summaryrefslogtreecommitdiffstats
path: root/src/Actor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Actor.java')
-rw-r--r--src/Actor.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/Actor.java b/src/Actor.java
new file mode 100644
index 0000000..ca3995a
--- /dev/null
+++ b/src/Actor.java
@@ -0,0 +1,107 @@
+public class Actor {
+ private String name;
+ private boolean alive;
+ private boolean enemy;
+ private int hp;
+ private int agility;
+ private int strenght;
+ private int defense;
+ private int x;
+ private int y;
+ private Weapon weapon;
+ private int actionsLeft;
+ private int actions = 2;
+
+ public Actor(String name, int hp, boolean enemy, int agility) {
+ this.name = name;
+ this.hp = hp;
+ this.enemy = enemy;
+ this.agility = agility;
+ 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;
+ }
+
+ 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;
+
+ }
+}