let globals = players['globals'];
for (const match of json['matches']) {
+ let our_score = 0;
+ let their_score = 0;
let handler = null;
let prev_handler = null;
let live_since = null;
// Liveness management
if (type === 'pull' || type === 'their_pull' || type === 'restart') {
live_since = t;
+ } else if (type === 'catch' && last_pull_was_ours === null) {
+ // Someone forgot to add the pull, so we'll need to wing it.
+ console.log('Missing pull on ' + our_score + '\u2013' + their_score + ' in ' + match['description'] + '; pretending to have one.');
+ live_since = t;
+ last_pull_was_ours = !offense;
} else if (type === 'goal' || type === 'their_goal' || type === 'stoppage') {
for (const [q,p] of Object.entries(players)) {
if (p.on_field_since === null) {
continue;
}
- if (p.last_point_seen !== point_num) {
+ if (type !== 'stoppage' && p.last_point_seen !== point_num) {
// In case the player did nothing this point,
// not even subbing in.
p.last_point_seen = point_num;
}
attribute_player_time(p, t, live_since);
+ if (type !== 'stoppage') {
+ if (last_pull_was_ours === true) { // D point.
+ ++p.defensive_points_completed;
+ if (type === 'goal') {
+ ++p.defensive_points_won;
+ }
+ } else if (last_pull_was_ours === false) { // O point.
+ ++p.offensive_points_completed;
+ if (type === 'goal') {
+ ++p.offensive_points_won;
+ }
+ }
+ }
+ }
+
+ if (type !== 'stoppage') {
+ // Update globals.
+ ++globals.points_played;
if (last_pull_was_ours === true) { // D point.
- ++p.defensive_points_completed;
+ ++globals.defensive_points_completed;
if (type === 'goal') {
- ++p.defensive_points_won;
+ ++globals.defensive_points_won;
}
} else if (last_pull_was_ours === false) { // O point.
- ++p.offensive_points_completed;
+ ++globals.offensive_points_completed;
if (type === 'goal') {
- ++p.offensive_points_won;
+ ++globals.offensive_points_won;
}
}
}
-
- // Update globals.
- ++globals.points_played;
if (live_since !== null) {
globals.playing_time_ms += t - live_since;
}
- if (last_pull_was_ours === true) { // D point.
- ++globals.defensive_points_completed;
- if (type === 'goal') {
- ++globals.defensive_points_won;
- }
- } else if (last_pull_was_ours === false) { // O point.
- ++globals.offensive_points_completed;
- if (type === 'goal') {
- ++globals.offensive_points_won;
- }
- }
+
live_since = null;
}
+ // Score management
+ if (type === 'goal') {
+ ++our_score;
+ } else if (type === 'their_goal') {
+ ++their_score;
+ }
+
// Point count management
if (p !== undefined && type !== 'out' && p.last_point_seen !== point_num) {
p.last_point_seen = point_num;