Class DomesticAnimal

All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
Pet, Sheep

public abstract class DomesticAnimal extends Creature
A domestic animal can be owned by a player;

each player can't own more than one domestic animal.

It has a weight; when it dies, it leaves an amount of meat, depending on its weight.

  • Field Details

    • weight

      protected int weight
    • wasOwned

      protected boolean wasOwned
    • owner

      protected Player owner
      The player who owns the domestic animal, or null if the animal is wild.
  • Constructor Details

    • DomesticAnimal

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

      public DomesticAnimal(RPObject object)
      Creates a wild DomesticAnimal based on an existing RPObject.
      Parameters:
      object - object containing the data for the animal
    • DomesticAnimal

      public DomesticAnimal(RPObject object, Player owner)
      Creates a wild DomesticAnimal based on an existing RPObject, and assigns it to a player.
      Parameters:
      object - owning player, or null
      owner - The player who should own the sheep
  • Method Details

    • setOwner

      public void setOwner(Player owner)
    • takesPartInCombat

      protected boolean takesPartInCombat()
      Does this domestic animal take part in combat?
      Returns:
      true, if it can be attacked by creatures, false otherwise
    • getOwner

      public Player getOwner()
    • wasOwned

      public boolean wasOwned()
      Checks if this domestic animal was owned by a player, regardless of whether it is owned at the moment.
      Returns:
      true, if the creature had been owned, otherwise false
    • update

      public void update()
      Overrides:
      update in class RPEntity
    • setWeight

      public void setWeight(int weight)
    • getWeight

      public int getWeight()
    • moveToOwner

      protected void moveToOwner()
    • dropItemsOn

      protected void dropItemsOn(Corpse corpse)
      Can be called when the sheep dies. Puts meat onto its corpse; the amount of meat depends on the domestic animal's weight.
      Overrides:
      dropItemsOn in class Creature
      Parameters:
      corpse - The corpse on which to put the meat
    • handleObjectCollision

      protected void handleObjectCollision()
      Overrides:
      handleObjectCollision in class GuidedEntity
    • handleSimpleCollision

      protected void handleSimpleCollision(int nx, int ny)
      Description copied from class: ActiveEntity
      a simple collision is from tiled collision layer or the edge of the map.
      Overrides:
      handleSimpleCollision in class ActiveEntity
    • isOwnerCallingMe

      protected boolean isOwnerCallingMe()
      Is the owner of this pet calling its name or the type name like "pet"?
      Returns:
      boolean flag