public class Actor { // TODO: make final private String name; // TODO: could be replaced with `bool isAlive() { return this.hp > 0; }` private boolean alive; // TODO: enemy should not be binary (ex clans / groups / factions) private boolean enemy; private int hp; // TODO: pack abilities / bonus / powers in structures private int agility; private int strenght; private int defense; private int x; private int y; private Weapon weapon; private int actionsLeft; // TODO: make final private int actions = 2; // TODO: make bonus / power-ups structure public Actor(String name, int hp, boolean enemy, int agility) { this.name = name; this.hp = hp; this.enemy = enemy; this.agility = agility; // TODO: puch should have infinite durability this.weapon = new Weapon("fist", 1, 1, 10000000); this.alive = true; this.resetActions(); } public void resetActions() { this.actionsLeft = this.actions; } public int getActionsLeft() { return this.actionsLeft; } public boolean hit(Actor actor, Map map) { if (this.actionsLeft > 0) { if (this.weapon.damage(this, actor, map)) { this.actionsLeft--; return true; } } return false; } public Weapon getWeapon() { return this.weapon; } public void equipWeapon(Weapon weapon) { this.weapon = weapon; } // TODO: could be `return this.hp > 0` and remove member public boolean isAlive() { return this.alive; } public void setHP(int hp) { this.hp = hp; if (this.hp <= 0) { this.alive = false; } } public void damage(int dmg) { this.hp -= dmg; if (this.hp <= 0) { this.alive = false; } } public int getAgility() { return this.agility; } public String getName() { return this.name; } public int getHP() { return this.hp; } public int getX() { return this.x; } public int getY() { return this.y; } public boolean isEnemy() { return this.enemy; } public void move(int x, int y) { if (this.actionsLeft > 0) { this.x = x; this.y = y; this.actionsLeft--; } } public void place(int x, int y) { this.x = x; this.y = y; } }