Class SpellsManager

java.lang.Object
com.realtime.crossfire.jxclient.spells.SpellsManager

public class SpellsManager extends Object
Manages all known spells. Spells are filtered by skill through the function filterSkill().
  • Field Details

    • UPD_SP_MANA

      public static final int UPD_SP_MANA
      Flag for updspell command: mana is present.
      See Also:
    • UPD_SP_GRACE

      public static final int UPD_SP_GRACE
      Flag for updspell command: grace is present.
      See Also:
    • UPD_SP_DAMAGE

      public static final int UPD_SP_DAMAGE
      Flag for updspell command: damage is present.
      See Also:
  • Constructor Details

    • SpellsManager

      public SpellsManager(@NotNull @NotNull GuiStateManager guiStateManager, @NotNull @NotNull SkillSet skillSet, @NotNull @NotNull Stats stats)
      Creates a new instance.
      Parameters:
      guiStateManager - the gui state manager to watch
      skillSet - skills the players knows
      stats - the stats for the player
  • Method Details

    • addCrossfireSpellChangedListener

      public void addCrossfireSpellChangedListener(@NotNull @NotNull SpellsManagerListener listener)
      Adds a SpellsManagerListener to notify about changes.
      Parameters:
      listener - the listener to add
    • removeCrossfireSpellChangedListener

      public void removeCrossfireSpellChangedListener(@NotNull @NotNull SpellsManagerListener listener)
      Removes a SpellsManagerListener to notify about changes.
      Parameters:
      listener - the listener to remove
    • addSpell

      public void addSpell(int tag, int level, int castingTime, int mana, int grace, int damage, int skill, int path, int faceNum, @NotNull @NotNull String spellName, @NotNull @NotNull String message)
      Adds a new spell. Re-uses entries from unknownSpells if possible.
      Parameters:
      tag - the spell's tag
      level - the spell's level
      castingTime - the spell's casting time
      mana - the spell's mana cost
      grace - the spell's grace cost
      damage - the spell's damage
      skill - the spell's skill
      path - the spell's path
      faceNum - the spell's face number
      spellName - the spell's name
      message - the spells' description
    • updateSpell

      public void updateSpell(int flags, int tag, int mana, int grace, int damage)
      Updates spell information.
      Parameters:
      flags - specifies which fields to update
      tag - the spell's tag
      mana - the spell's new mana cost
      grace - the spell's new grace cost
      damage - the spell's new damage
    • deleteSpell

      public void deleteSpell(int tag)
      Deletes a spell.
      Parameters:
      tag - the spell's tag
    • getSpell

      @Nullable public @Nullable Spell getSpell(@NotNull @NotNull String spellName)
      Returns a Spell instance by partial spell name.
      Parameters:
      spellName - the spell name to find
      Returns:
      the spell instance or null if the spell is unknown
    • getAllSpells

      @NotNull public @NotNull Collection<Spell> getAllSpells()
      Returns all known spells.
      Returns:
      the known spells
    • getFilteredSpells

      @NotNull public @NotNull Collection<Spell> getFilteredSpells()
      Returns all currently shown spells.
      Returns:
      all currently shown spells
    • getFilteredSpellsCount

      public int getFilteredSpellsCount()
      Returns the number of currently shown spells.
      Returns:
      the number of currently shown spells
    • getFilteredSpell

      @Nullable public @Nullable Spell getFilteredSpell(int index)
      Returns a Spell instance by index. Considers only currently shown spells.
      Parameters:
      index - the index
      Returns:
      the spell or null if the index is invalid
    • displaysFace

      public boolean displaysFace(int faceNum)
      Returns whether any spell has the given face.
      Parameters:
      faceNum - the face
      Returns:
      whether the face was found
    • selectCharacter

      public void selectCharacter()
      A character name was sent to the server.
    • filterSkill

      public void filterSkill(int index)
      Filters spells to display by the specified skill index.
      Parameters:
      index - the skill index, should be less than getSpellSkills()
    • getSpellSkills

      public int getSpellSkills()
      Returns the number of spell skills.
      Returns:
      the number of skills
    • getSpellSkill

      @Nullable public @Nullable Skill getSpellSkill(int index)
      Returns the specified spell skill.
      Parameters:
      index - the skill index, from 0 to getSpellSkills()-1
      Returns:
      the specified skill, null if index is invalid