-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameEvent.pde
88 lines (69 loc) · 2.6 KB
/
GameEvent.pde
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
public class GameEvent {
private int gameId;
private int eventNumber;
private int period;
private String periodClock;
private String score;
private String homeDescription;
private String visitorDescription;
public GameEvent(int gameId, int eventNumber, int period, String periodClock, String score,
String homeDescription, String visitorDescription) {
this.gameId = gameId;
this.eventNumber = eventNumber;
this.period = period;
this.periodClock = periodClock;
this.score = score;
this.homeDescription = homeDescription;
this.visitorDescription = visitorDescription;
}
public int getPeriod() {
return this.period;
}
public String getClock() {
return this.periodClock;
}
public String getScore() {
return this.score;
}
public String getHomeDescription() {
return this.homeDescription;
}
public String getVisitorDescription() {
return this.visitorDescription;
}
public HashMap<String, Float> getDistanceTraveledHomeTeam() {
HashMap<String, Float> distances = new HashMap<String, Float>(5);
FileLoader f = new FileLoader();
for(Player p : GAMES.get(this.gameId).getHomeTeam().getPlayers()) {
if(f.isPlayerInEvent(this.gameId, this.eventNumber, p.getId()))
distances.put(p.getLastName() + " (" + p.getJerseyNumber() + ")",
f.getDistanceTraveled(this.gameId, this.eventNumber, p.getId()));
}
return distances;
}
public HashMap<String, Float> getDistanceTraveledVisitorTeam() {
HashMap<String, Float> distances = new HashMap<String, Float>(5);
FileLoader f = new FileLoader();
for(Player p : GAMES.get(this.gameId).getVisitorTeam().getPlayers()) {
if(f.isPlayerInEvent(this.gameId, this.eventNumber, p.getId()))
distances.put(p.getLastName() + " (" + p.getJerseyNumber() + ")",
f.getDistanceTraveled(this.gameId, this.eventNumber, p.getId()));
}
return distances;
}
public float getDistanceTraveled(Player player) {
return new FileLoader().getDistanceTraveled(this.gameId, this.eventNumber, player.getId());
}
public float getAverageSpeed(Player player) {
return new FileLoader().getAverageSpeed(this.gameId, this.eventNumber, player.getId());
}
public boolean areFramesAvailable() {
return new FileLoader().gameEventExists(this.gameId, this.eventNumber);
}
public ArrayList<GameEventFrame> getEventFrames() {
return new FileLoader().loadGameEventFrames(this.gameId, this.eventNumber);
}
public Game getGame() {
return GAMES.get(this.gameId);
}
}