Class SpellMemory

java.lang.Object
SpellMemory
All Implemented Interfaces:
Iterable<Spell>

public class SpellMemory extends Object implements Iterable<Spell>
Memory of spells known by one creature. We don't allow duplicates, so this uses the Set interface.
Since:
2021-12-19
  • Field Details

    • memory

      Set<Spell> memory
      The set of spells in memory (no duplicates).
    • preferCastableSpells

      static boolean preferCastableSpells
      Should we select in-sim castable spells first?
  • Constructor Details

    • SpellMemory

      public SpellMemory()
      Constructor.
    • SpellMemory

      public SpellMemory(SpellMemory src)
      Copy constructor.
  • Method Details

    • setPreferCastableSpells

      public static void setPreferCastableSpells(boolean prefer)
      Set static preference for in-sim castable spells.
    • add

      public boolean add(Spell s)
      Add a spell.
    • remove

      public boolean remove(Spell s)
      Remove a spell.
    • contains

      public boolean contains(Spell s)
      Is this spell in our memory?
    • isBlank

      public boolean isBlank()
      Is our memory empty?
    • countAtLevel

      public int countAtLevel(int level)
      Count spells of a given level.
    • getAtLevel

      private Spell getAtLevel(int level)
      Get a random spell of a given level.
    • addRandom

      public boolean addRandom(int level)
      Add a random spell from index at a given level. Use rollMode() for weightings.
      Returns:
      true if we added a spell.
    • rollMode

      private Spell.Mode rollMode()
      Roll random selected spell mode. As per analysis of Gygax modules: see blog 2018-12-17.
    • addByName

      public void addByName(String name)
      Add a spell by naming it.
    • addSpellsForWizard

      public void addSpellsForWizard(int level)
      Add all spells for a wizard of a given level.
    • loseSpellLevel

      public void loseSpellLevel(int level)
      Lose the top character level load-out of spells. Bound memory by next lower level daily spells.
    • hasCastableSpells

      public boolean hasCastableSpells()
      Are there any castable spells in this memory?
    • toString

      public String toString()
      Identify this object as a string.
      Overrides:
      toString in class Object
    • iterator

      public Iterator<Spell> iterator()
      Return iterator for the iterable interface.
      Specified by:
      iterator in interface Iterable<Spell>
    • main

      public static void main(String[] args)
      Main test function.