Class Goblin

All Implemented Interfaces:
AIControllable

public class Goblin extends Entity implements AIControllable
In-game enemy controlled by AI. Decides to attack or defend based on its remaining HP.
  • Field Details

    • isDefending

      protected boolean isDefending
      Whether the Goblin is currently defending (halves incoming damage).
  • Constructor Details

    • Goblin

      public Goblin()
      Creates a Goblin with default stats. HP 60, ATK 15, DEF 2.
  • Method Details

    • calculateAttack

      public int calculateAttack()
      Calculates the Goblin's attack value using attackPower directly.
      Specified by:
      calculateAttack in class Entity
      Returns:
      Attack value
    • getDescription

      public String getDescription()
      Returns a short description of the Goblin for the UI.
      Specified by:
      getDescription in class Entity
      Returns:
      Description text
    • takeDamage

      public void takeDamage(int dmg)
      Takes damage, halving it first if the Goblin is currently defending.
      Overrides:
      takeDamage in class Entity
      Parameters:
      dmg - Raw damage before reduction
    • decideAction

      public BattleAction decideAction(Entity target)
      AI decides what to do this turn. If HP is below 30%, it chooses to defend; otherwise it always attacks.
      Specified by:
      decideAction in interface AIControllable
      Parameters:
      target - The opposing player (used as a reference; the Goblin does not inspect the target's stats)
      Returns:
      The action the Goblin will perform
    • isDefending

      public boolean isDefending()
      Returns:
      true if currently defending
    • setDefending

      public void setDefending(boolean d)
      Sets the defending state.
      Parameters:
      d - true to start defending