Class Entity

java.lang.Object
com.adventure.models.Entity
Direct Known Subclasses:
NPC, Player

public abstract class Entity extends Object
Represents a generic entity.
  • Field Details

    • inventory

      protected Inventory inventory
      Entity inventory.
    • stats

      protected Stats stats
      Entity stats.
  • Constructor Details

    • Entity

      public Entity(Inventory inventory, Stats stats, String name)
      Entity constructor.
      Parameters:
      inventory - Player inventory.
      stats - Player stats.
      name - Entity name.
  • Method Details

    • getInventory

      public Inventory getInventory()
      Inventory getter.
      Returns:
      The entity inventory.
    • getAlive

      public boolean getAlive()
      Returns if the entity is alive.
      Returns:
      True if the entity is alive, false otherwise.
    • getName

      public String getName()
      Returns the name of the entity.
      Returns:
      name of the entoty.
    • getStats

      public Stats getStats()
      Stats getter.
      Returns:
      Entity stats.
    • getAvailableDodges

      public int getAvailableDodges()
      Returns the number of the dodge
      Returns:
      number of available dodges
    • setInventory

      public void setInventory(Inventory inventory)
      Inventory setter.
      Parameters:
      inventory - Inventory to set.
    • setAlive

      public void setAlive(boolean alive)
      Setter used to kill or revive the entity.
      Parameters:
      alive - If is set to false, then the entity hp are set to 0. If is set to true and the entity was dead then the hp are set to maxHp.
    • setStats

      public void setStats(Stats stats)
      Sets entity stats.
      Parameters:
      stats - Entity stats.
    • setName

      public void setName(String name)
      Sets entity name.
      Parameters:
      name - Entity name.
    • useDodge

      public boolean useDodge()
      Uses a dodge.
      Returns:
      Returns true if the player had a dodge to consume, false otherwise.
    • resetDodge

      public void resetDodge()
      Resets the available dodges to the maximum amount.
    • getAttackDamage

      public int getAttackDamage()
      Returns the damage done by a player when attacking.
      Returns:
      Attack done by the player.
    • heal

      public void heal(int points)
      Heals the entity.
      Parameters:
      points - Health points to gain.
    • hit

      public int hit(int damage)
      Damages the entity.
      Parameters:
      damage - Health points to lose. This damage is mitigated by the entity defence.
      Returns:
      Inflicted damage.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object