Class Spell
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.PassiveEntity
games.stendhal.server.entity.spell.Spell
- All Implemented Interfaces:
EquipListener,Killer,Dateable,Cloneable,Iterable<String>,Serializable
- Direct Known Subclasses:
AttackingSpell,HealingSpell,ModifyAtkSpell,ModifyDefSpell,ModifyHpSpell,SlowDownSpell
The base spell class
- Author:
- timothyb89, madmetzger
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID -
Field Summary
FieldsFields inherited from class marauroa.common.game.RPObject
INVALID_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeEquippedIn(String slot)Checks whether this object can be equipped in the given slot.voidCasts this spell if all preconditions are fulfilled: - caster has enough mana - cooldown time expired - caster has the minimum level - target is valid for the spellprotected abstract voidProvides the concrete behaviour of each concrete spell, i.e.static voidGenerate the RPClass for spellsintGet the spell amount.intgetAtk()Get the spell atk.intGet the spell cooldown.intgetDef()Get the spell def.doubleGet the spell lifesteal.intgetMana()Get the spell mana.intGet the spell minimum level.doublegetName()Get the spell name.intgetRange()Get the spell range.intgetRate()Get the spell rate.intgetRegen()Get the spell regen.longprotected booleanprotected booleanisTargetValid(Entity caster, Entity target)Checks if the target Entity is applicable for this spell.voidsetModifier(double modifier)voidvoidsetTimestamp(long time)Methods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getDescriptionName, getEntitySlot, getHeight, getOrigin, getResistance, getResistance, getTitle, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, onAdded, onMoved, onRemoved, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance, stopped, updateMethods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJsonMethods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlotsMethods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
RPCLASS_SPELL
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Spell
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 newSpellSub classes ofSpell*have to* provide a constructor with this order of parameters!- Parameters:
name- the name of the spellnature- the nature of the spellamount- the amount of the effect of this spellatk- the atk value of the spellcooldown- the time the spell needs to cool down before casting it againdef- the def value of the spelllifesteal- the percentage of lifesteal for this spellmana- the amount of mana this spell uses when casting itminimumlevel- the required minimum level for this spellrange- the max distance for the spell targetrate- the frequency of the effect of this spellregen- the amount to regen with each effect turnmodifier-
-
-
Method Details
-
cast
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 spelltarget- the entity the spell is aimed at- Throws:
SpellException
-
isCooledDown
protected boolean isCooledDown() -
doEffects
Provides the concrete behaviour of each concrete spell, i.e. a healing effect should done here- Parameters:
caster-target-
-
isTargetValid
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 spelltarget- 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
Description copied from interface:EquipListenerChecks whether this object can be equipped in the given slot.- Specified by:
canBeEquippedInin interfaceEquipListener- Parameters:
slot- name of slot- Returns:
- true, if it can be equipped; false otherwise
-
getName
Get the spell name. -
getAmount
public int getAmount()Get the spell amount.- Returns:
- The spell's amount, or
0if undefined.
-
getAtk
public int getAtk()Get the spell atk.- Returns:
- The spell's atk, or
0if undefined.
-
getCooldown
public int getCooldown()Get the spell cooldown.- Returns:
- The spell's cooldown, or
0if undefined.
-
getDef
public int getDef()Get the spell def.- Returns:
- The spell's def, or
0if undefined.
-
getLifesteal
public double getLifesteal()Get the spell lifesteal.- Returns:
- The spell's lifesteal, or
0if undefined.
-
getMana
public int getMana()Get the spell mana.- Returns:
- The spell's mana, or
0if undefined.
-
getMinimumLevel
public int getMinimumLevel()Get the spell minimum level.- Returns:
- The spell's minimum level, or
0if undefined.
-
getRange
public int getRange()Get the spell range.- Returns:
- The spell's range, or
0if undefined.
-
getRate
public int getRate()Get the spell rate.- Returns:
- The spell's rate, or
0if undefined.
-
getRegen
public int getRegen()Get the spell regen.- Returns:
- The spell's regen, or
0if undefined.
-
getTimestamp
public long getTimestamp()- Specified by:
getTimestampin interfaceDateable- Returns:
- point of time relevant for this object
-
setTimestamp
public void setTimestamp(long time) -
setNature
-
getNature
-
getModifier
public double getModifier() -
setModifier
public void setModifier(double modifier)
-