wyvern.lib
Interface Inventory

All Superinterfaces:
Bag, Broadcaster, Container, GameObject, MethodHookable, PropertyList
All Known Implementing Classes:
MonsterInventory

public interface Inventory
extends Bag

Holds items being carried by a Monster or Player.

Version:
1.0, Sep 02, 1997
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.lib.Bag
Bag.FullBagException, Bag.InvalidItemException
 
Field Summary
 
Fields inherited from interface wyvern.lib.Bag
BAG_CUT_PERCENT_CAP, BAG_DEFAULT_CAPACITY
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Method Summary
 void computeEncumbrance()
          Computes the encumbrance level of the monster associated with this inventory.
 GameObject findByHashcode(int hashcode)
          Returns an object in the inventory matching the passed hashcode.
 GameObject findByHashcode(java.lang.String hashcode)
          Returns an object in the inventory matching the passed hashcode.
 GameObject getByIndex(java.lang.String num)
          Returns an item specified as a string index "#number"
 Command getCommand(CommandEvent event, Commandable agent)
          Iterates over the objects in the inventory, looking for an object implementing the Command interface that claims to know the command.
 Commandable getOwner()
          Returns the Commandable (usually a Monster or Player) who owns this inventory.
 GameObject[] objects()
          Returns an array containing the objects of the inventory, in the order in which they occur in the inventory.
 void resend(int index)
          Tells the inventory that an item's appearance has changed, so it needs to be re-sent to the client.
 void resendAll()
          Resends the entire inventory display.
 void setOwner(Commandable owner)
          Sets the owner for this inventory.
 
Methods inherited from interface wyvern.lib.Bag
add, adjust, canHoldMore, contains, filter, find, findByName, getCapacity, getItemWeight, getMaxCount, getPosition, getRemainingCapacity, hasRoomFor, hasRoomFor, indexOf, insert, invalidate, isEmpty, iterator, objectAt, printItemList, remove, remove, removeAll, removeAll, removeFirst, removeFirst, setCapacity, setCapacity, setObjectAt, size, visitObjects
 
Methods inherited from interface wyvern.lib.GameObject
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, externalize, getAlpha, getAppearance, getArchetype, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, getValue, getWeight, inContainer, initialize, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport
 
Methods inherited from interface wyvern.lib.PropertyList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from interface wyvern.lib.MethodHookable
addMethodHook, removeMethodHook, runMethodHook
 
Methods inherited from interface wyvern.lib.Broadcaster
broadcast, broadcast, broadcast, broadcast, broadcast
 
Methods inherited from interface wyvern.lib.Container
isBag, isInventory, isMap
 

Method Detail

resend

public void resend(int index)
Tells the inventory that an item's appearance has changed, so it needs to be re-sent to the client.

Parameters:
index - the index of the item to resend.

resendAll

public void resendAll()
Resends the entire inventory display.


objects

public GameObject[] objects()
Returns an array containing the objects of the inventory, in the order in which they occur in the inventory.

Returns:
an array copied from the inventory objects

getOwner

public Commandable getOwner()
Returns the Commandable (usually a Monster or Player) who owns this inventory.

Returns:
the Commandable owner. Could potentially be null, if the inventory is a standalone inventory used for some special game purpose, so be sure to check the return value to make sure it's non-null.

setOwner

public void setOwner(Commandable owner)
Sets the owner for this inventory. Usually only called by the Monster or Player creating the inventory on initialization.

Parameters:
owner - the new owner for the inventory.

getCommand

public Command getCommand(CommandEvent event,
                          Commandable agent)
Iterates over the objects in the inventory, looking for an object implementing the Command interface that claims to know the command. Returns the first object that says it knows the command.

Parameters:
event - the event to look for a handler for
agent - the agent doing the command
Returns:
a Command to handle the command, or null if no Command was registered for that command where the agent is at.

findByHashcode

public GameObject findByHashcode(java.lang.String hashcode)
Returns an object in the inventory matching the passed hashcode. Used to target specific objects (e.g. using mouse actions) when more than one object might have the same description.

Parameters:
hashcode - the hashcode for the object (as a string)
Returns:
the matching object, or null if not found

findByHashcode

public GameObject findByHashcode(int hashcode)
Returns an object in the inventory matching the passed hashcode. Used to target specific objects (e.g. using mouse actions) when more than one object might have the same description.

Parameters:
hashcode - the hashcode for the object
Returns:
the matching object, or null if not found

getByIndex

public GameObject getByIndex(java.lang.String num)
Returns an item specified as a string index "#number"

Parameters:
num - the input string, e.g. "#3".
Returns:
the object at that index, or null if the index is out of bounds

computeEncumbrance

public void computeEncumbrance()
Computes the encumbrance level of the monster associated with this inventory. Whenever something is added or removed, the monster's encumbrance is recalculated (which in turn affects the monster's move-speed). If you change the monster's strength on the fly, you should call the inventory's setCapacity() method, which will call this to recompute the encumbrance level.