org.starhope.appius.game.inventory
Class ItemManager

java.lang.Object
  extended by org.starhope.appius.game.inventory.ItemManager

public class ItemManager
extends Object

The ItemManager handles side-effects of equipping and removing items for an user.

There are two main purposes to the inventory management performed in this class:

The effects of items can be bridged through scripted event handlers, which might be specific to a given generic item type, which is typically the effect of an ACTIVE item. ACTIVE effect items will respond to a given user interface demand (e.g. “press the (A) button” or “click on a target”) specific to their equipment type. For example, a player might have melée weapons and ranged weapons which respond to their (A) and (B) buttons. The equipment reaction slots for those items are simply (A) and (B). The items which respond, however, might actually mount in various equipment slots. A ranged weapon might be in the “Hat” slot, and the player might have a melée weapon in each of the “LeftHand” and “RightHand” slots. In this case, the action handling for the items will have to run together, presuming that there is no conflict in mounting them.

PASSIVE items will typically have ongoing status effects, but may also register scripted event hooks. For example, magic shoes might simultaneously grant the player access to the verb “Skipping,” as a basic movement action, but they also might increase the player's “Karma” statistic at the same time.

Author:
brpocock@star-hope.org

Field Summary
private  AvatarClass avatar
          WRITEME: Document this brpocock@star-hope.org
private  Inventory inv
          WRITEME: Document this brpocock@star-hope.org
private  AbstractUser owner
          WRITEME: Document this brpocock@star-hope.org
 
Constructor Summary
ItemManager(AvatarClass avatarClass, Inventory inventory)
          WRITEME: Document this constructor brpocock@star-hope.org
 
Method Summary
private  void addEffects(InventoryItem item)
          WRITEME: Document this method brpocock@star-hope.org
static ItemManager get(AbstractUser u)
          WRITEME: Document this method brpocock@star-hope.org
static ItemManager get(AvatarClass avatarClass, Inventory inventory)
          WRITEME: Document this method brpocock@star-hope.org
 AvatarClass getAvatarClass()
           
 Collection<InventoryItem> getConflicts(InventoryItem item)
          WRITEME: Document this method brpocock@star-hope.org
 Inventory getInventory()
           
private  Collection<InventoryItem> getItemConflicts(InventoryItem item)
          WRITEME: Document this method brpocock@star-hope.org
 AbstractUser getOwner()
           
private  Collection<InventoryItem> getSlotConflicts(InventoryItem item)
          WRITEME: Document this method brpocock@star-hope.org
 boolean noteDeEquip(InventoryItem item)
          Acknowledge that an item has been de-equipped, and its status effects should be removed, and also remove any items that require this one to be equipped.
 boolean noteEquip(InventoryItem item)
          Acknowledge that an item has been equipped, and its status effects should be applied, and conflicting items removed.
 void useEquipment(char slot, String targetName, Coord3D targetCoords)
          WRITEME: Document this method brpocock@star-hope.org
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

avatar

private final AvatarClass avatar
WRITEME: Document this brpocock@star-hope.org


inv

private final Inventory inv
WRITEME: Document this brpocock@star-hope.org


owner

private final AbstractUser owner
WRITEME: Document this brpocock@star-hope.org

Constructor Detail

ItemManager

public ItemManager(AvatarClass avatarClass,
                   Inventory inventory)
WRITEME: Document this constructor brpocock@star-hope.org

Parameters:
avatarClass - WRITEME
inventory - WRITEME
Method Detail

get

public static ItemManager get(AbstractUser u)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
u - WRITEME
Returns:
WRITEME

get

public static ItemManager get(AvatarClass avatarClass,
                              Inventory inventory)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
avatarClass - WRITEME
inventory - WRITEME
Returns:
WRITEME

addEffects

private void addEffects(InventoryItem item)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
item - WRITEME

getAvatarClass

public AvatarClass getAvatarClass()
Returns:
the avatar

getConflicts

public Collection<InventoryItem> getConflicts(InventoryItem item)
                                       throws AlreadyUsedException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
item - WRITEME
Returns:
WRITEME
Throws:
AlreadyUsedException - if conflicts can't be determined because the item couldn't be equipped due to slot or valence restrictions

getInventory

public Inventory getInventory()
Returns:
the inventory

getItemConflicts

private Collection<InventoryItem> getItemConflicts(InventoryItem item)
                                            throws AlreadyUsedException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
item - WRITEME
Returns:
WRITEME
Throws:
AlreadyUsedException - if the item can't be equipped due to lack of a slot on the avatar for items of this type

getOwner

public AbstractUser getOwner()
Returns:
the owner

getSlotConflicts

private Collection<InventoryItem> getSlotConflicts(InventoryItem item)
                                            throws AlreadyUsedException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
item - WRITEME
Returns:
WRITEME
Throws:
AlreadyUsedException - if there is not a slot or valence free for this item at all

noteDeEquip

public boolean noteDeEquip(InventoryItem item)
Acknowledge that an item has been de-equipped, and its status effects should be removed, and also remove any items that require this one to be equipped. If this routine returns “false,” then it is impossible to resolve conflicts, and the item must not be de-equipped.

Parameters:
item - the item being de-equipped
Returns:
true, if the item can be de-equipped.

noteEquip

public boolean noteEquip(InventoryItem item)
Acknowledge that an item has been equipped, and its status effects should be applied, and conflicting items removed. If this routine returns “false,” then it is impossible to resolve conflicts, and the item must not be equipped.

Parameters:
item - the item being equipped
Returns:
true, if the item is permitted to be equipped.

useEquipment

public void useEquipment(char slot,
                         String targetName,
                         Coord3D targetCoords)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
slot - WRITEME
targetName - WRITEME
targetCoords - WRITEME