blob: 7b4635f239b6e959eee25d8e1b662f7debe36412 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
public class Actor {
private final String name;
// TODO: enemy should not be binary (ex clans / groups / factions)
private boolean isEnemy;
private int hp;
private int x;
private int y;
public class SkillSet {
public int agility = 0;
// public int strenght;
// public int defense;
}
public SkillSet skills;
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 isEnemy, int agility) {
this.name = name;
this.hp = hp;
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.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 boolean hit(Actor actor, Map map) {
if (this.actionsLeft > 0) {
if (this.weapon.damage(this, actor, map)) {
this.actionsLeft--;
return true;
}
}
return false;
}
public boolean isAlive() {
return this.hp > 0;
}
public boolean isEnemy() {
return this.isEnemy;
}
public void damage(int dmg) {
this.hp -= dmg;
}
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;
}
}
|