Class Goblin
java.lang.Object
model.entity.Entity
model.entity.Goblin
- All Implemented Interfaces:
AIControllable
In-game enemy controlled by AI.
Decides to attack or defend based on its remaining HP.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the Goblin is currently defending (halves incoming damage).Fields inherited from class model.entity.Entity
attackPower, baseAttackPower, baseDefense, currentHp, defense, maxHp, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCalculates the Goblin's attack value using attackPower directly.decideAction(Entity target) AI decides what to do this turn.Returns a short description of the Goblin for the UI.booleanvoidsetDefending(boolean d) Sets the defending state.voidtakeDamage(int dmg) Takes damage, halving it first if the Goblin is currently defending.Methods inherited from class model.entity.Entity
getAttackPower, getCurrentHp, getDefense, getMaxHp, getName, heal, isAlive, resetAttackPower, resetDefense, setAttackPower, setBaseAttackPower, setBaseDefense, setCurrentHp, setDefense, setMaxHp
-
Field Details
-
isDefending
protected boolean isDefendingWhether 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:
calculateAttackin classEntity- Returns:
- Attack value
-
getDescription
Returns a short description of the Goblin for the UI.- Specified by:
getDescriptionin classEntity- Returns:
- Description text
-
takeDamage
public void takeDamage(int dmg) Takes damage, halving it first if the Goblin is currently defending.- Overrides:
takeDamagein classEntity- Parameters:
dmg- Raw damage before reduction
-
decideAction
AI decides what to do this turn. If HP is below 30%, it chooses to defend; otherwise it always attacks.- Specified by:
decideActionin interfaceAIControllable- 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:
trueif currently defending
-
setDefending
public void setDefending(boolean d) Sets the defending state.- Parameters:
d-trueto start defending
-