forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NaveedHealer.java
65 lines (61 loc) · 1.87 KB
/
NaveedHealer.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
63
64
65
package Project02;
/**
* The healer heals people from the same nation.
* If the two players are from the same tribe and the other player is the healer,
* the healer can be healed. If other player is not a healer, nothing happens to the
* healer.
* If the two players are not from the same nation, healer can only fight a healer. Healer
* will run away if fighting warrior or wizard.
*/
public class NaveedHealer extends People
{
NaveedHealer(String nation, String tribe, int lifePoints)
{
super(nation, tribe, PeopleType.healer, lifePoints);
myDescription = "\tNaveed Healer";
}
/**
* Returns the lifepoints when encountering other people.
* @param otherPerson
* @return
*/
public int encounterStrategy(People otherPerson)
{
int lifepoints = 0;
// If the two players are from the same nation, heal each other
if((this.getNation().equals(otherPerson.getNation())))
{
// Can only heal by a healer
if(otherPerson.getType().equals(PeopleType.healer))
{
if(this.getLifePoints() < 40)
{
lifepoints = -(this.getLifePoints() / 5);
}
else
{
lifepoints = 0;
}
}
else
{
lifepoints = 0;
}
}
// If the two players are not from the same nation
else
{
// Running away
if(otherPerson.getType().equals(PeopleType.warrior) || otherPerson.getType().equals(PeopleType.wizard))
{
lifepoints = -this.getLifePoints();
}
// Fighting a healer
else
{
lifepoints = (int)(this.getLifePoints() / 2);
}
}
return lifepoints;
}
}