forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PerezWizard.java
56 lines (47 loc) · 1.6 KB
/
PerezWizard.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
package Project02;
public class PerezWizard extends Project02.People
{
PerezWizard(String nation, String tribe, int lifePoints)
{
super(nation, tribe, PeopleType.wizard, lifePoints);
myDescription = "\tPerez Wizard";
}
/**
*
* @param otherPerson
* Reference to opponent
* @return
* Attacks warriors for extra damage
*
* Small heal for allies from the same tribe, bonus if they are a wizard or healer
*/
public int encounterStrategy(Project02.People otherPerson) {
int lifePoints = 0;
if (this.getNation() != otherPerson.getNation()) // if they are not from the same nation
{
if (otherPerson.getType() == PeopleType.warrior) // attack warrior for more damage
{
lifePoints = (this.getLifePoints() /3);
} else // attack a wizard or healer
{
lifePoints = (int) (this.getLifePoints() / 5);
}
}
else // same nation
{
if (otherPerson.getTribe().equals(this.getTribe())) // same tribe
{
if (otherPerson.getType() == PeopleType.wizard ||
otherPerson.getType() == PeopleType.healer ) // small heal for other wizards or healers
{
lifePoints = -(this.getLifePoints() / 3);
}
else // small heal for warrior of same tribe
lifePoints = -(this.getLifePoints() / 5);
}
else
lifePoints = 0;
}
return lifePoints;
}
}