-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.java
More file actions
121 lines (93 loc) · 2.66 KB
/
Character.java
File metadata and controls
121 lines (93 loc) · 2.66 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
118
119
120
121
import java.lang.Math;
public class Character{
private String name;
private int baseHP;
private int baseAtk;
private int baseDef;
private int baseSpd;
private int maxHP;
private int currentHP;
private int currentEP;
private int level = 1;
private Team team;
public Character(String name, int baseHP, int baseAtk, int baseDef, int baseSpd){
this.name = name;
this.baseHP = baseHP;
this.baseAtk = baseAtk;
this.baseDef = baseDef;
this.baseSpd = baseSpd;
this.currentHP = getMaxHP();
this.maxHP = getMaxHP();
}
public Character(String name, int baseHP, int baseAtk, int baseDef, int baseSpd, Team team){
this(name, baseHP, baseAtk, baseDef, baseSpd);
this.team = team;
}
public String getName(){
return name;
}
public int getMaxHP(){
return (int)Math.round(baseHP*Math.pow(level, 1.2));
}
public int getAttack(){
return (int)Math.round(baseAtk*Math.pow(level, 1.2));
}
public int getDefence(){
return (int)Math.round(baseDef*Math.pow(level, 1.2));
}
public void increaseDefence(int amount){
baseDef += amount;
}
public int getSpeed(){
return (int)Math.round(baseSpd*Math.pow(level, 1.2));
}
//maxEP = 10;
private int targetEP;
public int getTargetEP(){
targetEP = (int)Math.round(10*Math.pow(level,1.5));
return targetEP;
}
public int getHP(){
return currentHP;
}
public int getEP(){
return currentEP;
}
public void increaseHP(int amount){
if(currentHP > 0){
currentHP += amount;
currentHP = Math.min(currentHP, this.getMaxHP());
}
}
public void decreaseHP(int amount){
if(currentHP > 0){
currentHP -= amount;
currentHP = Math.max(currentHP , 0);
}
}
public void increaseEP(int amount){
currentEP += amount;
if(currentEP >= getTargetEP()){
level += 1;
currentEP = 0;
if(this.isAlive()){
currentHP = getMaxHP();
}
}
}
public Team getTeam(){
return team;
}
public void setTeam(Team team){
this.team = team;
}
public Boolean isAlive(){
return this.currentHP > 0;
}
public double getPowerPoints(){
return (this.getAttack() + this.getDefence())/2.0;
}
public void setLevel(int level) {
this.level = level;
}
}