forked from rabinovichr/Project02
-
Notifications
You must be signed in to change notification settings - Fork 0
/
People.java
executable file
·134 lines (120 loc) · 2.93 KB
/
People.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package Project02;
/**
* Used to store, set, and get various values for individual player characters.
*
* It is also used to change each characters life point value, and determine whether or not a player is still alive.
*
* getDescription = player type (healer, warrior, or wizard)
*/
public abstract class People
{
private String personName;
private String myNation;
private String myTribe;
private PeopleType me;
protected String myDescription;
private int myLifePoints;
private boolean dead;
public final int MAX_LIFEPOINTS = 100;
/**
* @param nation
* Stores the String name of a nation
* @param tribe
* Stores the String name of a player's tribe
* @param person
* Reference to PeopleType, used to check player type (healer, warrior, wizard)
* @param lifePoints
* Stores life point value of a player
*/
public People(String nation, String tribe, PeopleType person, int lifePoints)
{
myNation = nation;
myTribe = tribe;
me = person;
myDescription = me.getDescription();
myLifePoints = lifePoints;
dead = false;
}
/**
* Once life points hits 0, sets player as dead
*/
public void setDead()
{
dead = true;
}
/**
* @return
* Returns current dead value for player (True or False)
*/
public boolean getDead()
{
return dead;
}
/**
* @return
* Gets player type
*/
public PeopleType getType()
{
return me;
}
/**
* @return
* Gets player tribe
*/
public String getTribe()
{
return myTribe;
}
/**
* @return
* Gets player nation
*/
public String getNation()
{
return myNation;
}
/**
* @return
* Check if player life point value is greater then 0
*/
public Boolean isPersonAlive()
{
return (myLifePoints > 0);
}
/**
* @return
* Get current life point value
*/
public int getLifePoints()
{
return myLifePoints;
}
/**
* @param points
* If current life point value exceeds max life points, set it back to the max.
*/
public void modifyLifePoints(int points) {
myLifePoints += points;
if(myLifePoints > MAX_LIFEPOINTS){
myLifePoints = MAX_LIFEPOINTS;
}
}
/**
* @param otherPerson
* Reference to opponent
* @return
* abstract for PlayerType (ex: PerezHealer) classes
*/
public abstract int encounterStrategy(People otherPerson);
/**
* @return
* returns a String profile of the player (nation, tribe, player name, player type, and their remaining life points.
*/
public String toString()
{
String result = new String( myNation + "\t" + myTribe + "\t" + me
+ "\t" + myDescription + "\t" + myLifePoints + " ");
return result;
}
}