org.haphazard.item
Class GeneralItem

java.lang.Object
  extended byorg.haphazard.gui.engine.GraphicalObject
      extended byorg.haphazard.item.GeneralItem
Direct Known Subclasses:
GeneralClothes

public class GeneralItem
extends GraphicalObject

This class contains all general information about items


Field Summary
 int mAttackBonus
           
 int mDefenceBonus
           
protected  java.util.Vector mRestrictions
          The restrictions of this item
 java.lang.String mSkill
           
 
Fields inherited from class org.haphazard.gui.engine.GraphicalObject
id, mDefaultSprite, mDescription, mDescriptionColor, mDescriptionDisplayTime, mDescriptionStartTime, mDimension, mLink, mName, mSpriteDisplayed, mSprites, mWeight
 
Constructor Summary
GeneralItem()
          Creates a new item
GeneralItem(java.lang.String name)
          Creates a new item with a specific name
 
Method Summary
 void addContainerSpecialization(java.lang.String specialization)
          Adds an item specialization to this container.
 void addRestriction(java.lang.String restriction)
          Adds a restriction to this item
 boolean equals(java.lang.Object item)
          Checks if this item is equal to another item
 int getAttackBonus()
          Returns the attack bonus of the item
 Dimension3D getContainerDimension()
          Gets this items containing capacity
 java.util.Vector getContainerSpecializations()
          Gets all the specializations this item has
 int getContainerSpecializationSlots()
          Returns the number of items this container can hold
 int getDamageBonus()
          Gets the items damage bonus The damage bonus is dependant on the items weight and if it is solid and has edges
 int getDefenceBonus()
          Returns the defence bonus of the item
 java.util.Vector getRestrictions()
          Gets a vector with the restrictions for equipping this object.
 boolean hasEdges()
          Checks if the item has edges
 boolean hasEdges(boolean hasEdges)
          Sets if the item has edges
 boolean isContainer()
          Checks if this item is a container
 boolean isContainer(boolean isContainer)
          Sets if this item is a container or not
 boolean isSolid()
          Checks if the item is solid
 boolean isSolid(boolean isSolid)
          Sets if the item is solid
static GraphicalObject loadInstance(java.io.InputStream input)
          Loads an instance of GraphicalObject
 void setContainerDimension(Dimension3D dimension)
          Sets the dimension of the container
 void setContainerSpecializationSlots(int count)
          Sets the number of specialized items the container can hold
 void setDamageBonus(int bonus)
          Sets the weapons damage bonus
 java.lang.String toXML(int indent)
          Translates this item into an XML notation
 
Methods inherited from class org.haphazard.gui.engine.GraphicalObject
addSprite, combineSprites, displayDescription, displaySprite, getAvailableSprites, getBoundingBox, getDescription, getDimension, getName, getNotResettedSprite, getResettedSprite, getWeight, isDefaultSpriteDisplayed, load, optimize, paintComponent, resetDisplayedSprite, save, setDefaultSprite, setDefaultSprite, setDescription, setDimension, setName, setWeight, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mSkill

public java.lang.String mSkill

mAttackBonus

public int mAttackBonus

mDefenceBonus

public int mDefenceBonus

mRestrictions

protected java.util.Vector mRestrictions
The restrictions of this item

Constructor Detail

GeneralItem

public GeneralItem()
Creates a new item


GeneralItem

public GeneralItem(java.lang.String name)
Creates a new item with a specific name

Parameters:
name - The name to gice the item
Method Detail

hasEdges

public boolean hasEdges(boolean hasEdges)
Sets if the item has edges

Parameters:
hasEdges - true if the item has edges
Returns:
The old value of the property

hasEdges

public boolean hasEdges()
Checks if the item has edges

Returns:
True if the item has edges

isSolid

public boolean isSolid(boolean isSolid)
Sets if the item is solid

Parameters:
isSolid - True if the item should be solid
Returns:
The old value of the property

isSolid

public boolean isSolid()
Checks if the item is solid

Returns:
True if the item is solid

getRestrictions

public java.util.Vector getRestrictions()
Gets a vector with the restrictions for equipping this object. The restrictions are strings on the form "restriction param1 ... params". For example, the restriction "bodypart Arm" restricts the usage of the object to characters who have an arm.

Returns:
A Vector of Strings (Restrictions), null if no restrictions

addRestriction

public void addRestriction(java.lang.String restriction)
Adds a restriction to this item

Parameters:
restriction - The restriction to add
See Also:
getRestrictions()

getDamageBonus

public int getDamageBonus()
Gets the items damage bonus The damage bonus is dependant on the items weight and if it is solid and has edges

Returns:
A bonus value for the attack

setDamageBonus

public void setDamageBonus(int bonus)
Sets the weapons damage bonus

Parameters:
bonus - The bonus to set

getAttackBonus

public int getAttackBonus()
Returns the attack bonus of the item

Returns:
The attack bonus (0)

getDefenceBonus

public int getDefenceBonus()
Returns the defence bonus of the item

Returns:
The defence bonus (0)

setContainerDimension

public void setContainerDimension(Dimension3D dimension)
Sets the dimension of the container

Parameters:
dimension - The dimension to set

getContainerDimension

public Dimension3D getContainerDimension()
Gets this items containing capacity

Returns:
The containing capacity of this item

addContainerSpecialization

public void addContainerSpecialization(java.lang.String specialization)
Adds an item specialization to this container. By specifying a certain type of item (i.e. "Long Sword") the container can hold Long Swords regardless of it's dimension. The containers specialized slots and the inner dimensions is not dependant on each other

Parameters:
specialization - The type of item to specialize in

getContainerSpecializations

public java.util.Vector getContainerSpecializations()
Gets all the specializations this item has

Returns:
A vector of String with the names of all the items this item can hold.

setContainerSpecializationSlots

public void setContainerSpecializationSlots(int count)
Sets the number of specialized items the container can hold

Parameters:
count - The number of specialized items the container can hold

getContainerSpecializationSlots

public int getContainerSpecializationSlots()
Returns the number of items this container can hold

Returns:
The number of specialized items this container can hold

isContainer

public boolean isContainer(boolean isContainer)
Sets if this item is a container or not

Parameters:
isContainer - True if this item should be a container
Returns:
The old value of the property

isContainer

public boolean isContainer()
Checks if this item is a container

Returns:
True if the item is a container.

loadInstance

public static GraphicalObject loadInstance(java.io.InputStream input)
Loads an instance of GraphicalObject

Parameters:
input - The input for the stream
Returns:
The loaded graphical object

equals

public boolean equals(java.lang.Object item)
Checks if this item is equal to another item

Parameters:
item - The item to check against
Returns:
True if they are equal

toXML

public java.lang.String toXML(int indent)
Translates this item into an XML notation

Overrides:
toXML in class GraphicalObject
Parameters:
indent - The indentation level
Returns:
The item in XML syntax