|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.player.SpellListImpl
Manages the player's list of known spells.
Field Summary | |
protected java.util.Set |
spells_
|
Constructor Summary | |
SpellListImpl()
|
Method Summary | |
void |
addSpell(java.lang.String name)
Adds a spell to the list; used by the map editor. |
static boolean |
addToPlayer(Commandable player)
Ensures player has a spell list. |
java.lang.Object |
createClone()
Produces a clone of the property for the caller. |
boolean |
equals(java.lang.Object o)
Returns true if the passed SpellList is equivalent to this one. |
boolean |
forgetSpell(java.lang.String name,
Commandable agent)
Forgets a spell. |
int |
getSize()
Returns the number of spells in this list. |
java.lang.String[] |
getSpells()
Returns the spell names in this list. |
java.lang.String |
getSpellString()
Returns all the spells in the spellbook, as a formatted string of the form "spell_1 spell_2 spell_3". |
int |
hashCode()
Have to override this if you override equals(), in Java. |
boolean |
knowsSpell(java.lang.String name)
Checks whether the player knows this spell |
void |
learnSpell(java.lang.String name)
Learns a spell. |
boolean |
okToLearn(java.lang.String name,
Commandable agent,
java.lang.StringBuffer reason)
Checks whether player is allowed to learn this spell, taking into account the lore cost of the spell and available lore points. |
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
boolean |
shouldWrite()
Returns true if we should write the object at all. |
java.lang.String |
toString()
Prints the list, for debugging. |
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Set spells_
Constructor Detail |
public SpellListImpl()
Method Detail |
public void learnSpell(java.lang.String name)
learnSpell
in interface SpellList
name
- display-name of spell to learn, e.g. "word of recall"public boolean forgetSpell(java.lang.String name, Commandable agent)
forgetSpell
in interface SpellList
name
- the spell to forget, e.g. "create earth wall"agent
- the agent to whom to return the lore points
for the spell, or null if not applicable.
public boolean knowsSpell(java.lang.String name)
knowsSpell
in interface SpellList
name
- display name to check, e.g. "lightning bolt"
public boolean okToLearn(java.lang.String name, Commandable agent, java.lang.StringBuffer reason)
okToLearn
in interface SpellList
name
- spell to checkagent
- the agent trying to learn the spellreason
- the error message, if any
public java.lang.String[] getSpells()
getSpells
in interface SpellList
public static boolean addToPlayer(Commandable player)
player
- the player
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
readData
in interface SelfExternalizable
bean
- the XML DOM representation of the externalized
bean object. Its child could be a text node, in which case
the bean has to do all the parsing for the data. It could
also wrap a series of elements (e.g. archetypes), in which case
the bean may wish to leverage the XML parsing utilities that
the game provides in the ArchetypeManager and XMLWrapper.
java.lang.Exception
public java.util.List writeData() throws java.lang.Exception
writeData
in interface SelfExternalizable
java.lang.Exception
public boolean shouldWrite()
shouldWrite
in interface SelfExternalizable
public int getSize()
getSize
in interface SpellList
public void addSpell(java.lang.String name)
addSpell
in interface SpellList
name
- the name of the spell to addpublic java.lang.String getSpellString()
getSpellString
in interface SpellList
public java.lang.String toString()
public java.lang.Object createClone()
MutableProperty
createClone
in interface MutableProperty
public boolean equals(java.lang.Object o)
public int hashCode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |