Class Spell

All Implemented Interfaces:
EquipListener, Killer, Dateable, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
AttackingSpell, HealingSpell, ModifyAtkSpell, ModifyDefSpell, ModifyHpSpell, SlowDownSpell

public abstract class Spell extends PassiveEntity implements EquipListener, Dateable
The base spell class
Author:
timothyb89, madmetzger
  • Field Details

  • Constructor Details

    • Spell

      public Spell(RPObject object)
      Creates a spell from an RPObject
      Parameters:
      object - the RPObject to create the spell from
    • Spell

      public Spell(String name, Nature nature, int amount, int atk, int cooldown, int def, double lifesteal, int mana, int minimumlevel, int range, int rate, int regen, double modifier)
      Creates a new Spell Sub classes of Spell *have to* provide a constructor with this order of parameters!
      Parameters:
      name - the name of the spell
      nature - the nature of the spell
      amount - the amount of the effect of this spell
      atk - the atk value of the spell
      cooldown - the time the spell needs to cool down before casting it again
      def - the def value of the spell
      lifesteal - the percentage of lifesteal for this spell
      mana - the amount of mana this spell uses when casting it
      minimumlevel - the required minimum level for this spell
      range - the max distance for the spell target
      rate - the frequency of the effect of this spell
      regen - the amount to regen with each effect turn
      modifier -
  • Method Details

    • cast

      public void cast(Player caster, Entity target) throws SpellException
      Casts this spell if all preconditions are fulfilled: - caster has enough mana - cooldown time expired - caster has the minimum level - target is valid for the spell
      Parameters:
      caster - the player who tries to cast this spell
      target - the entity the spell is aimed at
      Throws:
      SpellException
    • isCooledDown

      protected boolean isCooledDown()
    • doEffects

      protected abstract void doEffects(Player caster, Entity target)
      Provides the concrete behaviour of each concrete spell, i.e. a healing effect should done here
      Parameters:
      caster -
      target -
    • isTargetValid

      protected boolean isTargetValid(Entity caster, Entity target)
      Checks if the target Entity is applicable for this spell. Basically each Entity can target of a spell. Subclasses have to override this method if they want to be more strict in the choice of the target.
      Parameters:
      caster - the user of the spell
      target - the target Entity to check the applicability for
      Returns:
      true iff target is applicable to this spell
    • generateRPClass

      public static void generateRPClass()
      Generate the RPClass for spells
    • canBeEquippedIn

      public boolean canBeEquippedIn(String slot)
      Description copied from interface: EquipListener
      Checks whether this object can be equipped in the given slot.
      Specified by:
      canBeEquippedIn in interface EquipListener
      Parameters:
      slot - name of slot
      Returns:
      true, if it can be equipped; false otherwise
    • getName

      public String getName()
      Get the spell name.
      Specified by:
      getName in interface Killer
      Overrides:
      getName in class Entity
      Returns:
      The spell's name, or null if undefined.
    • getAmount

      public int getAmount()
      Get the spell amount.
      Returns:
      The spell's amount, or 0 if undefined.
    • getAtk

      public int getAtk()
      Get the spell atk.
      Returns:
      The spell's atk, or 0 if undefined.
    • getCooldown

      public int getCooldown()
      Get the spell cooldown.
      Returns:
      The spell's cooldown, or 0 if undefined.
    • getDef

      public int getDef()
      Get the spell def.
      Returns:
      The spell's def, or 0 if undefined.
    • getLifesteal

      public double getLifesteal()
      Get the spell lifesteal.
      Returns:
      The spell's lifesteal, or 0 if undefined.
    • getMana

      public int getMana()
      Get the spell mana.
      Returns:
      The spell's mana, or 0 if undefined.
    • getMinimumLevel

      public int getMinimumLevel()
      Get the spell minimum level.
      Returns:
      The spell's minimum level, or 0 if undefined.
    • getRange

      public int getRange()
      Get the spell range.
      Returns:
      The spell's range, or 0 if undefined.
    • getRate

      public int getRate()
      Get the spell rate.
      Returns:
      The spell's rate, or 0 if undefined.
    • getRegen

      public int getRegen()
      Get the spell regen.
      Returns:
      The spell's regen, or 0 if undefined.
    • getTimestamp

      public long getTimestamp()
      Specified by:
      getTimestamp in interface Dateable
      Returns:
      point of time relevant for this object
    • setTimestamp

      public void setTimestamp(long time)
    • setNature

      public void setNature(Nature nature)
    • getNature

      public Nature getNature()
    • getModifier

      public double getModifier()
    • setModifier

      public void setModifier(double modifier)