Class SpellMemory
java.lang.Object
SpellMemory
Memory of spells known by one creature.
We don't allow duplicates, so this uses the Set interface.
- Since:
- 2021-12-19
-
Field Summary
Modifier and TypeFieldDescriptionThe set of spells in memory (no duplicates).(package private) static boolean
Should we select in-sim castable spells first? -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a spell.void
Add a spell by naming it.boolean
addRandom
(int level) Add a random spell from index at a given level.void
addSpellsForWizard
(int level) Add all spells for a wizard of a given level.boolean
Is this spell in our memory?int
countAtLevel
(int level) Count spells of a given level.private Spell
getAtLevel
(int level) Get a random spell of a given level.boolean
Are there any castable spells in this memory?boolean
isBlank()
Is our memory empty?iterator()
Return iterator for the iterable interface.void
loseSpellLevel
(int level) Lose the top character level load-out of spells.static void
Main test function.boolean
Remove a spell.private Spell.Mode
rollMode()
Roll random selected spell mode.static void
setPreferCastableSpells
(boolean prefer) Set static preference for in-sim castable spells.toString()
Identify this object as a string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
memory
The set of spells in memory (no duplicates). -
preferCastableSpells
static boolean preferCastableSpellsShould we select in-sim castable spells first?
-
-
Constructor Details
-
SpellMemory
public SpellMemory()Constructor. -
SpellMemory
Copy constructor.
-
-
Method Details
-
setPreferCastableSpells
public static void setPreferCastableSpells(boolean prefer) Set static preference for in-sim castable spells. -
add
Add a spell. -
remove
Remove a spell. -
contains
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
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
Roll random selected spell mode. As per analysis of Gygax modules: see blog 2018-12-17. -
addByName
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
Identify this object as a string. -
iterator
Return iterator for the iterable interface. -
main
Main test function.
-