-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTribe.java
More file actions
executable file
·167 lines (132 loc) · 4.52 KB
/
Tribe.java
File metadata and controls
executable file
·167 lines (132 loc) · 4.52 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package Project02;
import java.util.ArrayList;
/**
* This class involves everything that within the tribes of each nation
*/
public class Tribe
{
private String nationName;
private String tribeName;
private int tribeLifePoints;
private ArrayList<Project02.People> members = new ArrayList<>();
private ArrayList<Project02.People> livingMembers = new ArrayList<>();
/**
* This class allows us to know the names of each nation, each tribe, and how many
* lifePoints are there.
* @param nation
* @param tribe
* @param lifePoints
*/
public Tribe(String nation, String tribe, int lifePoints)
{
nationName = nation;
tribeName = tribe;
tribeLifePoints = lifePoints;
if (nationName == "Artifacts"){
members.add(new Project02.TrainArtifact(nationName, tribeName, tribeLifePoints));
members.add(new Project02.PoisonArtifact(nationName, tribeName, tribeLifePoints));
members.add(new Project02.ShieldArtifact(nationName, tribeName, tribeLifePoints));
members.add(new Project02.BoobyTrapArtifact(nationName, tribeName, tribeLifePoints));
}
for(int i = 0; i < 5; i++)
if(i % 2 == 0) {
if (nationName == "CoryNation") {
members.add(new Project02.CoryWarrior1(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.CoryWizard1(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.CoryHealer1(nationName, tribeName, tribeLifePoints / 6));
}
if (nationName == "RobertNation") {
members.add(new Project02.RobertWarrior(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.RobertWizard(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.RobertHealer(nationName, tribeName, tribeLifePoints / 6));
}
if (nationName == "BenNation"){
members.add(new Project02.BenWarrior1(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.BenWizard1(nationName, tribeName, tribeLifePoints / 6));
members.add(new Project02.BenHealer1(nationName, tribeName, tribeLifePoints / 6));
}
}
for(int i = 0; i < members.size(); i++)
livingMembers.addAll(members);
}
/**
* Manages the list of the livingTribeMembers.
* @return livingMembers
*/
public ArrayList<Project02.People> getLivingTribeMembers()
{
livingMembers.clear();
tribeLifePoints = 0;
for(int person = 0; person < members.size(); person++)
{
if(members.get(person).isPersonAlive())
{
livingMembers.add(members.get(person));
tribeLifePoints += members.get(person).getLifePoints();
//System.out.println(members.get(person));
}
else
{
if(!(members.get(person).getDead()))
{
members.get(person).setDead();
System.out.println("\t\t" + members.get(person) + " is dead!");
}
}
}
//System.out.println(livingMembers);
return livingMembers;
}
/*
public void printMembers()
{
for(int i = 0; i < 2; i++)
{
System.out.println(people.get(i));
}
}
*/
/**
* Manages how many people are in the tribe.
* @return the number of living members of the tribe
*/
public int getTribeSize()
{
return livingMembers.size();
}
/**
* Manages if the tribe member alive
* @return tribeLifePoints greater than zero
*/
public Boolean isTribeAlive()
{
return (tribeLifePoints > 0);
}
/**
* Manages how many life points the tribe has
* @return the tribes life points
*/
public int getTribeLifePoints()
{
return tribeLifePoints;
}
/**
* Manages the name of the tribe
* @return name of the tribe
*/
public String getTribeName()
{
return tribeName;
}
public String toString()
{
String result = "\0";
result = tribeName;
for(int i = 0; i < members.size(); i++)
{
result = result + '\n' + members.get(i).toString();
}
result = result + '\n';
return result;
}
}