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 TypeMethodDescriptionvoidaddBuilding(ShopBuilding building) voidaddEquipmentToList(Equipments equipment) voidaddGold(int gold) Adds to the player's gold.voidvoidaddResources(ResourceType resourceType, int amount) voidaddStone(int stone) Adds to the player's stone.voidaddWood(int wood) Adds to the player's wood.intcountInEquipmentList(Equipments equipment) getArmor()intgetBuildingCount(ShopBuilding building) intgetGold()Returns the player's gold.intgetItemCount(Artefact item) getItems()intgetStone()Returns the player's stone.intgetWood()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) voidremoveBuilding(ShopBuilding building) voidsetArmor(Equipments armor) voidsetBuildings(HashMap<ShopBuilding, Integer> buildings) voidsetEquipmentList(List<Equipments> equipmentsList) voidsetGold(int gold) Sets the player's gold.voidvoidsetStone(int stone) Sets the player's stone.voidsetWeapon(Equipments weapon) voidsetWood(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
-