Class InventoryComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.player.InventoryComponent

public class InventoryComponent extends Component
A component intended to be used by the player to track their inventory. Currently only stores the gold 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.
  • Constructor Details

    • InventoryComponent

      public InventoryComponent(int gold)
  • Method Details

    • getGold

      public int getGold()
      Returns the player's gold.
      Returns:
      entity's health
    • hasGold

      public Boolean hasGold(int gold)
      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
    • setGold

      public void setGold(int gold)
      Sets the player's gold. Gold has a minimum bound of 0.
      Parameters:
      gold - gold
    • addGold

      public void addGold(int gold)
      Adds to the player's gold. The amount added can be negative.
      Parameters:
      gold - gold to add