forked from stjpm09/ClassMelee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClanStats.java
executable file
·66 lines (55 loc) · 1.67 KB
/
ClanStats.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
package clanmelee;
public class ClanStats {
private final int totalClanCount;
private int[] hitPoints;
private int[] playerCounts;
private int[] warriorCounts;
private int[] healerCounts;
public ClanStats(int clanCount) {
this.totalClanCount = clanCount;
this.hitPoints = new int[clanCount];
this.playerCounts = new int[clanCount];
this.warriorCounts = new int[clanCount];
this.healerCounts = new int[clanCount];
}
public void addPlayer(ClanMember p) {
int clanID = p.getClanID();
hitPoints[clanID] += p.getHitPoints();
playerCounts[clanID] += 1;
if (p.getType() == ClanMember.ClanMemberType.HEALER)
healerCounts[clanID] += 1;
else if (p.getType() == ClanMember.ClanMemberType.WARRIOR)
warriorCounts[clanID] += 1;
}
public int getHitPoints(int clanID) {
return hitPoints[clanID];
}
public int getPlayerCount(int clanID) {
return playerCounts[clanID];
}
public int getWarriorCount(int clanID) {
return warriorCounts[clanID];
}
public int getHealerCount(int clanID) {
return healerCounts[clanID];
}
public int getClanCount() {
int clanCount = 0;
for (int i = 0; i < totalClanCount; i++) {
if (playerCounts[i] != 0)
clanCount += 1;
}
return clanCount;
}
public int getWinner() {
int max = 0;
int maxID = 0;
for (int i = 0; i < totalClanCount; i++) {
if (hitPoints[i] > max) {
max = hitPoints[i];
maxID = i;
}
}
return maxID;
}
}