|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PList wyvern.kernel.maps.MapObject wyvern.lib.classes.BasicBag wyvern.kernel.monsters.MonsterInventory wyvern.kernel.player.PlayerInventory
A basic implementation of the Inventory interface. It handles updating the client when its contents change. Currently it's only capable of updating a single client; it would be impossible for a Wiz client to have a "spy" view of a client's inventory. We should fix this.
Nested Class Summary |
Nested classes inherited from class wyvern.lib.Bag |
Bag.FullBagException, Bag.InvalidItemException |
Field Summary | |
protected RemoteInventory |
client_
|
protected long |
lastWallet_
|
static int |
MAX_ITEMS
We don't allow players to carry more than this many items in their top-level inventory, because it has performance issues. |
Fields inherited from class wyvern.kernel.monsters.MonsterInventory |
owner_ |
Fields inherited from class wyvern.kernel.maps.MapObject |
IN_MAP_EDITOR, listenerList_ |
Fields inherited from class wyvern.kernel.properties.PList |
readOnly_ |
Fields inherited from interface wyvern.lib.Bag |
BAG_CUT_PERCENT_CAP, BAG_DEFAULT_CAPACITY |
Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
Constructor Summary | |
PlayerInventory()
|
|
PlayerInventory(RemoteInventory client,
Player p)
|
Method Summary | |
GameObject |
add(GameObject obj)
Adds an item to the bag (at the end). |
void |
adjust(GameObject obj,
int index)
Adjusts the position of an item in the list without removing it and adding it (thereby skipping the encumbrance and other checks). |
boolean |
canHoldMore()
Returns true if we're not at our max count for this bag. |
protected void |
checkWeight(GameObject item)
Wiz inventories have no weight restrictions. |
void |
computeEncumbrance()
Computes the encumbrance level of the monster associated with this inventory. |
java.lang.Object |
createClone()
|
long |
getCapacity()
Returns the carrying capacity of this inventory. |
java.lang.String |
getCommands(GameObject obj)
Returns a string containing the commands valid for this object, for displaying in a popup menu on the client when click on the object in inventory. |
int |
getMaxCount()
Returns the maximum number of items that can be stored in this bag. |
boolean |
hasRoomFor(GameObject obj)
Returns true if the specified object could be added to the bag's current contents without exceeding the bag's weight capacity. |
void |
insert(GameObject obj,
int index)
Inserts an item into the bag at the specified index. |
void |
invalidate(GameObject obj)
Visually invalidates the specified object in the container. |
protected void |
notifyDropped(GameObject obj)
Notifies Readyable objects that they've been unreadied. |
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
boolean |
remove(GameObject target)
Removes an item from the bag; does nothing if the item isn't in the bag. |
java.util.List |
removeAll()
Removes and returns all the items from the bag. |
GameObject |
removeFirst(Predicate p)
Removes the first instance of an object satisfying a Predicate. |
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()
Re-sends all the inventory. |
GameObject |
setObjectAt(int index,
GameObject item)
Replaces the object at the specified index with a new object. |
void |
setOwner(Player p)
Sets the player for this inventory. |
void |
setRemoteInventory(RemoteInventory inv)
Sets a new RemoteInventory to talk to, e.g. after a reconnect from net-death. |
java.lang.String |
toString()
Returns a String representation of the inventory. |
protected void |
updateGold()
Updates the gold-display on the client when coins enter or leave the inventory. |
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
Methods inherited from class wyvern.kernel.monsters.MonsterInventory |
checkAddCommand, checkRemoveCommand, findByHashcode, findByHashcode, getByIndex, getCommand, getMap, getOwner, isInventory, objects, remove, removeFirst, setContainer, setOwner, shouldWrite |
Methods inherited from class wyvern.lib.classes.BasicBag |
addGroupable, apply, checkFilter, contains, filter, find, findByName, getEmptyTitle, getItems, getItemWeight, getPosition, getRemainingCapacity, getTitle, getWeight, hasRoomFor, indexOf, initContents, initFilter, initialize, isBag, isEmpty, isMap, iterator, objectAt, printItemList, removeAll, setCapacity, setCapacity, setCapacity, setUplinks, size, updateDescription, visitObjects, writeItemList |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface wyvern.lib.properties.SelfExternalizable |
shouldWrite |
Methods inherited from interface wyvern.lib.Bag |
contains, filter, find, findByName, getItemWeight, getPosition, getRemainingCapacity, hasRoomFor, indexOf, isEmpty, iterator, objectAt, printItemList, removeAll, setCapacity, setCapacity, size, visitObjects |
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, isMap |
Field Detail |
public static final int MAX_ITEMS
protected RemoteInventory client_
protected long lastWallet_
Constructor Detail |
public PlayerInventory()
public PlayerInventory(RemoteInventory client, Player p)
Method Detail |
public void setOwner(Player p)
public void setRemoteInventory(RemoteInventory inv)
inv
- the new RemoteInventory to talk topublic GameObject add(GameObject obj) throws Bag.FullBagException
MonsterInventory
add
in interface Bag
add
in class MonsterInventory
obj
- a GameObject to add
Bag.FullBagException
public boolean remove(GameObject target)
MonsterInventory
remove
in interface Bag
remove
in class MonsterInventory
target
- the item to remove
public GameObject removeFirst(Predicate p)
MonsterInventory
removeFirst
in interface Bag
removeFirst
in class MonsterInventory
p
- a Predicate that returns true if the object is "the one"Predicate
public java.util.List removeAll()
MonsterInventory
removeAll
in interface Bag
removeAll
in class MonsterInventory
public GameObject setObjectAt(int index, GameObject item) throws Bag.FullBagException
MonsterInventory
setObjectAt
in interface Bag
setObjectAt
in class MonsterInventory
index
- the index to replace; if greater than the end of
the list, the object will be appended; if less than zero, the
object will be prepended.item
- the object to replace
Bag.FullBagException
public boolean hasRoomFor(GameObject obj)
Bag
hasRoomFor
in interface Bag
hasRoomFor
in class BasicBag
public boolean canHoldMore()
Bag
canHoldMore
in interface Bag
canHoldMore
in class BasicBag
public int getMaxCount()
Bag
getMaxCount
in interface Bag
getMaxCount
in class BasicBag
public void resend(int index)
MonsterInventory
resend
in interface Inventory
resend
in class MonsterInventory
index
- the index of the item to resend.public void resendAll()
MonsterInventory
resendAll
in interface Inventory
resendAll
in class MonsterInventory
public void invalidate(GameObject obj)
Bag
invalidate
in interface Bag
invalidate
in class BasicBag
obj
- the object to invalidatepublic java.lang.String toString()
MonsterInventory
toString
in class MonsterInventory
protected void notifyDropped(GameObject obj)
notifyDropped
in class MonsterInventory
obj
- the object to dropprotected void updateGold()
public void computeEncumbrance()
MonsterInventory
computeEncumbrance
in interface Inventory
computeEncumbrance
in class MonsterInventory
public java.util.List writeData() throws java.lang.Exception
SelfExternalizable
writeData
in interface SelfExternalizable
writeData
in class MonsterInventory
java.lang.Exception
protected void checkWeight(GameObject item) throws Bag.FullBagException
checkWeight
in class BasicBag
item
- the object to check
Bag.FullBagException
public long getCapacity()
MonsterInventory
getCapacity
in interface Bag
getCapacity
in class MonsterInventory
public java.lang.Object createClone()
public void insert(GameObject obj, int index) throws Bag.FullBagException
MonsterInventory
insert
in interface Bag
insert
in class MonsterInventory
index
- the index to insert at. An index less than zero
will be changed to zero (put obj at front), and an index larger
than the size of the bag will put the object at the end.
Bag.FullBagException
public void adjust(GameObject obj, int index)
Bag
adjust
in interface Bag
adjust
in class BasicBag
index
- the index to move it to. An index less than zero
will be changed to zero (put obj at front), and an index larger
than the size of the bag will put the object at the end.obj
- the item to insertpublic java.lang.String getCommands(GameObject obj)
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
SelfExternalizable
readData
in interface SelfExternalizable
readData
in class BasicBag
bean
- the DOM Node representing the bean
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |