mdh.hephaestus2
Class Item

java.lang.Object
  |
  +--mdh.hephaestus2.Stuff
        |
        +--mdh.hephaestus2.Thing
              |
              +--mdh.hephaestus2.Statted
                    |
                    +--mdh.hephaestus2.Item
All Implemented Interfaces:
Serializable

public final class Item
extends Statted

Any portable Thing - usually used for equipment.

Author:
Copyright © 2001 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Constructor Summary
Item(String name)
          Creates a new item with the given name.
 
Method Summary
 Item copyItem()
          Makes an exact duplicate of this Item.
 String getDropCallback()
          Returns the callback called when this item is dropped.
 int getEquip()
          Returns the equipment position this item can be used in, or -1 for none.
 String getEquipCallback()
          Returns the callback called when this item is equipped.
 String getRemoveCallback()
          Returns the callback called when this item is removed (unequipped).
 String getTakeCallback()
          Returns the callback called when this item is taken.
 int getType()
          Returns the type constant for this object, one of Global.TYPE_*.
 boolean isGoldCoins()
          Returns true if the item has a name consisting of digits followed by " gold".
 boolean isType(int type)
          Returns true if this class or any of its superclasses is of 'type', one of Global.TYPE_*.
static Item makeGold(int gold)
          Creates a new stack of gold coins.
 void setDropCallback(String d)
           
 void setEquip(int e)
          Sets the equipment position this item can be used in, or -1 for none.
 void setEquipCallback(String e)
           
 void setRemoveCallback(String u)
           
 void setTakeCallback(String t)
           
 
Methods inherited from class mdh.hephaestus2.Statted
calcSecondary, getGold, getStat, getStatMax, setGold, setStat, setStatBoth, setStatMax
 
Methods inherited from class mdh.hephaestus2.Thing
findGrid, findMap, getIconFilename, getNPoses, getOpacity, getPose, getProps, getTile, initProps, loc, moveto, moveto, setFacing, setOpacity, setPose, setTile
 
Methods inherited from class mdh.hephaestus2.Stuff
destroy, getBlocking, getName, getTriggerCallback, id, setBlocking, setName, setTriggerCallback, toString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Item

public Item(String name)
     throws HephaestusException
Creates a new item with the given name. This gives the Stuff a new unique ID and adds it to the database.

Parameters:
name - Human-readable name to show in descriptions. Names do not have to be unique, but should be kept fairly short so they can fit in menus. Null names are not allowed.
Method Detail

makeGold

public static Item makeGold(int gold)
                     throws HephaestusException
Creates a new stack of gold coins.

HephaestusException

copyItem

public Item copyItem()
              throws HephaestusException
Makes an exact duplicate of this Item.

HephaestusException

getEquip

public int getEquip()
             throws HephaestusException
Returns the equipment position this item can be used in, or -1 for none.

HephaestusException
See Also:
Global.EQ_Weapon

getTakeCallback

public String getTakeCallback()
                       throws HephaestusException
Returns the callback called when this item is taken.

The take fails if this callback returns a false value, so normal items should return Boolean.TRUE.

HephaestusException

getDropCallback

public String getDropCallback()
                       throws HephaestusException
Returns the callback called when this item is dropped.

The drop fails if this callback returns a false value, so normal items should return Boolean.TRUE.

HephaestusException

getEquipCallback

public String getEquipCallback()
                        throws HephaestusException
Returns the callback called when this item is equipped.

The equip fails if this callback returns a false value, so normal items should return Boolean.TRUE.

HephaestusException

getRemoveCallback

public String getRemoveCallback()
                         throws HephaestusException
Returns the callback called when this item is removed (unequipped).

The remove fails if this callback returns a false value, so normal items should return Boolean.TRUE.

HephaestusException

getType

public int getType()
Description copied from class: Stuff
Returns the type constant for this object, one of Global.TYPE_*.

Specified by:
getType in class Stuff

isType

public boolean isType(int type)
Description copied from class: Stuff
Returns true if this class or any of its superclasses is of 'type', one of Global.TYPE_*.

Overrides:
isType in class Statted

isGoldCoins

public boolean isGoldCoins()
Returns true if the item has a name consisting of digits followed by " gold". If so, Player will automatically convert the item into cash on taking it.


setEquip

public void setEquip(int e)
              throws HephaestusException
Sets the equipment position this item can be used in, or -1 for none.

HephaestusException
See Also:
Global.EQ_Weapon

setTakeCallback

public void setTakeCallback(String t)
                     throws HephaestusException
HephaestusException
See Also:
getTakeCallback()

setDropCallback

public void setDropCallback(String d)
                     throws HephaestusException
HephaestusException
See Also:
getDropCallback()

setEquipCallback

public void setEquipCallback(String e)
                      throws HephaestusException
HephaestusException
See Also:
getEquipCallback()

setRemoveCallback

public void setRemoveCallback(String u)
                       throws HephaestusException
HephaestusException
See Also:
getRemoveCallback()