DDSpellbook.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package org.leumasjaffe.charsheet.model.magic;
  2. import java.util.Collection;
  3. import java.util.List;
  4. import org.leumasjaffe.charsheet.model.observable.IntValue;
  5. import org.leumasjaffe.observer.Observable;
  6. import com.fasterxml.jackson.annotation.JsonIgnore;
  7. import com.fasterxml.jackson.annotation.JsonTypeInfo;
  8. import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
  9. import lombok.Getter;
  10. import lombok.NonNull;
  11. import lombok.Setter;
  12. @JsonTypeInfo(use = Id.MINIMAL_CLASS)
  13. public abstract class DDSpellbook extends Observable.Instance {
  14. public interface Secondary {
  15. DDSpellbook getMainSpellbook();
  16. void setMainSpellbook(DDSpellbook spellBook);
  17. }
  18. @Getter @Setter String name;
  19. @NonNull public abstract Collection<DDSpell> spellsKnownAtLevel( int level );
  20. @NonNull public abstract List<DDSpell> spellsPreparedAtLevel( int level );
  21. @NonNull public List<DDSpell> getSpellsPreparedPreviouslyForLevel(int level) { return spellsPreparedAtLevel(level); }
  22. public boolean learnsSpells() { return false; }
  23. public boolean preparesSpells() { return false; }
  24. @JsonIgnore public IntValue getSharedAllowedSlots() {
  25. return new IntValue(-1);
  26. }
  27. public int numSpellsKnownAtLevel( int level ) {
  28. return spellsKnownAtLevel( level ).size();
  29. }
  30. public abstract int numSpellsPerDayAtLevel( int level );
  31. public int numSpellsPerDayRemainingAtLevel(int level) {
  32. return spellsPreparedAtLevel( level ).size();
  33. }
  34. public abstract void castSpell( int level, final DDSpell spell );
  35. public String getSingleName() {
  36. return getName();
  37. }
  38. public void learnSpells(int level, Collection<DDSpell> known) {
  39. throw new UnsupportedOperationException("This class does not have a list of known spells to edit");
  40. }
  41. public abstract void prepareSpells(int level, Collection<DDSpell> collection);
  42. }