forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToybergHealer2.java
49 lines (41 loc) · 1.69 KB
/
ToybergHealer2.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
38
39
40
41
42
43
44
45
46
47
48
49
package Project02;
import Project02.People;
import Project02.PeopleType;
import static Project02.PeopleType.*;
public class ToybergHealer2 extends Project02.People {
ToybergHealer2(String nation, String tribe, int lifePoints) {
super(nation, tribe, healer, lifePoints);
myDescription = "\tToyberg Healer2";
}
public int encounterStrategy(Project02.People otherPerson) {
int lifePoints = 0;
if(!this.getNation().equals(otherPerson.getNation())){
if(this.getLifePoints() > MAX_LIFEPOINTS / 3){
if(otherPerson.getType() == healer){ // attack hostile healers using half health
lifePoints = this.getLifePoints() / 2;
}
else if(otherPerson.getType() == wizard || otherPerson.getType() == warrior){
lifePoints = this.getLifePoints() / 4; // attack other combatants using lower health
}
}
else{
lifePoints = -this.getLifePoints(); // run away
}
}
else{
if(this.getTribe().equals("Tribe2")){ // master healers from this tribe are extremely efficient at treating battle wounds
return otherPerson.MAX_LIFEPOINTS;
}
else if(otherPerson.getLifePoints() < this.getLifePoints()){ // heal a friend
if(otherPerson.getTribe().equals(this.getTribe())){
lifePoints = (int) this.getLifePoints();
}
lifePoints = (int) (this.getLifePoints() - otherPerson.getLifePoints() / 2);
}
else{
lifePoints = 0;
}
}
return lifePoints;
}
}