Class SpellsManager

  • All Implemented Interfaces:
    java.lang.Iterable<Spell>

    public class SpellsManager
    extends java.lang.Object
    implements java.lang.Iterable<Spell>
    Manages all known spells. Spells are filtered by skill through the function filterSkill().
    • Field Detail

      • UPD_SP_MANA

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

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

        public static final int UPD_SP_DAMAGE
        Flag for updspell command: damage is present.
        See Also:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • 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 java.lang.String spellName,
                             @NotNull
                             @NotNull java.lang.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

        @NotNull
        public @NotNull Spell getSpell​(@NotNull
                                       @NotNull java.lang.String spellName)
        Returns a Spell instance by spell name. Creates a new instance if the spell is unknown.
        Parameters:
        spellName - the spell name to find
        Returns:
        the spell instance
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<Spell> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Spell>
      • getSpells

        public int getSpells()
        Returns the number of known spells.
        Returns:
        the number of spells
      • getSpell

        @Nullable
        public @Nullable Spell getSpell​(int index)
        Returns a Spell instance by index.
        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()
        An 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