All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable

public class Sheep extends DomesticAnimal
Author:
Daniel Herding
  • Field Details

    • HUNGER_HUNGRY

      protected static final int HUNGER_HUNGRY
      The amount of hunger that indicates hungry.
      See Also:
      Constant Field Values
    • HUNGER_EXTREMELY_HUNGRY

      protected static final int HUNGER_EXTREMELY_HUNGRY
      The amount of hunger that indicates extremely hungry.
      See Also:
      Constant Field Values
    • HUNGER_STARVATION

      protected static final int HUNGER_STARVATION
      The amount of hunger that indicates starvation.
      See Also:
      Constant Field Values
    • MAX_WEIGHT

      public static final int MAX_WEIGHT
      The weight at which the sheep will stop eating.
      See Also:
      Constant Field Values
  • Constructor Details

    • Sheep

      public Sheep()
      Creates a new wild Sheep.
    • Sheep

      public Sheep(Player owner)
      Creates a new Sheep that is owned by a player.
      Parameters:
      owner - owning player, or null
    • Sheep

      public Sheep(RPObject object, Player owner)
      Creates a Sheep based on an existing sheep RPObject, and assigns it to a player.
      Parameters:
      object - object containing the data for the sheep
      owner - The player who should own the sheep
  • Method Details

    • setAttackStrategy

      public void setAttackStrategy(Map<String,​String> aiProfiles)
      Description copied from class: Creature
      Set the fighting strategy used by the creature.
      Overrides:
      setAttackStrategy in class Creature
      Parameters:
      aiProfiles - AI profiles to be used when deciding the strategy
    • generateRPClass

      public static void generateRPClass()
    • onDead

      public void onDead(Killer killer, boolean remove)
      Is called when the sheep dies. Removes the dead sheep from the owner.
      Overrides:
      onDead in class Creature
      Parameters:
      killer - The entity who caused the death, i.e. who did the last hit.
      remove - true iff this entity should be removed from the world. For almost everything remove is true, but not for the players, who are instead moved to afterlife ("reborn").
    • getFoodinRange

      protected List<SheepFood> getFoodinRange(double range)
      Returns a list of SheepFood in the given range ordered by distance. The first in list is the nearest.
      Parameters:
      range - The maximum distance to a SheepFood
      Returns:
      a list of SheepFood or emptyList if none is found in the given range
    • onHungry

      protected boolean onHungry()
      Called when the sheep is hungry.
      Returns:
      true if the sheep is hunting for food.
    • searchForFood

      protected boolean searchForFood()
    • onIdle

      protected void onIdle()
      Called when the sheep is idle.
    • onStarve

      protected void onStarve()
      Called when the sheep is starving.
    • eat

      protected void eat(SheepFood food)
      Let the sheep eat some food.
      Parameters:
      food - The food to eat.
    • logic

      public void logic()
      Determines what the sheep shall do next.
      Overrides:
      logic in class Creature
    • describe

      public String describe()
      Description copied from class: Entity
      Describes the entity (if a players looks at it).
      Overrides:
      describe in class RPEntity
      Returns:
      description from the players point of view