Class InventoryComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.player.InventoryComponent
A component intended to be used by the player to track their inventory.
Currently only stores the gold and stone amount but can be extended for more
advanced functionality such as storing items.
Can also be used as a more generic component for other entities.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBuilding
(ShopBuilding building) void
addEquipmentToList
(Equipments equipment) void
addGold
(int gold) Adds to the player's gold.void
void
addResources
(ResourceType resourceType, int amount) void
addStone
(int stone) Adds to the player's stone.void
addWood
(int wood) Adds to the player's wood.int
countInEquipmentList
(Equipments equipment) getArmor()
int
getBuildingCount
(ShopBuilding building) int
getGold()
Returns the player's gold.int
getItemCount
(Artefact item) getItems()
int
getStone()
Returns the player's stone.int
getWood()
Returns the player's wood.hasGold
(int gold) Returns if the player has a certain amount of gold.hasStone
(int stone) Returns if the player has a certain amount of stone.hasWood
(int wood) Returns if the player has a certain amount of wood.placeBuilding
(ShopBuilding building) void
removeBuilding
(ShopBuilding building) void
setArmor
(Equipments armor) void
setBuildings
(HashMap<ShopBuilding, Integer> buildings) void
setEquipmentList
(List<Equipments> equipmentsList) void
setGold
(int gold) Sets the player's gold.void
void
setStone
(int stone) Sets the player's stone.void
setWeapon
(Equipments weapon) void
setWood
(int wood) Sets the player's wood.Methods inherited from class com.deco2800.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
InventoryComponent
public InventoryComponent(int gold, int stone, int wood)
-
-
Method Details
-
setWeapon
-
setArmor
-
getWeapon
-
getArmor
-
getGold
public int getGold()Returns the player's gold.- Returns:
- entity's gold
-
getStone
public int getStone()Returns the player's stone.- Returns:
- entity's stone
-
getWood
public int getWood()Returns the player's wood.- Returns:
- entity's wood
-
hasGold
Returns if the player has a certain amount of gold.- Parameters:
gold
- required amount of gold- Returns:
- player has greater than or equal to the required amount of gold
-
hasStone
Returns if the player has a certain amount of stone.- Parameters:
stone
- required amount of stone- Returns:
- player has greater than or equal to the required amount of stone
-
hasWood
Returns if the player has a certain amount of wood.- Parameters:
wood
- required amount of stone- Returns:
- player has greater than or equal to the required amount of wood
-
setGold
public void setGold(int gold) Sets the player's gold. Gold has a minimum bound of 0.- Parameters:
gold
- gold
-
setStone
public void setStone(int stone) Sets the player's stone. Stone has a minimum bound of 0.- Parameters:
stone
- currency stone
-
setWood
public void setWood(int wood) Sets the player's wood. Stone has a minimum bound of 0.- Parameters:
wood
- currency wood
-
addGold
public void addGold(int gold) Adds to the player's gold. The amount added can be negative.- Parameters:
gold
- gold to add
-
addStone
public void addStone(int stone) Adds to the player's stone. The amount added can be negative.- Parameters:
stone
- stone to add
-
addWood
public void addWood(int wood) Adds to the player's wood. The amount added can be negative.- Parameters:
wood
- stone to add
-
addResources
-
setEquipmentList
-
getEquipmentList
-
addEquipmentToList
-
countInEquipmentList
-
setItems
-
setBuildings
-
addBuilding
-
removeBuilding
-
getBuildingCount
-
getBuildings
-
addItems
-
useItem
-
placeBuilding
-
getItems
-
getItemCount
-