OGS Java API Spec

ogs.core
Class Item

java.lang.Object
  |
  +--ogs.support.Object
        |
        +--ogs.core.Entity
              |
              +--ogs.core.Item
All Implemented Interfaces:
EventListener
Direct Known Subclasses:
Armor, Weapon

public abstract class Item
extends Entity

An item is a entity that can be used by a creature. An item has various attributes that determine how much "health" it has and thus its current condition and how hard it is to destroy. The density of an item determines how many health points an item has per unit of thickness. Thus, density multiplied by thickness determines the maximum health of an item. Materials are used to specify a predefined density. Some common materials are provided by this class. An item made of wood for example has a density of 5. Finally, the hardness of an item determines how resistant to damage it is. When damage is applied to an item, the hardness is subtracted from the damage. Thus harder items take less damage. Note that the health of an item can be specified directly (through Entity operations) in spite of these attributes. These attributes should be used in cases where specific values for health have not been provided and approximate values are required. An item also has worth. Worth determines how valuable an item is usually expressed as a monetary value. Since worth is a relative concept; the units of worth are locale-dependent.


Field Summary
static int GLASS
          An item made of glass has a density of 1.
static int IRON
          An item made of iron has a density of 10.
static int PAPER
          An item made of paper has a density of 2.
static int STONE
          An item made of stone has a density of 8.
static int UNKNOWN
          Some unknown material.
static int WOOD
          An item made of wood has a density of 5.
 
Fields inherited from class ogs.core.Entity
currentHealth, defense, maximumHealth, size, weight
 
Fields inherited from class ogs.support.Object
listeners
 
Constructor Summary
Item()
           
 
Method Summary
 int getDensity()
           
 byte getHardness()
          Determine the hardness of this item.
 int getMaterial()
          Determine the material that this item is made of.
 double getThickness()
          Determine the thickness of this item.
 double getWorth()
          Determine the worth of this item.
 void setDensity(int density)
           
 void setHardness(byte hardness)
          Change the hardness of this item.
 void setMaterial(int material)
          Change the material that this item is made of.
 void setThickness(double thickness)
          Change the thickness of this item.
 void setWorth(double worth)
          Change the worth of this item.
protected  void updateHealthPoints()
          Update the maximum health points of this item using the current thickness and density.
 
Methods inherited from class ogs.core.Entity
getCurrentHealth, getDefense, getMaximumHealth, getSize, getWeight, setCurrentHealth, setMaximumHealth, setWeight
 
Methods inherited from class ogs.support.Object
addListener, handleEvent, notifyListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
Some unknown material. The density of an unknown material can be specified directly using the setDensity operation.

See Also:
Constant Field Values

PAPER

public static final int PAPER
An item made of paper has a density of 2.

See Also:
Constant Field Values

GLASS

public static final int GLASS
An item made of glass has a density of 1.

See Also:
Constant Field Values

WOOD

public static final int WOOD
An item made of wood has a density of 5.

See Also:
Constant Field Values

STONE

public static final int STONE
An item made of stone has a density of 8.

See Also:
Constant Field Values

IRON

public static final int IRON
An item made of iron has a density of 10.

See Also:
Constant Field Values
Constructor Detail

Item

public Item()
Method Detail

getMaterial

public int getMaterial()
Determine the material that this item is made of.

Returns:
Material that this item is made of.

setMaterial

public void setMaterial(int material)
Change the material that this item is made of.

Parameters:
material - Material that this item is made of.

getHardness

public byte getHardness()
Determine the hardness of this item.

Returns:
Hardness of this item.

setHardness

public void setHardness(byte hardness)
Change the hardness of this item.

Parameters:
hardness - Hardness of this item.

getThickness

public double getThickness()
Determine the thickness of this item.


setThickness

public void setThickness(double thickness)
Change the thickness of this item.


getDensity

public int getDensity()

setDensity

public void setDensity(int density)

getWorth

public double getWorth()
Determine the worth of this item. The units of worth are locale-dependent.

Returns:
Worth of this item.

setWorth

public void setWorth(double worth)
Change the worth of this item. THe units of worth are locale-dependent.

Parameters:
worth - Worth of this item.

updateHealthPoints

protected void updateHealthPoints()
Update the maximum health points of this item using the current thickness and density.


OGS Java API Spec