us.asciiroth.client.core
Class PlayerBag

java.lang.Object
  extended by us.asciiroth.client.core.Bag<Item>
      extended by us.asciiroth.client.core.PlayerBag

public class PlayerBag
extends Bag<Item>

A bag that tracks the player's inventory. What makes the inventory unique, as bags go, is that one item in the bag is selected, and there is an item called "empty-handed" that simulates the player using nothing at all in the bag.


Nested Class Summary
 
Nested classes/interfaces inherited from class us.asciiroth.client.core.Bag
Bag.Entry<T extends Piece>
 
Field Summary
static EmptyHanded EMPTY_HANDED
          An item that represents "no item".
 
Constructor Summary
PlayerBag()
          Constructor.
 
Method Summary
 void add(Item item)
          Add one count of an item to the bag.
 Item exchange(Item item)
          Add one instance of the supplied item and remove one instance of the currently selected item.
 Item getByName(java.lang.String name)
          Find an item by its name, the name displayed to the user.
 Item getSelected()
          Get the currently selected item (the item that is being "wielded" and is assumed to be in use when the player moves toward something that will respond to an item).
 boolean isSelected(Bag.Entry<Item> entry)
          Is this entry selected
 void moveSelectedDown()
           
 void moveSelectedUp()
           
 void remove(Item item)
          Remove one count of an item from the bag.
 void select(int index)
           
 void selectDown()
          Select the next lowest item in the bag (wraps around to the end of the list.
 void selectEmptyHanded()
          Select the empty handed item in the bag.
 void selectFirstWeapon()
           
 void selectUp()
          Select the next highest item in the bag (wraps around to the end of the list.
 void setInitialSelection(int newIndex)
          When initializing the player, this quietly sets the item that is selected.
 
Methods inherited from class us.asciiroth.client.core.Bag
add, asEntryList, contains, findEntry, get, getCount, getIndex, isEmpty, last, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_HANDED

public static final EmptyHanded EMPTY_HANDED
An item that represents "no item".

Constructor Detail

PlayerBag

public PlayerBag()
Constructor.

Method Detail

add

public void add(Item item)
Description copied from class: Bag
Add one count of an item to the bag.

Overrides:
add in class Bag<Item>

exchange

public Item exchange(Item item)
Add one instance of the supplied item and remove one instance of the currently selected item. Simulates an exchange.

Parameters:
item - the item the player receives
Returns:
the item the player is giving up in return

getByName

public Item getByName(java.lang.String name)
Find an item by its name, the name displayed to the user.

Parameters:
name - the name of the item as displayed to the user
Returns:
the item if it is in inventory, null otherwise

getSelected

public Item getSelected()
Get the currently selected item (the item that is being "wielded" and is assumed to be in use when the player moves toward something that will respond to an item).

Returns:
the currently selected item.

isSelected

public boolean isSelected(Bag.Entry<Item> entry)
Is this entry selected

Parameters:
entry -
Returns:
true if this entry is selected, false otherwise

moveSelectedDown

public void moveSelectedDown()

moveSelectedUp

public void moveSelectedUp()

remove

public void remove(Item item)
Description copied from class: Bag
Remove one count of an item from the bag.

Overrides:
remove in class Bag<Item>

select

public void select(int index)

selectDown

public void selectDown()
Select the next lowest item in the bag (wraps around to the end of the list.


selectEmptyHanded

public void selectEmptyHanded()
Select the empty handed item in the bag.


selectFirstWeapon

public void selectFirstWeapon()

selectUp

public void selectUp()
Select the next highest item in the bag (wraps around to the end of the list.


setInitialSelection

public void setInitialSelection(int newIndex)
When initializing the player, this quietly sets the item that is selected.

Parameters:
newIndex -

0.7

© 2009 Alx Dark