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
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canBeEquippedIn(String slot)
Checks whether this object can be equipped in the given slot.void
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 spellprotected abstract void
Provides the concrete behaviour of each concrete spell, i.e.static void
Generate the RPClass for spellsint
Get the spell amount.int
getAtk()
Get the spell atk.int
Get the spell cooldown.int
getDef()
Get the spell def.double
Get the spell lifesteal.int
getMana()
Get the spell mana.int
Get the spell minimum level.double
getName()
Get the spell name.int
getRange()
Get the spell range.int
getRate()
Get the spell rate.int
getRegen()
Get the spell regen.long
protected boolean
protected boolean
isTargetValid(Entity caster, Entity target)
Checks if the target Entity is applicable for this spell.void
setModifier(double modifier)
void
void
setTimestamp(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, update
Methods 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, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods 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, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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 newSpell
Sub 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:EquipListener
Checks whether this object can be equipped in the given slot.- Specified by:
canBeEquippedIn
in 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
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 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)
-