javoids
Class Item

java.lang.Object
  extended by javoids.Item
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Weapon

public class Item
extends java.lang.Object
implements java.io.Serializable

A class to represent an item in the game (weapon, or other usable tool)

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
static class Item.Direction
          An enumeration of directions that you can travel along the weapon list (left, right or choose best).
static class Item.Type
          The type of item.
 
Field Summary
private  int count
          the number of uses left
private  int defaultCount
          the default number of uses
private  ImageMap.Name defaultImage
          the default image to use for drawing
private  ImageMap.Name image
          the current image to use for drawing
private  boolean limitless
          is the item limitless?
private  int maximumCount
          the maximum number of uses
private  java.lang.String name
          the text version of the item name
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
private  int size
          the size of the item (for drawing)
private  SoundMap.Sound sound
          the sound to play when used
private  Item.Type type
          the type of item (the item name)
 
Constructor Summary
Item()
          Constructor (default)
Item(Item item)
          Constructor (copy)
 
Method Summary
static Item.Type cycleWeapon(java.util.HashMap<Item.Type,Item> items, Item.Type currentItem, Item.Direction direction)
          Determine what weapon to select next.
 int getCount()
           
 int getDefaultCount()
           
 ImageMap.Name getDefaultImage()
           
 ImageMap.Name getImage()
           
 int getMaximumCount()
           
 java.lang.String getName()
           
 int getSize()
           
 SoundMap.Sound getSound()
           
 Item.Type getType()
           
 boolean isLimitless()
           
 boolean isWeapon()
           
static boolean isWeapon(Item.Type item)
           
 void modifyCount(int _count)
           
 void reset()
          reset the item's information to non-immortal and a default count
 void setCount(int _count)
           
 void setDefaultCount(int _defaultCount)
           
 void setDefaultImage(ImageMap.Name _defaultImage)
           
 void setImage(ImageMap.Name _image)
           
 Item.Type setItem(Item.Type item)
           
 void setLimitless(boolean _immortal)
           
 void setMaximumCount(int _maximumCount)
           
 void setName(java.lang.String _name)
           
 void setSize(int _size)
           
 void setSound(SoundMap.Sound _sound)
           
 void setType(Item.Type _type)
           
static Item.Type setWeapon(Item.Type item)
           
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

type

private Item.Type type
the type of item (the item name)


name

private java.lang.String name
the text version of the item name


limitless

private boolean limitless
is the item limitless?


defaultImage

private ImageMap.Name defaultImage
the default image to use for drawing


image

private ImageMap.Name image
the current image to use for drawing


sound

private SoundMap.Sound sound
the sound to play when used


maximumCount

private int maximumCount
the maximum number of uses


count

private int count
the number of uses left


defaultCount

private int defaultCount
the default number of uses


size

private int size
the size of the item (for drawing)

Constructor Detail

Item

public Item()
Constructor (default)


Item

public Item(Item item)
Constructor (copy)

Parameters:
item - the item to copy
Method Detail

getName

public java.lang.String getName()
Returns:
the text representation of the item name

getType

public Item.Type getType()
Returns:
the item type

isLimitless

public boolean isLimitless()
Returns:
is the item limitless?

getImage

public ImageMap.Name getImage()
Returns:
the current item the item is using

getDefaultImage

public ImageMap.Name getDefaultImage()
Returns:
the default image this item uses

getSound

public SoundMap.Sound getSound()
Returns:
the sound that this item makes when used

getCount

public int getCount()
Returns:
the current number of uses left for this item

getDefaultCount

public int getDefaultCount()
Returns:
the default number of uses for this item

getMaximumCount

public int getMaximumCount()
Returns:
the maximum number of uses for this item

getSize

public int getSize()
Returns:
the size of the image used to represent this item

setName

public void setName(java.lang.String _name)
Parameters:
_name - set the item name to this

setType

public void setType(Item.Type _type)
Parameters:
_type - set the type of the item

setLimitless

public void setLimitless(boolean _immortal)
Parameters:
_immortal - set the immortality of this item (true/false)

setImage

public void setImage(ImageMap.Name _image)
Parameters:
_image - set the current image this item is using

setDefaultImage

public void setDefaultImage(ImageMap.Name _defaultImage)
Parameters:
_defaultImage - set the default image this item uses

setSound

public void setSound(SoundMap.Sound _sound)
Parameters:
_sound - set the sound this item makes

setCount

public void setCount(int _count)
Parameters:
_count - set the current number of uses left to this value

setDefaultCount

public void setDefaultCount(int _defaultCount)
Parameters:
_defaultCount - set the default number of uses to this value

setMaximumCount

public void setMaximumCount(int _maximumCount)
Parameters:
_maximumCount - set the maximum number of uses to this value

setSize

public void setSize(int _size)
Parameters:
_size - set the size of the image to represent this item

modifyCount

public void modifyCount(int _count)
Parameters:
_count - modify the number of uses by this amount (if not immortal)

reset

public void reset()
reset the item's information to non-immortal and a default count


isWeapon

public boolean isWeapon()
Returns:
true if the current item is a weapon

isWeapon

public static boolean isWeapon(Item.Type item)
Parameters:
item - the item to test for weapon status
Returns:
whether the item is a weapon or not

cycleWeapon

public static Item.Type cycleWeapon(java.util.HashMap<Item.Type,Item> items,
                                    Item.Type currentItem,
                                    Item.Direction direction)
Determine what weapon to select next.

Parameters:
items - a mapping of item types to items
currentItem - the currently selected item
direction - the direction to go through the list (left or right)
Returns:
the newly selected item

setWeapon

public static Item.Type setWeapon(Item.Type item)
Parameters:
item - the weapon item type to set
Returns:
the item set, or NO_ITEM if it is anything other than a weapon item.

setItem

public Item.Type setItem(Item.Type item)
Parameters:
item - the non-weapon item type to set
Returns:
the item set, or NO_ITEM if it is anything other than a non-weapon item.

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
String A representation of the object for debugging.