-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatReader.java
144 lines (133 loc) · 3.76 KB
/
StatReader.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
134
135
136
137
138
139
140
141
142
143
144
package statCalculator;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class StatReader {
private boolean isAdvanced = false;
private Player modify;
public StatReader() {
}
public StatReader(String input, Division division) throws FileNotFoundException {
FileReader reader = new FileReader(input);
Scanner scan = new Scanner(reader);
if(isAdvanced == false) {
while(scan.hasNextLine()) {
String team = scan.next();
String player = scan.next();
Team cur = new Team(team);
if(division.containsTeam(team) == false) {
Team toAdd = new Team(team);
division.addTeam(toAdd);
cur = division.findTeam(team);
}
else {
cur = division.findTeam(team);
}
if(cur.containsPlayer(player) == false) {
Player pToAdd = new Player(cur,player);
cur.addPlayer(pToAdd);
modify = cur.findPlayer(player);
int kills = scan.nextInt();
double deaths = scan.nextDouble();
modify.addKills(kills);
modify.addDeaths(deaths);
}
else {
modify = cur.findPlayer(player);
int kills = scan.nextInt();
double deaths = scan.nextDouble();
modify.addKills(kills);
modify.addDeaths(deaths);
}
}
scan.close();
}
if(isAdvanced == true) {
while(scan.hasNextLine()) {
String team = scan.next();
String player = scan.next();
String gameMode = scan.next();
Team cur = new Team(team);
if(division.containsTeam(team) == false) {
Team toAdd = new Team(team);
division.addTeam(toAdd);
cur = division.findTeam(team);
}
else {
cur = division.findTeam(team);
}
if(cur.containsPlayer(player) == false) {
Player pToAdd = new Player(cur,player);
cur.addPlayer(pToAdd);
modify = cur.findPlayer(player);
if(gameMode.equals("HP")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int hpTime = scan.nextInt();
modify.addHpGame();
modify.addHardpointKills(kills);
modify.addHardpointDeaths(deaths);
}
if(gameMode.equals("SND")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int plants = scan.nextInt();
int firstBloods = scan.nextInt();
modify.addSearchKills(kills);
modify.addSearchDeaths(deaths);
modify.addPlant(plants);
modify.addFirstBlood(firstBloods);
modify.addSNDGames();
}
if(gameMode.equals("CTF")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int captures = scan.nextInt();
modify.addCTFKills(kills);
modify.addCTFDeaths(deaths);
modify.addCapture(captures);
modify.addCTFGames();
}
}
else {
modify = cur.findPlayer(player);
if(gameMode.equals("HP")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int hpTime = scan.nextInt();
modify.addHpGame();
modify.addHardpointKills(kills);
modify.addHardpointDeaths(deaths);
}
if(gameMode.equals("SND")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int plants = scan.nextInt();
int firstBloods = scan.nextInt();
modify.addSearchKills(kills);
modify.addSearchDeaths(deaths);
modify.addPlant(plants);
modify.addFirstBlood(firstBloods);
modify.addSNDGames();
}
if(gameMode.equals("CTF")) {
int kills = scan.nextInt();
double deaths = scan.nextDouble();
int captures = scan.nextInt();
modify.addCTFKills(kills);
modify.addCTFDeaths(deaths);
modify.addCapture(captures);
modify.addCTFGames();
}
}
}
scan.close();
}
}
public void setAdvancedTrue() {
isAdvanced = true;
}
public void setAdvancedFalse() {
isAdvanced = false;
}
}