Modifier and Type | Field and Description |
---|---|
private java.util.List<Spell> |
filteredSpells
Spells currently exposed, based on the filter.
|
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private EventListenerList2<SpellsManagerListener> |
listeners
The
SpellsManagerListeners to notify about
changes. |
private static java.util.Comparator<Skill> |
SKILL_COMPARATOR
Compare 2 skills.
|
private Skill |
skillAll
Dummy skill for "all skills".
|
private int |
skillFilter
Skill to filter spells by, as a skill id in
SkillSet . |
private SkillSet |
skillSet
The
SkillSet containing skills from the server. |
private java.util.Comparator<Spell> |
spellNameComparator
A
Comparator to compare Spell instances by spell path and
name. |
private java.util.List<Spell> |
spells
All known spells.
|
private java.util.List<Skill> |
spellSkills
Skills used by the spell, including the "all" skill.
|
private Stats |
stats
The
Stats for the player. |
private java.util.Map<java.lang.String,Spell> |
unknownSpells
All unknown spells that have been referenced before.
|
static int |
UPD_SP_DAMAGE
Flag for updspell command: damage is present.
|
static int |
UPD_SP_GRACE
Flag for updspell command: grace is present.
|
static int |
UPD_SP_MANA
Flag for updspell command: mana is present.
|
Constructor and Description |
---|
SpellsManager(GuiStateManager guiStateManager,
SkillSet skillSet,
Stats stats)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCrossfireSpellChangedListener(SpellsManagerListener listener)
Adds a
SpellsManagerListener to notify about changes. |
void |
addSpell(int tag,
int level,
int castingTime,
int mana,
int grace,
int damage,
int skill,
int path,
int faceNum,
java.lang.String spellName,
java.lang.String message)
Adds a new spell.
|
void |
deleteSpell(int tag)
Deletes a spell.
|
private void |
deleteSpellByIndex(int index)
Deletes a spell by index into
spells . |
boolean |
displaysFace(int faceNum)
Returns whether any spell has the given face.
|
void |
filterSkill(int index)
Filters spells to display by the specified skill index.
|
private void |
filterSpells()
Rebuilds the list of spells to display.
|
Spell |
getSpell(int index)
Returns a
Spell instance by index. |
Spell |
getSpell(java.lang.String spellName)
Returns a
Spell instance by spell name. |
int |
getSpells()
Returns the number of known spells.
|
Skill |
getSpellSkill(int index)
Returns the specified spell skill.
|
int |
getSpellSkills()
Returns the number of spell skills.
|
java.util.Iterator<Spell> |
iterator() |
private void |
rebuildSkills()
Rebuilds the list of skills from the spells.
|
void |
removeCrossfireSpellChangedListener(SpellsManagerListener listener)
Removes a
SpellsManagerListener to notify about changes. |
void |
selectCharacter()
An character name was sent to the server.
|
void |
updateSpell(int flags,
int tag,
int mana,
int grace,
int damage)
Updates spell information.
|
@NotNull private final java.util.List<Spell> filteredSpells
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@NotNull private final EventListenerList2<SpellsManagerListener> listeners
SpellsManagerListeners
to notify about
changes.private static final java.util.Comparator<Skill> SKILL_COMPARATOR
private final Skill skillAll
private int skillFilter
SkillSet
. -1 means to
not filter.@NotNull private final java.util.Comparator<Spell> spellNameComparator
Comparator
to compare Spell
instances by spell path and
name.@NotNull private final java.util.List<Spell> spells
private final java.util.List<Skill> spellSkills
@NotNull private final java.util.Map<java.lang.String,Spell> unknownSpells
Spell
instance. Accesses are synchronized on this instance.public static final int UPD_SP_DAMAGE
public static final int UPD_SP_GRACE
public static final int UPD_SP_MANA
public SpellsManager(@NotNull GuiStateManager guiStateManager, @NotNull SkillSet skillSet, @NotNull Stats stats)
guiStateManager
- the gui state manager to watchskillSet
- skills the players knowsstats
- the stats for the playerpublic void addCrossfireSpellChangedListener(@NotNull SpellsManagerListener listener)
SpellsManagerListener
to notify about changes.listener
- the listener to addpublic void addSpell(int tag, int level, int castingTime, int mana, int grace, int damage, int skill, int path, int faceNum, @NotNull java.lang.String spellName, @NotNull java.lang.String message)
unknownSpells
if
possible.tag
- the spell's taglevel
- the spell's levelcastingTime
- the spell's casting timemana
- the spell's mana costgrace
- the spell's grace costdamage
- the spell's damageskill
- the spell's skillpath
- the spell's pathfaceNum
- the spell's face numberspellName
- the spell's namemessage
- the spells' descriptionpublic void deleteSpell(int tag)
tag
- the spell's tagprivate void deleteSpellByIndex(int index)
spells
.index
- the index to deletepublic boolean displaysFace(int faceNum)
faceNum
- the facepublic void filterSkill(int index)
index
- the skill index, should be less than getSpellSkills()private void filterSpells()
@Nullable public Spell getSpell(int index)
Spell
instance by index.index
- the indexnull
if the index is invalid@NotNull public Spell getSpell(@NotNull java.lang.String spellName)
Spell
instance by spell name. Creates a new instance if
the spell is unknown.spellName
- the spell name to findpublic int getSpells()
@Nullable public Skill getSpellSkill(int index)
index
- the skill index, from 0 to getSpellSkills()-1null
if index is invalidpublic int getSpellSkills()
@NotNull public java.util.Iterator<Spell> iterator()
iterator
in interface java.lang.Iterable<Spell>
private void rebuildSkills()
public void removeCrossfireSpellChangedListener(@NotNull SpellsManagerListener listener)
SpellsManagerListener
to notify about changes.listener
- the listener to removepublic void selectCharacter()
public void updateSpell(int flags, int tag, int mana, int grace, int damage)
flags
- specifies which fields to updatetag
- the spell's tagmana
- the spell's new mana costgrace
- the spell's new grace costdamage
- the spell's new damage