forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToybergWarrior.java
62 lines (50 loc) · 1.89 KB
/
ToybergWarrior.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
53
54
55
56
57
58
59
60
61
62
package Project02;
public class ToybergWarrior extends Project02.People {
ToybergWarrior(String nation, String tribe, int lifePoints){
super(nation, tribe, Project02.PeopleType.warrior, lifePoints);
myDescription = "\tToyberg Warrior";
}
boolean strengthBoost = false;
int numBandages = 1;
public int encounterStrategy(Project02.People otherPerson) {
int lifePoints = 0;
if(this.getNation() == otherPerson.getNation()){
if(otherPerson.getType() == this.getType()){ // give strength boost if both friendly warriors
this.strengthBoost = true;
}
if(otherPerson.getType() == Project02.PeopleType.healer){
numBandages ++;
}
if(otherPerson.getLifePoints() < this.getLifePoints()){
if(otherPerson.getTribe() == this.getTribe()){
lifePoints = -((this.getLifePoints() - otherPerson.getLifePoints()) / 2);
}
else{
lifePoints = -((this.getLifePoints() - otherPerson.getLifePoints()) / 4);
}
}
}
else{
int points = this.getLifePoints() - otherPerson.getLifePoints();
if(points > 0){
lifePoints = this.getLifePoints();
}
else{
if(this.strengthBoost){
this.strengthBoost = false;
return lifePoints + this.MAX_LIFEPOINTS / 10;
}
lifePoints = this.getLifePoints() / 2;
}
}
return lifePoints;
}
/**
* uses a disposable bandage to heal injuries. Character begins with 1 bandage and
* gets one additional each time he encounters a friendly healer
*/
private void useBandage(){
numBandages -= 1;
modifyLifePoints(this.MAX_LIFEPOINTS / 10);
}
}