org.globalse.arena.sword.engine
Class ConsumableItem

java.lang.Object
  |
  +--org.globalse.arena.frag.objects.FRAGObject
        |
        +--org.globalse.arena.sword.engine.Item
              |
              +--org.globalse.arena.sword.engine.ConsumableItem

public class ConsumableItem
extends Item

A ConsumableItem is an Item that can change the properties of the Adventurer once "consumed" (like health, strength, etc). The ConsumableItem itself is consumed (destroyed) as a result of using it. It could be a loaf of bread, piece of meat, an apple...

See Also:
FRAGObject, Sword, Serialized Form

Fields inherited from class org.globalse.arena.sword.engine.Item
weight
 
Fields inherited from class org.globalse.arena.frag.objects.FRAGObject
controller, gameName, influenceRange, objectName, owner, position, visibilityRange
 
Constructor Summary
ConsumableItem()
           
 
Method Summary
 void actionEvent(ObjectActionEvent event)
          Processes the ObjectActionEvents that the ObjectManager receives for this object.
 double getCollisionSphere()
          Returns the collisionSphere Attribute for this consumableItem
 double getHealthBonus()
          Returns the amount of health an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getHealthMaxBonus()
          Returns the amount of healthMax (upper limit for health) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getInventoryMaxBonus()
          Returns the amount of inventoryMaxBonus (upper limit for the inventory) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getMagicPowerBonus()
          Returns the amount of magic power an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getManaBonus()
          Returns the amount of mana an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getManaMaxBonus()
          Returns the amount of manaMax (upper limit for mana) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 double getStrengthBonus()
          Returns the amount of strength an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
 void init(java.lang.String gameName, java.lang.String objectName, double weight, java.lang.String type, double healthBonus, double healthMaxBonus, double manaBonus, double manaMaxBonus, double magicPowerBonus, double inventoryMaxBonus, double strengthBonus)
          Initializes a ConsumableItem with the given properties (see below).
 void init(java.lang.String gameName, java.lang.String objectName, java.lang.String type)
          Creates new consumable item and initializes it with the default properties.
 boolean isItemUsableBy(java.lang.String owner)
          Checks if this item is currently used by someone
 boolean useWith(java.lang.String target)
          Called when this ConsumableItem is to be used.
 
Methods inherited from class org.globalse.arena.sword.engine.Item
checkCollision, draw, getDescription, getDimensions, getImage, getObjectName, getType, getVisible, init, setVisible
 
Methods inherited from class org.globalse.arena.frag.objects.FRAGObject
checkAndResetMark, checkMark, clone, controlAcquired, controlLost, getGameManager, getInfluenceRange, getObjectManager, getPosition, killed, mark, newerVersion, setInfluenceRange, setPosition
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsumableItem

public ConsumableItem()
Method Detail

init

public void init(java.lang.String gameName,
                 java.lang.String objectName,
                 java.lang.String type)
Creates new consumable item and initializes it with the default properties.
Parameters:
type - a String that denotes the kind of item (bread, meat, ...)

init

public void init(java.lang.String gameName,
                 java.lang.String objectName,
                 double weight,
                 java.lang.String type,
                 double healthBonus,
                 double healthMaxBonus,
                 double manaBonus,
                 double manaMaxBonus,
                 double magicPowerBonus,
                 double inventoryMaxBonus,
                 double strengthBonus)
Initializes a ConsumableItem with the given properties (see below).
Parameters:
weight - the weight (in kg) of the item
type - a String that denotes the kind of item (bread, meat, ...)
healthBonus - the health bonus of the item
healthMaxBonus - the healthMax bonus of the item
manaBonus - the mana bonus of the item
manaMaxBonus - the manaMax bonus of the item
magicPowerBonus - the magicPower bonus of the item
inventoryMaxBonus - the inventoryMax bonus of the item
strengthBonus - the strength bonus of the item

getHealthBonus

public double getHealthBonus()
Returns the amount of health an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the healthBonus of the ConsumableItem

getHealthMaxBonus

public double getHealthMaxBonus()
Returns the amount of healthMax (upper limit for health) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the healthMaxBonus of the ConsumableItem

getManaBonus

public double getManaBonus()
Returns the amount of mana an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the manaBonus of the ConsumableItem

getManaMaxBonus

public double getManaMaxBonus()
Returns the amount of manaMax (upper limit for mana) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the manaMax of the ConsumableItem

getMagicPowerBonus

public double getMagicPowerBonus()
Returns the amount of magic power an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the healthBonus of the ConsumableItem

getInventoryMaxBonus

public double getInventoryMaxBonus()
Returns the amount of inventoryMaxBonus (upper limit for the inventory) an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the inventoryMaxBonus of the ConsumableItem

getStrengthBonus

public double getStrengthBonus()
Returns the amount of strength an Adventurer gains (loses if the return value is negative) when consuming (using) the item.
Returns:
the strengthBonus of the ConsumableItem

useWith

public boolean useWith(java.lang.String target)
Called when this ConsumableItem is to be used. It updates thereafter the state of the target (usually an Adventurer)
Parameters:
target - the target, "consuming" this consumable item (the Adventurer)
Returns:
true if this ConsumableItem was successfully consumed by the target, else false
Overrides:
useWith in class Item

actionEvent

public void actionEvent(ObjectActionEvent event)
Processes the ObjectActionEvents that the ObjectManager receives for this object.
Parameters:
event - the event, that took place
Overrides:
actionEvent in class Item
See Also:
ObjectActionEvent

isItemUsableBy

public boolean isItemUsableBy(java.lang.String owner)
Checks if this item is currently used by someone
Parameters:
owner - the "suspected" user of the item
Returns:
true if this item is used by someone, else false
Overrides:
isItemUsableBy in class Item

getCollisionSphere

public double getCollisionSphere()
Returns the collisionSphere Attribute for this consumableItem
Returns:
collisionSphere the collisionSphere of this object
Overrides:
getCollisionSphere in class Item



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)