forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerezHealer2.java
45 lines (38 loc) · 1.23 KB
/
PerezHealer2.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
package Project02;
public class PerezHealer2 extends Project02.People
{
PerezHealer2(String nation, String tribe, int lifePoints)
{
super(nation, tribe, PeopleType.healer, lifePoints);
myDescription = "\tPerez Healer 2";
}
/**
*
* @param otherPerson
* Reference to opponent
* @return
* Attacks Warriors for extra damage, but heals for less then Healer 1
*/
public int encounterStrategy(Project02.People otherPerson) {
int lifePoints = 0;
if (this.getNation() != otherPerson.getNation()) // not from the same nation
{
if (otherPerson.getType() == PeopleType.warrior) // attack warrior for more damage then others
{
lifePoints = (this.getLifePoints()/3);
}
else // attack a wizard or healer
{
lifePoints = (int) (this.getLifePoints()/4);
}
}
else // from the same nation
{
if (otherPerson.getLifePoints() < this.getLifePoints()) // heal a friend if less health
{
lifePoints = (int) (-this.getLifePoints() / 5);
}
}
return lifePoints;
}
}