From 9dca8d0f3610e2cd1079f9705f1da31ff19aba93 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 19 Nov 2018 09:12:42 +0100 Subject: Add Actor.SkillSet, remove useless members in various strucutres --- src/Actor.java | 95 ++++++++++++++++++++++------------------------------------ 1 file changed, 36 insertions(+), 59 deletions(-) (limited to 'src/Actor.java') diff --git a/src/Actor.java b/src/Actor.java index ef63217..b4d34aa 100644 --- a/src/Actor.java +++ b/src/Actor.java @@ -1,18 +1,20 @@ public class Actor { - // TODO: make final - private String name; - // TODO: could be replaced with `bool isAlive() { return this.hp > 0; }` - private boolean alive; + private final String name; + // TODO: enemy should not be binary (ex clans / groups / factions) - private boolean enemy; + private boolean isEnemy; 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; + + public class SkillSet { + public int agility; + // public int strenght; + // public int defense; + } + + public SkillSet skills; private Weapon weapon; private int actionsLeft; @@ -20,26 +22,39 @@ public class Actor { private int actions = 2; // TODO: make bonus / power-ups structure - public Actor(String name, int hp, boolean enemy, int agility) { + public Actor(String name, int hp, boolean isEnemy, int agility) { this.name = name; this.hp = hp; - this.enemy = enemy; - this.agility = agility; + this.isEnemy = isEnemy; + + this.skills = new SkillSet(); + this.skills.agility = agility; + // TODO: puch should have infinite durability this.weapon = new Weapon("fist", 1, 1, 10000000); - this.alive = true; this.resetActions(); } + public String getName() { return this.name; } + + public int getX() { return this.x; } + public int getY() { return this.y; } + + public Weapon getWeapon() { return this.weapon; } + public void equipWeapon(Weapon weapon) { this.weapon = weapon; } + + public void setHP(int hp) { this.hp = hp; } + public int getHP() { return this.hp; } + + public final SkillSet getSkills() { return this.skills; } + + public int getActionsLeft() { return this.actionsLeft; } + 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)) { @@ -50,55 +65,17 @@ public class Actor { 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; + return this.hp > 0; } - public void setHP(int hp) { - this.hp = hp; - if (this.hp <= 0) { - this.alive = false; - } + + public boolean isEnemy() { + return this.isEnemy; } 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) { -- cgit v1.2.1