forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNaveedWizard.java
109 lines (105 loc) · 3.15 KB
/
NaveedWizard.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package Project02;
public class NaveedWizard extends People
{
NaveedWizard(String nation, String tribe, int lifePoints)
{
super(nation, tribe, PeopleType.wizard, lifePoints);
myDescription = "\tNaveed Wizard";
}
/**
* Gives the lifepoints to the player
* @param additionalLifepoints
* @return
*/
private int encounterStrategy2(int additionalLifepoints)
{
int lifepoints;
// Checking lifepoints if it is less 100
if(this.getLifePoints() < 40)
{
lifepoints = -(this.getLifePoints() / additionalLifepoints);
}
// Does not add any lifepoints into the player
else
{
lifepoints = 0;
}
return lifepoints;
}
/**
* Checking if the other person type
* @param otherPerson
* @param additionalLifepoints
* @return
*/
private int checkingOtherPeopleType(People otherPerson, int additionalLifepoints)
{
int lifepoints = 0;
// Checking if the other person type is a healer or wizard
if (otherPerson.getType().equals(PeopleType.healer) || otherPerson.getType().equals(PeopleType.wizard))
{
lifepoints = encounterStrategy2(additionalLifepoints);
}
// Checking if the other person is a warrior.
else
{
lifepoints = this.getLifePoints();
}
return lifepoints;
}
/**
* Checking if the two players are from the same nation.
* If not, the players fight each other or the player runs
* away.
* @param otherPerson
* @return
*/
@Override
public int encounterStrategy(People otherPerson)
{
int lifepoints = 0;
// Both players are from the same nation
if(this.getNation().equals(otherPerson.getNation()))
{
// Both players are from the same tribe
if (this.getTribe().equals(otherPerson.getTribe()))
{
lifepoints = checkingOtherPeopleType(otherPerson,10);
}
// Both players are not from the same tribe.
else
{
lifepoints = checkingOtherPeopleType(otherPerson,5);
}
}
// Both players are not from the same nation
else
{
// Fighting against a warrior
if(otherPerson.getType().equals(PeopleType.warrior))
{
// Running away
if (this.getLifePoints() < otherPerson.getLifePoints())
{
lifepoints = -this.getLifePoints();
}
// Fighting a warrior, but losing 15 lifepoints
else
{
lifepoints = this.getLifePoints() / 4;
}
}
// Fighting against a wizard
if (otherPerson.getType().equals(PeopleType.wizard))
{
lifepoints = this.getLifePoints() / 2;
}
// Fighting against a healer
else
{
lifepoints = this.getLifePoints();
}
}
return lifepoints;
}
}