forked from katylikeskats/Old-Polytopia-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit.java
More file actions
117 lines (94 loc) · 2.56 KB
/
Unit.java
File metadata and controls
117 lines (94 loc) · 2.56 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
abstract public class Unit {
private int r;
private int c;
private int maxHealth;
private int currHealth;
private int movement;
private int attack;
private int defense;
private int range;
private String tribe;
private int killCount;
Unit(int r, int c, int attack, int defense, int health, int movement, int range, String tribe){
this.r = r;
this.c = c;
this.attack = attack;
this.defense = defense;
this.currHealth = health;
this.maxHealth = health;
this.movement = movement;
this.range = range;
this.tribe = tribe;
}
public int getR() {
return r;
}
public void setR(int r) {
this.r = r;
}
public int getC() {
return c;
}
public void setC(int c) {
this.c = c;
}
public int getMaxHealth() {
return maxHealth;
}
public void setMaxHealth(int health) {
this.maxHealth = health;
}
public int getCurrHealth() {
return currHealth;
}
public void setCurrHealth(int currHealth) {
this.currHealth = currHealth;
}
public int getMovement() {
return movement;
}
public void setMovement(int movement) {
this.movement = movement;
}
public int getAttack() {
return attack;
}
public void setAttack(int attack) {
this.attack = attack;
}
public int getDefense() {
return defense;
}
public void setDefense(int defense) {
this.defense = defense;
}
public int getRange() {
return range;
}
public void setRange(int range) {
this.range = range;
}
public String getTribe() {
return tribe;
}
public void setTribe(String tribe) {
this.tribe = tribe;
}
public int getKillCount() {
return killCount;
}
public void setKillCount(int killCount) {
this.killCount = killCount;
}
public int getDamage(Unit other) {
double attackForce = this.attack * (this.currHealth / this.maxHealth);
double defenseForce = other.getDefense() * (other.getCurrHealth() / other.getMaxHealth());
double totalDamage = attackForce + defenseForce;
return (int) Math.round((attackForce / totalDamage) * this.attack * 4.5);
}
public void levelUp() {
this.currHealth = maxHealth + 5;
this.maxHealth += 5;
this.killCount = 0;
}
}