forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToybergWarrior2.java
52 lines (39 loc) · 1.56 KB
/
ToybergWarrior2.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
50
51
52
package Project02;
import Project02.People;
import Project02.PeopleType;
import static Project02.PeopleType.wizard;
public class ToybergWarrior2 extends People {
ToybergWarrior2(String nation, String tribe, int lifePoints) {
super(nation, tribe, PeopleType.warrior, lifePoints);
myDescription = "\tToyberg Warrior2";
}
public int encounterStrategy(People otherPerson) {
int lifePoints = 0;
if(this.getNation().equals(otherPerson.getNation())){ // friendly encounter
if(otherPerson.getLifePoints() < this.getLifePoints()){ // heal friendly
if(otherPerson.getTribe().equals(this.getTribe())){
lifePoints = -((this.getLifePoints() - otherPerson.getLifePoints()) / 2); // bonus if same tribe
}
else{
lifePoints = -((this.getLifePoints() - otherPerson.getLifePoints()) / 4);
}
}
}
else{
if(getLifePoints() > this.MAX_LIFEPOINTS / 2){
lifePoints = this.getLifePoints();
}
/*
* does more than normal damage in return for small loss in health
*/
else if(getLifePoints() < this.MAX_LIFEPOINTS / 2 && this.getLifePoints() > otherPerson.getLifePoints()){
lifePoints = this.getLifePoints();
modifyLifePoints(-this.getLifePoints() / 10);
}
else{
lifePoints = this.getLifePoints() / 2;
}
}
return lifePoints;
}
}