org.starhope.appius.game.inventory
Class ItemEffects

java.lang.Object
  extended by org.starhope.appius.game.inventory.ItemEffects
Direct Known Subclasses:
Shovel, SimpleAbstractWeapon, SimpleArmour

public class ItemEffects
extends Object

This is the base class from which all item effects must be derived. It provides neutral “no-op” handlers for all mandatory hooks and fires script events through Quaestor.

Author:
brpocock@star-hope.org

Field Summary
protected  InventoryItem item
          The inventory item from which these effects are emitted
 
Constructor Summary
ItemEffects(InventoryItem theItem)
           
 
Method Summary
 int alter(UserStat stat)
          Get the amount by which the item which bears this effect alters the supplied stat
 boolean canSwim()
           
 boolean conflicts(GenericItemReference itemClass, InventoryItem anItem)
           For the item which bears this effect, determine whether another item conflicts with it.
 boolean considerAsVehicle()
           
static ItemEffects forItem(InventoryItem item)
          Get the ItemEffects subclass responsible for handling effects from a given item type
 DamageTypeRanks getDefenseGeometric()
           
 DamageTypeRanks getDefenseLinear()
           
 InventoryItem getItem()
           
 boolean isFloatingVehicle()
           
 boolean isMountedAnimal()
           
 boolean isWheeledVehicle()
           
protected  void notifyEquipment()
          Sent equipment notification to the owner: something has changed
 void onDeEquip()
          Called whenever the item is de-equipped
 void onEquip()
          Called whenever the item is equipped
 void takeDamage(DamageTypeRanks attacks)
          WRITEME: Document this method brpocock@star-hope.org
 void use(String targetName, Coord3D targetCoords)
          The item is being used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

item

protected final InventoryItem item
The inventory item from which these effects are emitted

Constructor Detail

ItemEffects

public ItemEffects(InventoryItem theItem)
Parameters:
theItem - the item from which these effects are emitted
Method Detail

forItem

public static ItemEffects forItem(InventoryItem item)
                           throws NotFoundException
Get the ItemEffects subclass responsible for handling effects from a given item type

Parameters:
item - the item for which to get the effects-handler object
Returns:
the ItemEffects subclass responsible for that item ID
Throws:
NotFoundException - if the item doesn't exist, doesn't define an effects type, or the effects type handler class can't be found or instantiated

alter

public int alter(UserStat stat)
Get the amount by which the item which bears this effect alters the supplied stat

Parameters:
stat - the user stat to be altered
Returns:
the amount by which equipping this item alters the user's stats

canSwim

public boolean canSwim()
Returns:
true, if this item somehow grants the bearer the ability to swim (which can still be subject to e.g. skill checks, later)

conflicts

public boolean conflicts(GenericItemReference itemClass,
                         InventoryItem anItem)

For the item which bears this effect, determine whether another item conflicts with it.

Since this comparison is done against all equipped items, the GenericItemReference is provided simply as a convenience. This method must be called with the correct GenericItemReference that would be returned by calling InventoryItem.getGenericItem(), simply to save on calling that routine many times during the comparison of all items.

Parameters:
itemClass - the GenericItemReference of this the item is an instance
anItem - the InventoryItem against which this item is being considered
Returns:
true, if this item conflicts with the other (they cannot be equipped together)

considerAsVehicle

public boolean considerAsVehicle()
Returns:
true, if this item is to be considered a vehicle

getDefenseGeometric

public DamageTypeRanks getDefenseGeometric()
Returns:
defense factors to be multiplied by the bearer's innate base defenses

getDefenseLinear

public DamageTypeRanks getDefenseLinear()
Returns:
defense values to be added to the bearer's innate base defenses

getItem

public InventoryItem getItem()
Returns:
the item

isFloatingVehicle

public boolean isFloatingVehicle()
Returns:
true, if this is a vehicle that floats above the ground in some way

isMountedAnimal

public boolean isMountedAnimal()
Returns:
true, if this is an animal mount (or similar, e.g. steam-powered horse)

isWheeledVehicle

public boolean isWheeledVehicle()
Returns:
true, if this is a wheeled vehicle (or similar, e.g. skis)

notifyEquipment

protected void notifyEquipment()
Sent equipment notification to the owner: something has changed


onDeEquip

public void onDeEquip()
Called whenever the item is de-equipped


onEquip

public void onEquip()
Called whenever the item is equipped


takeDamage

public void takeDamage(DamageTypeRanks attacks)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
attacks - WRITEME

use

public void use(String targetName,
                Coord3D targetCoords)
The item is being used. The optional target name and/or target coördinates may be provided.

Parameters:
targetName - a named object in the room against which the item is to be used
targetCoords - the coördinates in the room against which the item is to be used.