public final class Inventory extends java.util.LinkedList<Item> implements SaveElement
Constructor and Description |
---|
Inventory(Targetable character)
Inventory constructor
|
Inventory(Targetable character,
InventoryLock lock)
Inventory constructor, with lock
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Item item)
Adds item to inventory
|
boolean |
addAll(java.util.Collection<? extends Item> items)
Adds all items from collection to inventory
|
boolean |
addAll(Item[] items)
Adds all items from collection to inventory
|
java.util.List<SlotContent> |
asSlotsContent()
Returns all inventory as list with slot content
|
boolean |
equip(Item item)
Equips specified item, if item is in character inventory and its equippable
|
Item |
get(int index)
Returns item with specific index in inventory container
|
int |
getArmorRating()
Returns armor rating of equipped items
|
int |
getCashValue()
Returns value of all coins in this inventory
|
Armor |
getChest()
Return character chest
|
java.util.Collection<Item> |
getCoins()
Returns all coins in inventory
|
Armor |
getHelmet()
Return character helmet
|
Item |
getItem(java.lang.String itemId)
Returns item which matches to specific id
|
Item |
getItemBySerial(java.lang.String serialId)
Returns item with specified serial ID
|
java.util.Collection<Item> |
getItems(java.lang.String id)
Returns all items with specified ID from inventory
|
java.util.Collection<Item> |
getItems(java.lang.String id,
int amount)
Returns specified amount of items with specified ID
|
Weapon |
getMainWeapon()
Return character main weapon
|
Weapon |
getOffHand()
Returns character off hand
|
org.w3c.dom.Element |
getSave(org.w3c.dom.Document doc)
Parses inventory to XML document element
|
org.w3c.dom.Element |
getSaveWithoutEq(org.w3c.dom.Document doc)
Parses inventory without equipment to XML document element
|
int[] |
getWeaponDamage()
Returns weapon damage of equipment items
|
java.util.List<Item> |
getWithoutEq()
Returns all items except equipped items
|
boolean |
isDualwield()
Checks if both main and off weapon are equipped
|
boolean |
isEquipped(Item item)
Checks if specified item is equipped
|
boolean |
isLocked()
Checks if inventory is locked
|
void |
lock(InventoryLock lock)
Lock inventory with specified lock
|
boolean |
remove(java.lang.Object item)
Removes specified item from inventory
|
boolean |
remove(java.lang.String serialId)
Removes items with specified serial ID from inventory
|
boolean |
remove(java.lang.String id,
int amount)
Removes specified amount of items with specified ID from inventory
|
boolean |
removeAll(java.util.Collection<?> items) |
boolean |
takeCash(int value)
Takes amount of coins with specified value from inventory
|
Item |
takeItem(Item item)
Removes specified item from inventory and returns it
|
Item |
takeItem(java.lang.String itemId)
Removes item with specified ID from inventory and returns it
|
void |
unequipp(Equippable item)
Removes specific item from equippment
|
boolean |
unlock(Character character)
Opens lock
|
boolean |
unlock(UnlockBonus skill)
Opens lock with specified skill
|
void |
update()
Updates inventory
(for example bonuses from equipped items)
|
add, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray
public Inventory(Targetable character)
character
- Inventory ownerpublic Inventory(Targetable character, InventoryLock lock)
character
- Inventory ownerlock
- Inventory lockpublic void update()
public boolean add(Item item)
add
in interface java.util.Collection<Item>
add
in interface java.util.Deque<Item>
add
in interface java.util.List<Item>
add
in interface java.util.Queue<Item>
add
in class java.util.LinkedList<Item>
public boolean addAll(java.util.Collection<? extends Item> items)
public boolean addAll(Item[] items)
items
- Collection with itemspublic boolean remove(java.lang.Object item)
remove
in interface java.util.Collection<Item>
remove
in interface java.util.Deque<Item>
remove
in interface java.util.List<Item>
remove
in class java.util.LinkedList<Item>
item
- Game itempublic boolean remove(java.lang.String serialId)
serialId
- Serial ID of item to removepublic boolean remove(java.lang.String id, int amount)
serialId
- ID of items to removepublic boolean removeAll(java.util.Collection<?> items)
public int getCashValue()
public void unequipp(Equippable item)
item
- Equipped character itempublic boolean equip(Item item)
item
- Equippable item in character inventorypublic boolean isEquipped(Item item)
item
- Game itempublic int[] getWeaponDamage()
public int getArmorRating()
public Armor getHelmet()
public Armor getChest()
public Weapon getMainWeapon()
public Weapon getOffHand()
public Item getItem(java.lang.String itemId)
itemId
- Id of requested itempublic java.util.Collection<Item> getItems(java.lang.String id, int amount)
id
- Items IDamount
- Amount of items to returnpublic java.util.Collection<Item> getItems(java.lang.String id)
id
- String with items IDpublic java.util.Collection<Item> getCoins()
public Item get(int index)
public Item getItemBySerial(java.lang.String serialId)
serialId
- String with serial IDpublic Item takeItem(Item item)
item
- Item in inventory to removepublic Item takeItem(java.lang.String itemId)
item
- Item in inventory to removepublic boolean takeCash(int value)
value
- Value to 'pay' with coins from inventorypublic java.util.List<Item> getWithoutEq()
public java.util.List<SlotContent> asSlotsContent()
public boolean isDualwield()
public boolean isLocked()
public boolean unlock(Character character)
character
- Game character opening lockpublic boolean unlock(UnlockBonus skill)
skill
- Skillpublic void lock(InventoryLock lock)
lock
- Inventory lockpublic org.w3c.dom.Element getSave(org.w3c.dom.Document doc)
getSave
in interface SaveElement
doc
- Document for save game filepublic org.w3c.dom.Element getSaveWithoutEq(org.w3c.dom.Document doc)
doc
- Document for save game file