-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSStudent.java
37 lines (30 loc) · 1.11 KB
/
CSStudent.java
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
public class CSStudent extends Student implements Triggerable{
public CSStudent(String name) {
super(name, 7, 6, 6, 6, 4);
}
public void pairWorking(Character friend , Character enemy) throws Exception {
this.specialAttack();
int damageAmount = (100 * this.getAttack()) / (100 + enemy.getDefence());
enemy.decreaseHP(damageAmount);
int damageAmountFriend = (100 * friend.getAttack()) / (100 + enemy.getDefence());
enemy.decreaseHP(damageAmountFriend);
if(enemy.getHP() == 0){
this.increaseEP(4);
}
}
public void support(Character friend) throws Exception {
this.specialAttack();
if(friend.isAlive()){
friend.increaseHP(this.getDefence());
}
}
@Override
public void triggerSpecialAttack(Character enemy, Character friend) throws Exception {
if(friend.isAlive() && friend.getHP() < friend.getMaxHP()/3 ){
this.support(friend);
}
else{
this.pairWorking(friend, enemy);
}
}
}