Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.spells.SpellsManager Class Reference

Manages all known spells. More...

+ Inheritance diagram for com.realtime.crossfire.jxclient.spells.SpellsManager:
+ Collaboration diagram for com.realtime.crossfire.jxclient.spells.SpellsManager:

Public Member Functions

void addCrossfireSpellChangedListener (@NotNull final SpellsManagerListener listener)
 Adds a SpellsManagerListener to notify about changes. More...
 
void addSpell (final int tag, final int level, final int castingTime, final int mana, final int grace, final int damage, final int skill, final int path, final int faceNum, @NotNull final String spellName, @NotNull final String message)
 Adds a new spell. More...
 
void deleteSpell (final int tag)
 Deletes a spell. More...
 
boolean displaysFace (final int faceNum)
 Returns whether any spell has the given face. More...
 
void filterSkill (final int index)
 Filters spells to display by the specified skill index. More...
 
Spell getSpell (@NotNull final String spellName)
 Returns a Spell instance by spell name. More...
 
Spell getSpell (final int index)
 Returns a Spell instance by index. More...
 
int getSpells ()
 Returns the number of known spells. More...
 
Skill getSpellSkill (final int index)
 Returns the specified spell skill. More...
 
int getSpellSkills ()
 Returns the number of spell skills. More...
 
Iterator< Spelliterator ()
 
void removeCrossfireSpellChangedListener (@NotNull final SpellsManagerListener listener)
 Removes a SpellsManagerListener to notify about changes. More...
 
void selectCharacter ()
 An character name was sent to the server. More...
 
 SpellsManager (@NotNull final GuiStateManager guiStateManager, @NotNull final SkillSet skillSet, @NotNull final Stats stats)
 Creates a new instance. More...
 
void updateSpell (final int flags, final int tag, final int mana, final int grace, final int damage)
 Updates spell information. More...
 

Static Public Attributes

static final int UPD_SP_DAMAGE = 4
 Flag for updspell command: damage is present. More...
 
static final int UPD_SP_GRACE = 2
 Flag for updspell command: grace is present. More...
 
static final int UPD_SP_MANA = 1
 Flag for updspell command: mana is present. More...
 

Private Member Functions

void deleteSpellByIndex (final int index)
 Deletes a spell by index into spells. More...
 
void filterSpells ()
 Rebuilds the list of spells to display. More...
 
void rebuildSkills ()
 Rebuilds the list of skills from the spells. More...
 

Private Attributes

final List< SpellfilteredSpells = new CopyOnWriteArrayList<>()
 Spells currently exposed, based on the filter. More...
 
final GuiStateListener guiStateListener
 The GuiStateListener for detecting established or dropped connections. More...
 
final EventListenerList2< SpellsManagerListenerlisteners = new EventListenerList2<>()
 The SpellsManagerListeners to notify about changes. More...
 
final Skill skillAll = new Skill("All skills")
 Dummy skill for "all skills". More...
 
int skillFilter = -1
 Skill to filter spells by, as a skill id in SkillSet. More...
 
final SkillSet skillSet
 The SkillSet containing skills from the server. More...
 
final Comparator< SpellspellNameComparator = new SpellComparator()
 A Comparator to compare Spell instances by spell path and name. More...
 
final List< Spellspells = new CopyOnWriteArrayList<>()
 All known spells. More...
 
final List< SkillspellSkills = new ArrayList<>()
 Skills used by the spell, including the "all" skill. More...
 
final Stats stats
 The Stats for the player. More...
 
final Map< String, SpellunknownSpells = new HashMap<>()
 All unknown spells that have been referenced before. More...
 

Static Private Attributes

static final Comparator< SkillSKILL_COMPARATOR = (o1, o2) -> o1.toString().compareTo(o2.toString())
 Compare 2 skills. More...
 

Detailed Description

Manages all known spells.

Spells are filtered by skill through the function filterSkill().

Author
Lauwenmark
Andreas Kirschbaum

Definition at line 49 of file SpellsManager.java.

Constructor & Destructor Documentation

◆ SpellsManager()

com.realtime.crossfire.jxclient.spells.SpellsManager.SpellsManager ( @NotNull final GuiStateManager  guiStateManager,
@NotNull final SkillSet  skillSet,
@NotNull final Stats  stats 
)

Creates a new instance.

Parameters
guiStateManagerthe gui state manager to watch
skillSetskills the players knows
statsthe stats for the player

Definition at line 183 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.spells.SpellsManager.guiStateListener, com.realtime.crossfire.jxclient.spells.SpellsManager.skillSet, and com.realtime.crossfire.jxclient.spells.SpellsManager.stats.

Member Function Documentation

◆ addCrossfireSpellChangedListener()

void com.realtime.crossfire.jxclient.spells.SpellsManager.addCrossfireSpellChangedListener ( @NotNull final SpellsManagerListener  listener)

Adds a SpellsManagerListener to notify about changes.

Parameters
listenerthe listener to add

Definition at line 193 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ addSpell()

void com.realtime.crossfire.jxclient.spells.SpellsManager.addSpell ( final int  tag,
final int  level,
final int  castingTime,
final int  mana,
final int  grace,
final int  damage,
final int  skill,
final int  path,
final int  faceNum,
@NotNull final String  spellName,
@NotNull final String  message 
)

Adds a new spell.

Re-uses entries from unknownSpells if possible.

Parameters
tagthe spell's tag
levelthe spell's level
castingTimethe spell's casting time
manathe spell's mana cost
gracethe spell's grace cost
damagethe spell's damage
skillthe spell's skill
paththe spell's path
faceNumthe spell's face number
spellNamethe spell's name
messagethe spells' description

Definition at line 220 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.spells.SpellsManager.filterSpells(), com.realtime.crossfire.jxclient.spells.SpellsManager.rebuildSkills(), com.realtime.crossfire.jxclient.spells.Spell.setParameters(), and com.realtime.crossfire.jxclient.spells.SpellsManager.unknownSpells.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection.processAddSpell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteSpell()

void com.realtime.crossfire.jxclient.spells.SpellsManager.deleteSpell ( final int  tag)

◆ deleteSpellByIndex()

void com.realtime.crossfire.jxclient.spells.SpellsManager.deleteSpellByIndex ( final int  index)
private

◆ displaysFace()

boolean com.realtime.crossfire.jxclient.spells.SpellsManager.displaysFace ( final int  faceNum)

Returns whether any spell has the given face.

Parameters
faceNumthe face
Returns
whether the face was found

Definition at line 363 of file SpellsManager.java.

◆ filterSkill()

void com.realtime.crossfire.jxclient.spells.SpellsManager.filterSkill ( final int  index)

Filters spells to display by the specified skill index.

Parameters
indexthe skill index, should be less than getSpellSkills()

Definition at line 385 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.spells.SpellsManager.filterSpells(), and com.realtime.crossfire.jxclient.skills.SkillSet.getSkillId().

Referenced by com.realtime.crossfire.jxclient.gui.list.GUISpellSkillList.selectionChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterSpells()

void com.realtime.crossfire.jxclient.spells.SpellsManager.filterSpells ( )
private

◆ getSpell() [1/2]

Spell com.realtime.crossfire.jxclient.spells.SpellsManager.getSpell ( @NotNull final String  spellName)

Returns a Spell instance by spell name.

Creates a new instance if the spell is unknown.

Parameters
spellNamethe spell name to find
Returns
the spell instance

Definition at line 312 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.spells.Spell.getName(), com.realtime.crossfire.jxclient.spells.Spell.setUnknown(), and com.realtime.crossfire.jxclient.spells.SpellsManager.unknownSpells.

Referenced by com.realtime.crossfire.jxclient.items.SpellsView.getItem(), com.realtime.crossfire.jxclient.gui.item.GUIItemSpell.setSpell(), com.realtime.crossfire.jxclient.shortcuts.Shortcuts.setSpellShortcut(), and com.realtime.crossfire.jxclient.gui.list.GUISpellList.updateTooltip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSpell() [2/2]

Spell com.realtime.crossfire.jxclient.spells.SpellsManager.getSpell ( final int  index)

Returns a Spell instance by index.

Parameters
indexthe index
Returns
the spell or
null
if the index is invalid

Definition at line 350 of file SpellsManager.java.

◆ getSpells()

int com.realtime.crossfire.jxclient.spells.SpellsManager.getSpells ( )

Returns the number of known spells.

Returns
the number of spells

Definition at line 340 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.gui.item.GUIItemSpellSkill.canScroll(), com.realtime.crossfire.jxclient.gui.item.GUIItemSpell.canScroll(), and com.realtime.crossfire.jxclient.items.SpellsView.getSize().

+ Here is the caller graph for this function:

◆ getSpellSkill()

Skill com.realtime.crossfire.jxclient.spells.SpellsManager.getSpellSkill ( final int  index)

Returns the specified spell skill.

Parameters
indexthe skill index, from 0 to getSpellSkills()-1
Returns
the specified skill,
null
if index is invalid

Definition at line 441 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.items.SpellSkillView.getItem(), com.realtime.crossfire.jxclient.gui.item.GUIItemSpellSkill.setSkill(), and com.realtime.crossfire.jxclient.gui.list.GUISpellSkillList.updateTooltip().

+ Here is the caller graph for this function:

◆ getSpellSkills()

int com.realtime.crossfire.jxclient.spells.SpellsManager.getSpellSkills ( )

Returns the number of spell skills.

Returns
the number of skills

Definition at line 431 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.items.SpellSkillView.getSize().

+ Here is the caller graph for this function:

◆ iterator()

Iterator<Spell> com.realtime.crossfire.jxclient.spells.SpellsManager.iterator ( )

Definition at line 332 of file SpellsManager.java.

◆ rebuildSkills()

void com.realtime.crossfire.jxclient.spells.SpellsManager.rebuildSkills ( )
private

Rebuilds the list of skills from the spells.

Definition at line 415 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.skills.SkillSet.getSkill().

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.addSpell(), com.realtime.crossfire.jxclient.spells.SpellsManager.deleteSpell(), and com.realtime.crossfire.jxclient.spells.SpellsManager.deleteSpellByIndex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeCrossfireSpellChangedListener()

void com.realtime.crossfire.jxclient.spells.SpellsManager.removeCrossfireSpellChangedListener ( @NotNull final SpellsManagerListener  listener)

Removes a SpellsManagerListener to notify about changes.

Parameters
listenerthe listener to remove

Definition at line 201 of file SpellsManager.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

Referenced by com.realtime.crossfire.jxclient.gui.item.GUIItemSpellSkill.dispose(), and com.realtime.crossfire.jxclient.gui.item.GUIItemSpell.dispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectCharacter()

void com.realtime.crossfire.jxclient.spells.SpellsManager.selectCharacter ( )

An character name was sent to the server.

Definition at line 376 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.AbstractCrossfireServerConnection.fireSelectCharacter().

+ Here is the caller graph for this function:

◆ updateSpell()

void com.realtime.crossfire.jxclient.spells.SpellsManager.updateSpell ( final int  flags,
final int  tag,
final int  mana,
final int  grace,
final int  damage 
)

Updates spell information.

Parameters
flagsspecifies which fields to update
tagthe spell's tag
manathe spell's new mana cost
gracethe spell's new grace cost
damagethe spell's new damage

Definition at line 260 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection.processUpdSpell().

+ Here is the caller graph for this function:

Member Data Documentation

◆ filteredSpells

final List<Spell> com.realtime.crossfire.jxclient.spells.SpellsManager.filteredSpells = new CopyOnWriteArrayList<>()
private

Spells currently exposed, based on the filter.

Definition at line 76 of file SpellsManager.java.

◆ guiStateListener

final GuiStateListener com.realtime.crossfire.jxclient.spells.SpellsManager.guiStateListener
private

The GuiStateListener for detecting established or dropped connections.

Definition at line 111 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.SpellsManager().

◆ listeners

final EventListenerList2<SpellsManagerListener> com.realtime.crossfire.jxclient.spells.SpellsManager.listeners = new EventListenerList2<>()
private

The SpellsManagerListeners to notify about changes.

Definition at line 96 of file SpellsManager.java.

◆ SKILL_COMPARATOR

final Comparator<Skill> com.realtime.crossfire.jxclient.spells.SpellsManager.SKILL_COMPARATOR = (o1, o2) -> o1.toString().compareTo(o2.toString())
staticprivate

Compare 2 skills.

Definition at line 175 of file SpellsManager.java.

◆ skillAll

final Skill com.realtime.crossfire.jxclient.spells.SpellsManager.skillAll = new Skill("All skills")
private

Dummy skill for "all skills".

Definition at line 165 of file SpellsManager.java.

◆ skillFilter

int com.realtime.crossfire.jxclient.spells.SpellsManager.skillFilter = -1
private

Skill to filter spells by, as a skill id in SkillSet.

-1 means to not filter.

Definition at line 82 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.filterSpells().

◆ skillSet

final SkillSet com.realtime.crossfire.jxclient.spells.SpellsManager.skillSet
private

The SkillSet containing skills from the server.

Definition at line 155 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.SpellsManager().

◆ spellNameComparator

final Comparator<Spell> com.realtime.crossfire.jxclient.spells.SpellsManager.spellNameComparator = new SpellComparator()
private

A Comparator to compare Spell instances by spell path and name.

Definition at line 103 of file SpellsManager.java.

◆ spells

final List<Spell> com.realtime.crossfire.jxclient.spells.SpellsManager.spells = new CopyOnWriteArrayList<>()
private

All known spells.

Definition at line 70 of file SpellsManager.java.

◆ spellSkills

final List<Skill> com.realtime.crossfire.jxclient.spells.SpellsManager.spellSkills = new ArrayList<>()
private

Skills used by the spell, including the "all" skill.

Definition at line 170 of file SpellsManager.java.

◆ stats

final Stats com.realtime.crossfire.jxclient.spells.SpellsManager.stats
private

The Stats for the player.

Definition at line 160 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.SpellsManager().

◆ unknownSpells

final Map<String, Spell> com.realtime.crossfire.jxclient.spells.SpellsManager.unknownSpells = new HashMap<>()
private

All unknown spells that have been referenced before.

Maps spell name to Spell instance. Accesses are synchronized on this instance.

Definition at line 89 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.spells.SpellsManager.addSpell(), com.realtime.crossfire.jxclient.spells.SpellsManager.deleteSpellByIndex(), and com.realtime.crossfire.jxclient.spells.SpellsManager.getSpell().

◆ UPD_SP_DAMAGE

final int com.realtime.crossfire.jxclient.spells.SpellsManager.UPD_SP_DAMAGE = 4
static

Flag for updspell command: damage is present.

Definition at line 64 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection.processUpdSpell().

◆ UPD_SP_GRACE

final int com.realtime.crossfire.jxclient.spells.SpellsManager.UPD_SP_GRACE = 2
static

Flag for updspell command: grace is present.

Definition at line 59 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection.processUpdSpell().

◆ UPD_SP_MANA

final int com.realtime.crossfire.jxclient.spells.SpellsManager.UPD_SP_MANA = 1
static

Flag for updspell command: mana is present.

Definition at line 54 of file SpellsManager.java.

Referenced by com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection.processUpdSpell().


The documentation for this class was generated from the following file: