forked from justinszaro/WarringNations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTribe.java
More file actions
executable file
·143 lines (129 loc) · 4.95 KB
/
Tribe.java
File metadata and controls
executable file
·143 lines (129 loc) · 4.95 KB
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
134
135
136
137
138
139
140
141
142
143
import java.util.ArrayList;
/**
* The Tribes are made here using the Nation class. Then the living tribe members can be found using getLivingTribeMembers, as well as
* tribe size, tribe life points, tribe name and if they are alive.
*
* @author Max Schuman, Elizabeth Vicente, Tanishq Iyer, Justin Szaro
* @version 3.0
* @since 2021-04-11
*/
public class Tribe
{
private final String tribeName;
private int tribeLifePoints;
private final ArrayList<People> members = new ArrayList<>();
private final ArrayList<People> livingMembers = new ArrayList<>();
/**
* Tribe function is called in Nation passing. It instantiates the members for the corresponding tribes.
* @param nation - String of the Nation name
* @param tribe - String of Tribe's index (0-2)
* @param lifePoints - Int of the lifepoints - should be 500 be default
*
*/
public Tribe(String nation, String tribe, int lifePoints)
{
tribeName = tribe;
tribeLifePoints = lifePoints;
if (nation.equals("Justin's Nation")) {
members.add(new JustinWarrior1(nation, tribeName, tribeLifePoints / 6));
members.add(new JustinWizard1(nation, tribeName, tribeLifePoints / 6));
members.add(new JustinHealer1(nation, tribeName, tribeLifePoints /6));
}
else if (nation.equals("Maxwell's Nation")) {
members.add(new MaxwellHealer01(nation, tribeName, tribeLifePoints /6));
members.add(new MaxwellWarrior01(nation, tribeName, tribeLifePoints /6));
members.add(new MaxwellWizard01(nation, tribeName, tribeLifePoints /6));
}
else if (nation.equals("Tanishq's Nation")) {
members.add(new TanishqHealer1(nation, tribeName, tribeLifePoints /6));
members.add(new TanishqWarrior1(nation, tribeName, tribeLifePoints /6));
members.add(new TanishqWizard1(nation, tribeName, tribeLifePoints /6));
}
else if (nation.equals("Elizabeth's Nation")) {
members.add(new ElizabethWarrior(nation, tribeName, tribeLifePoints / 6));
members.add(new ElizabethWizard(nation, tribeName, tribeLifePoints / 6));
members.add(new ElizabethHealer(nation, tribeName, tribeLifePoints / 6));
}
else if (nation.equals("Artifact's Nation")) {
//we add our special characters
members.add(new ElizabethArtifact(nation,tribeName, lifePoints / 4));
members.add(new DeathArtifact(nation, tribeName, lifePoints / 4));
members.add(new TheFlashArtifact(nation,tribeName, lifePoints/4));
members.add(new TanishqCurseArtifact(nation, tribeName, lifePoints / 4));
}
for(int i = 0; i < members.size(); i++)
livingMembers.addAll(members);
}
/**
* This checks the Tribe members that are alive.
* The list is cleared and restarted as well as the Tribe's life points
* By loop through, the size of the member list times, check to see if
* the member list as an alive member at the position of person.
* If that person is alive, add them to the livingMembers list and the tribe's
* lifepoints have that member's lifeponts added to it.
* @return the final list of living members
*/
public ArrayList<People> getLivingTribeMembers()
{
livingMembers.clear();
tribeLifePoints = 0;
for (People member : members) {
if (member.isPersonAlive()) {
livingMembers.add(member);
tribeLifePoints += member.getLifePoints();
} else {
if (!(member.getDead())) {
member.setDead();
System.out.println("\t\t" + member + " is dead!");
}
}
}
return livingMembers;
}
/**
* To get the living members of the tribe
* @return the number of people still alive in the tribe.
*/
public int getTribeSize()
{
return livingMembers.size();
}
/**
* Returns a boolean if the tribe have lifepoints left.
* @return Boolean If tribe is alive return true, else return false.
*/
public Boolean isTribeAlive()
{
return (tribeLifePoints > 0);
}
/**
* returns the tribes life points as an integer
* @return tribeLifePoints
*/
public int getTribeLifePoints()
{
return tribeLifePoints;
}
/**
* Returns the tribes name.
* @return tribeName Name of the tribe
*/
public String getTribeName()
{
return tribeName;
}
/**
* Returns a string with the tribes name and its members.
* @return result the properties of the tribe
*/
public String toString()
{
StringBuilder result;
result = new StringBuilder(tribeName);
for (People member : members) {
result.append('\n').append(member.toString());
}
result.append('\n');
return result.toString();
}
}