Class TamableComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.npc.TamableComponent
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class TamableComponent extends Component
This the class for Tameable Component. These components should only apply to animals. Tameable stats can be found in the NPCs.json file
  • Constructor Details

    • TamableComponent

      public TamableComponent(Entity player, int tamingThreshold, double tamingProbability, String favouriteFood)
      Constructor for the Tameable Component class
      Parameters:
      player - The main player/user entity
      tamingThreshold - An integer that number of times the animal can be fed to tame it.
      tamingProbability - A double that represents chances to tame the animal.
      favouriteFood - The animals favourite food.
  • Method Details

    • create

      public void create()
      Create the event and add it to the event hashmap so the function can be called and the player can observe the effects.
      Overrides:
      create in class Component
    • isTamed

      public boolean isTamed()
      Function is used to check to see if the animal has been tamed.
      Returns:
      True if the animal has been tamed, else false.
    • setTame

      public void setTame(boolean value)
      Function is used to set the tame value of the animals. This is used for testing purposes and will be deleted in later sprint.
      Parameters:
      value - Boolean value that will be used to set to the istamed variable.
    • write

      public void write(com.badlogic.gdx.utils.Json json)
      Writes to the json boolean of tamed.
      Specified by:
      write in interface com.badlogic.gdx.utils.Json.Serializable
      Overrides:
      write in class Component
      Parameters:
      json - which is a valid Json.
    • read

      public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap)
      Specified by:
      read in interface com.badlogic.gdx.utils.Json.Serializable
      Overrides:
      read in class Component
    • getFavouriteFood

      public String getFavouriteFood()
      Getter for favourite food
      Returns:
      favourite food