Package com.mg105.entities
Class Inventory
java.lang.Object
com.mg105.entities.Inventory
An inventory is a class that manages items
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds an item to the inventory.boolean
Returns if there is at LEAST one item in inventory with itemNameboolean
isFull()
Returns if the inventory is full.int
limit()
Returns the maximum amount items allowed in the inventoryint
Returns the number of items in the inventory currentlyint
numberOfItems
(@NotNull String itemName) Returns the total number of items in the inventory that have the itemName as there namevoid
Removes all the items from the inventory.boolean
removeItem
(@NotNull String itemName) Removes ONE instance of an item from the inventory that has the same itemName.boolean
Uses the item on the given character
-
Constructor Details
-
Inventory
public Inventory()
-
-
Method Details
-
limit
public int limit()Returns the maximum amount items allowed in the inventory- Returns:
- the maximum number of items the inventory can hold
-
numberOfItems
public int numberOfItems()Returns the number of items in the inventory currently- Returns:
- the number of items in the inventory
-
numberOfItems
Returns the total number of items in the inventory that have the itemName as there name- Parameters:
itemName
- The name of items that should be counted- Returns:
- the number of items in inventory with that name
- See Also:
-
isFull
public boolean isFull()Returns if the inventory is full. A full inventory cannot have any items added to ti.- Returns:
- if the inventory is full.
-
addItem
Adds an item to the inventory. An item is not added to the inventory iff the inventory is full.- Parameters:
item
- The item to be added to the inventory- Returns:
- whether of not the item was added to the inventory
-
removeItem
Removes ONE instance of an item from the inventory that has the same itemName.- Parameters:
itemName
- The name of item that should be removed- Returns:
- true iff an item with itemName was removed from the inventory
- See Also:
-
removeAll
public void removeAll()Removes all the items from the inventory. -
useItem
public boolean useItem(@NotNull @NotNull GameState state, @NotNull @NotNull String itemName, @NotNull @NotNull String characterName) Uses the item on the given character- Parameters:
state
- The current state of the gameitemName
- The name of the item to usecharacterName
- the character to use the item on- Returns:
- true iff the item with a name of itemName was used
- See Also:
-
has
Returns if there is at LEAST one item in inventory with itemName- Parameters:
itemName
- the name of item that needs to be searched for- Returns:
- if there is an item in the inventory with a name that is itemName
-