Class Item
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.item.Item
- All Implemented Interfaces:
EquipListener
,TurnListener
,UseListener
,Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
AreaUseItem
,Box
,BreakableItem
,CaptureTheFlagFlag
,Container
,Dice
,DummyWeapon
,FoodMill
,GateKey
,HouseKey
,ItemInformation
,LifeSupportGear
,NecroStaff
,OwnedItem
,RingOfLife
,SlotActivatedItem
,StackableItem
,Token
,WeddingRing
This is an item.
-
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 TypeMethodDescriptionvoid
Bind the item to a player, if the item is one that should be automatically bound, and the item is not already bound.boolean
canBeEquippedIn(String slot)
Checks whether this object can be equipped in the given slot.describe()
Describes the entity (if a players looks at it).void
Propose increase the degree of deterioration.void
deteriorate(RPEntity user)
Can be overridden to handle actions on user entity.static void
int
Returns the attack points of this item.int
Returns each how many turns this item can attack.int
getAttackRate(boolean meleeDistance)
Returns turn delay for this item's attack.Get the player this is bound to.Get the type of damage inflicted by this item.static int
Retrieves default attack rate for items.int
Returns the defense points of this item.getDescriptionName(boolean definite)
Returns the name or something that can be used to identify the entity for the player.int
Each Item is subject to deterioration that weakens the itemGet the item's infoString.int
gets the min levelgetName()
Gets the name of the item.returns the PlantGrower which created this item or null if no plantgrower was involved.int
Get item count.int
Returns the ranged attack points of this item.double
getSusceptibility(Nature type)
Get this item's contribution to susceptibility to a type of damage.getTitle()
Get the nicely formatted entity title/name.Get a weapon type identifier that can be used in attack events, so that the client can draw an appropriate item image for the attack.void
initializeActiveSlotsList(List<String> slotList)
Override in SlotActivatedItem sub-class.void
initializeStatusResistancesList(Map<StatusType,Double> resistanceList)
Override in StatusResistantItem sub-class.boolean
isBound()
Check if the item is bound to a playerboolean
boolean
Checks if the item is of type type .boolean
Returns if the item is persistent.boolean
Is the item undroppable.boolean
onEquipped(RPEntity equipper, String slot)
opportunity to affect the player when equipped currently returns boolean, to indicate whether it made any change TODO: should this return some sort of undoable thing (if it can be undone?)void
onPickedUp(Player player)
void
onPutOnGround(boolean expire)
Is called when the item is created.void
onPutOnGround(Player player)
Is called when the item is moved to the ground.void
void
onTurnReached(int currentTurn)
This method is called when the turn number is reached.boolean
item is about to be removed from owner.boolean
Invoked when the object is used.void
void
Removes the item.void
repair()
repair this itemvoid
setBoundTo(String name)
Bind this item to a player.void
setDamageType(Nature type)
Set the type of damage inflicted by this itemvoid
setEquipableSlots(List<String> slots)
on which slots may this item be equipped.void
setFromCorpse(boolean fromCorpse)
void
setInfoString(String infostring)
Set the item's infostring.void
setPersistent(boolean persistent)
Set the item's persistence.void
setPlantGrower(PassiveEntityRespawnPoint plantGrower)
If this item is created by a PlantGrower, the item will notify it when picked from the ground.void
setSusceptibilities(Map<Nature,Double> susceptibilities)
Set the susceptibility data of this item.void
setUndroppableOnDeath(boolean unDroppableOnDeath)
Set is the item undroppable when player dies.void
setUseBehavior(UseBehavior behavior)
Set behavior to follow when the item is used.toString()
This method returns a String that represent the objectMethods inherited from class games.stendhal.server.entity.Entity
getAdjacentNodes, getArea, getArea, getCursor, getDescription, getEntitySlot, getHeight, getOrigin, getResistance, getResistance, 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, 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
-
DEGRADATION_TIMEOUT
public static final int DEGRADATION_TIMEOUT- See Also:
- Constant Field Values
-
-
Constructor Details
-
Item
Creates a new Item.- Parameters:
name
- name of itemclazz
- class (or type) of itemsubclass
- subclass of this itemattributes
- attributes (like attack). may be empty ornull
-
Item
copy constructor.- Parameters:
item
- item to copy
-
-
Method Details
-
generateRPClass
public static void generateRPClass() -
setEquipableSlots
on which slots may this item be equipped.- Parameters:
slots
- list of allowed slots
-
setPlantGrower
If this item is created by a PlantGrower, the item will notify it when picked from the ground.- Parameters:
plantGrower
- a plant grower
-
getPlantGrower
returns the PlantGrower which created this item or null if no plantgrower was involved.- Returns:
- PlantGrower or null
-
getAttack
public int getAttack()Returns the attack points of this item. Positive and negative values are allowed. If this item doesn't modify the attack it should return '0'.- Returns:
- attack points
-
getDefense
public int getDefense()Returns the defense points of this item. Positive and negative values are allowed. If this item doesn't modify the defense it should return '0'.- Returns:
- defense points
-
getRangedAttack
public int getRangedAttack()Returns the ranged attack points of this item. Positive and negative values are allowed. If this item doesn't modify the ranged attack it should return '0'.- Returns:
- ranged attack points
-
getAttackRate
public int getAttackRate()Returns each how many turns this item can attack.- Returns:
- each how many turns this item can attack.
-
getAttackRate
public int getAttackRate(boolean meleeDistance)Returns turn delay for this item's attack.- Parameters:
meleeDistance
-true
if the entity is standing next to its attack target.- Returns:
- Turn delay for this items attack.
-
getDefaultAttackRate
public static int getDefaultAttackRate()Retrieves default attack rate for items. -
getDeterioration
public int getDeterioration()Each Item is subject to deterioration that weakens the item- Returns:
- the current degree of deterioration
-
deteriorate
public void deteriorate()Propose increase the degree of deterioration. If degree increases is decided by random -
deteriorate
Can be overridden to handle actions on user entity.- Parameters:
user
- Entity using the item.
-
repair
public void repair()repair this item -
isPersistent
public boolean isPersistent()Returns if the item is persistent. Persistent items do not update their stats from the item database and thus can have individual stats- Returns:
- true if item is persistent
-
setPersistent
public void setPersistent(boolean persistent)Set the item's persistence.- Parameters:
persistent
- If the item's stats are persistent.
-
isOfClass
Checks if the item is of type type .- Parameters:
clazz
- the class to check- Returns:
- true if the type matches, else false
-
getItemClass
- Returns:
- the type of the item
-
getItemSubclass
- Returns:
- the subclass of the item
-
getName
Gets the name of the item. -
getQuantity
public int getQuantity()Get item count.- Returns:
- 1.
-
getPossibleSlots
- Returns:
- the list of possible slots for this item
-
getBoundTo
Get the player this is bound to. A bound item can only be used by that player.- Returns:
- The player name, or
null
.
-
isBound
public boolean isBound()Check if the item is bound to a player- Returns:
true
if the item is bound, otherwisefalse
-
autobind
Bind the item to a player, if the item is one that should be automatically bound, and the item is not already bound.- Parameters:
player
- player name
-
getInfoString
Get the item's infoString. The infoString contains context specific information that is used by the implementation.- Returns:
- The infoString.
-
setBoundTo
Bind this item to a player. A bound item can only be used by that player.- Parameters:
name
- The player name, ornull
.
-
isUndroppableOnDeath
public boolean isUndroppableOnDeath()Is the item undroppable. On player death items carried may be dropped into the players corpse. unless this method returns true.- Returns:
- true if item may not be dropped on death of players.
-
setUndroppableOnDeath
public void setUndroppableOnDeath(boolean unDroppableOnDeath)Set is the item undroppable when player dies.- Parameters:
unDroppableOnDeath
- If true, the item won't be dropped if the player dies.
-
setUseBehavior
Set behavior to follow when the item is used.- Parameters:
behavior
- new behavior
-
setInfoString
Set the item's infostring. The infostring contains context specific information that is used by the implementation.- Parameters:
infostring
- The item's infostring.
-
getDamageType
Get the type of damage inflicted by this item.- Returns:
- type of damage
-
setDamageType
Set the type of damage inflicted by this item- Parameters:
type
- type of damage
-
getSusceptibility
Get this item's contribution to susceptibility to a type of damage.- Parameters:
type
- type of damage to be checked- Returns:
- susceptibility to damage of type
type
-
setSusceptibilities
Set the susceptibility data of this item.- Parameters:
susceptibilities
- susceptibilities to be used
-
initializeActiveSlotsList
Override in SlotActivatedItem sub-class. -
initializeStatusResistancesList
Override in StatusResistantItem sub-class. -
getWeaponType
Get a weapon type identifier that can be used in attack events, so that the client can draw an appropriate item image for the attack.- Returns:
- weapon identifier
-
toString
Description copied from class:RPObject
This method returns a String that represent the object -
onPutOnGround
Is called when the item is moved to the ground.- Parameters:
player
- the player who drops the Item.
-
onPutOnGround
public void onPutOnGround(boolean expire)Is called when the item is created.- Parameters:
expire
- Set true if the item should expire normally, false otherwise.
-
onRemoveFromGround
public void onRemoveFromGround() -
onPickedUp
-
onTurnReached
public void onTurnReached(int currentTurn)Description copied from interface:TurnListener
This method is called when the turn number is reached.- Specified by:
onTurnReached
in interfaceTurnListener
- Parameters:
currentTurn
- current turn number
-
describe
Description copied from class:Entity
Describes the entity (if a players looks at it). -
removeOne
public void removeOne()Removes the item. In case of StackableItems only one is removed. -
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
-
removeFromWorld
public void removeFromWorld() -
getDescriptionName
Returns the name or something that can be used to identify the entity for the player.- Overrides:
getDescriptionName
in classEntity
- Parameters:
definite
-true
for "the", andfalse
for "a/an" in case the entity has no name.- Returns:
- The description name.
-
getTitle
Get the nicely formatted entity title/name. -
setFromCorpse
public void setFromCorpse(boolean fromCorpse) -
isFromCorpse
public boolean isFromCorpse() -
getMinLevel
public int getMinLevel()gets the min level- Returns:
- minLevel
-
onEquipped
opportunity to affect the player when equipped currently returns boolean, to indicate whether it made any change TODO: should this return some sort of undoable thing (if it can be undone?)- Parameters:
equipper
- entity equipping the itemslot
- slot where the item is equipped- Returns:
- unknown, see the note above
-
onUnequipped
public boolean onUnequipped()item is about to be removed from owner. at this time, we are still owned by the original owner. opportunity to affect the player when equipped note: use this.getContainerOwner(), rather than the equipper param TODO: i don't think the parameters are necessary. can get owner and slot from Item api- Returns:
- needs documenting
-
onUsed
Description copied from interface:UseListener
Invoked when the object is used.- Specified by:
onUsed
in interfaceUseListener
- Parameters:
user
- the RPEntity who uses the object- Returns:
- true if successful
-