'offensive_points_completed': 0,
'offensive_points_won': 0,
+ 'clean_holds': 0,
+
'defensive_points_completed': 0,
'defensive_points_won': 0,
+ 'clean_breaks': 0,
+
+ 'turnovers_won': 0,
+ 'turnovers_lost': 0,
+ 'their_clean_holds': 0,
+ 'their_clean_breaks': 0,
};
let globals = players['globals'];
let current_predominant_gender = null;
let current_num_players_on_field = null;
+ let we_lost_disc = false;
+ let they_lost_disc = false;
+
// The last used formations of the given kind, if any; they may be reused
// when the point starts, if nothing else is set.
let last_offensive_formation = null;
last_pull_was_ours = !offense;
between_points = false;
} else if (type === 'goal' || type === 'their_goal' || type === 'stoppage') {
+ if (type === 'goal') {
+ if (keep) ++p.touches;
+ }
for (const [q,p] of Object.entries(players)) {
if (p.on_field_since === null) {
continue;
// Score management
if (type === 'goal') {
++our_score;
- between_points = true;
} else if (type === 'their_goal') {
++their_score;
- between_points = true;
}
// Point count management
puller = pull_started = null;
}
+ // Stats for clean holds or not (must be done before resetting we_lost_disc etc. below).
+ if (keep) {
+ if (type === 'goal' && !we_lost_disc) {
+ if (last_pull_was_ours === false) { // O point.
+ ++globals.clean_holds;
+ } else if (last_pull_was_ours === true) {
+ ++globals.clean_breaks;
+ }
+ } else if (type === 'their_goal' && !they_lost_disc) {
+ if (last_pull_was_ours === true) { // O point for them.
+ ++globals.their_clean_holds;
+ } else if (last_pull_was_ours === false) {
+ ++globals.their_clean_breaks;
+ }
+ }
+ }
+
// Offense/defense management
let last_offense = offense;
if (type === 'set_defense' || type === 'goal' || type === 'throwaway' || type === 'drop' || type === 'was_d' || type === 'stallout') {
offense = false;
+ we_lost_disc = true;
+ if (keep && type !== 'goal' && !(type === 'set_defense' && last_pull_was_ours === null)) {
+ ++globals.turnovers_lost;
+ }
} else if (type === 'set_offense' || type === 'their_goal' || type === 'their_throwaway' || type === 'defense' || type === 'interception') {
offense = true;
+ they_lost_disc = true;
+ if (keep && type !== 'their_goal' && !(type === 'set_offense' && last_pull_was_ours === null)) {
+ ++globals.turnovers_won;
+ }
+ }
+ if (type === 'goal' || type === 'their_goal') {
+ between_points = true;
+ we_lost_disc = false;
+ they_lost_disc = false;
}
if (last_offense !== offense && live_since !== null) {
// Switched offense/defense status, so attribute this drive as needed,
rows = make_table_playing_time(players);
} else if (chosen_category === 'per_point') {
rows = make_table_per_point(players);
+ } else if (chosen_category === 'team_wide') {
+ rows = make_table_team_wide(players);
}
rowsets.push(rows);
}
return 'playing_time';
} else if (window.location.hash === '#per_point') {
return 'per_point';
+ } else if (window.location.hash === '#team_wide') {
+ return 'team_wide';
} else {
return 'general';
}
function write_main_menu(chosen_category) {
let elems = [];
- if (chosen_category === 'general') {
- let span = document.createElement('span');
- span.innerText = 'General';
- elems.push(span);
- } else {
- let a = document.createElement('a');
- a.appendChild(document.createTextNode('General'));
- a.setAttribute('href', '#general');
- elems.push(a);
- }
-
- if (chosen_category === 'offense') {
- let span = document.createElement('span');
- span.innerText = 'Offense';
- elems.push(span);
- } else {
- let a = document.createElement('a');
- a.appendChild(document.createTextNode('Offense'));
- a.setAttribute('href', '#offense');
- elems.push(a);
- }
-
- if (chosen_category === 'defense') {
- let span = document.createElement('span');
- span.innerText = 'Defense';
- elems.push(span);
- } else {
- let a = document.createElement('a');
- a.appendChild(document.createTextNode('Defense'));
- a.setAttribute('href', '#defense');
- elems.push(a);
- }
-
- if (chosen_category === 'playing_time') {
- let span = document.createElement('span');
- span.innerText = 'Playing time';
- elems.push(span);
- } else {
- let a = document.createElement('a');
- a.appendChild(document.createTextNode('Playing time'));
- a.setAttribute('href', '#playing_time');
- elems.push(a);
- }
-
- if (chosen_category === 'per_point') {
- let span = document.createElement('span');
- span.innerText = 'Per point';
- elems.push(span);
- } else {
- let a = document.createElement('a');
- a.appendChild(document.createTextNode('Per point'));
- a.setAttribute('href', '#per_point');
- elems.push(a);
+ const categories = [
+ ['general', 'General'],
+ ['offense', 'Offense'],
+ ['defense', 'Defense'],
+ ['playing_time', 'Playing time'],
+ ['per_point', 'Per point'],
+ ['team_wide', 'Team-wide'],
+ ];
+ for (const [id, title] of categories) {
+ if (chosen_category === id) {
+ let span = document.createElement('span');
+ span.innerText = title;
+ elems.push(span);
+ } else {
+ let a = document.createElement('a');
+ a.appendChild(document.createTextNode(title));
+ a.setAttribute('href', '#' + id);
+ elems.push(a);
+ }
}
document.getElementById('mainmenu').replaceChildren(...elems);
return rows;
}
+function make_table_team_wide(players) {
+ let globals = players['globals'];
+
+ let rows = [];
+ {
+ let header = document.createElement('tr');
+ add_th(header, '');
+ add_th(header, 'Our team', 6);
+ add_th(header, 'Opponents', 6);
+ rows.push(header);
+ }
+
+ // Turnovers.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Turnovers generated', 'name');
+ add_3cell(row, '');
+ add_3cell(row, globals.turnovers_won);
+ add_3cell(row, '');
+ add_3cell(row, globals.turnovers_lost);
+ rows.push(row);
+ }
+
+ // Clean holds.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Clean holds', 'name');
+ let our_clean_holds = make_binomial_ci(globals.clean_holds, globals.offensive_points_completed, z);
+ let their_clean_holds = make_binomial_ci(globals.their_clean_holds, globals.defensive_points_completed, z);
+ our_clean_holds.desired = 0.3; // Arbitrary.
+ our_clean_holds.format = 'percentage';
+ their_clean_holds.desired = 0.3;
+ their_clean_holds.format = 'percentage';
+ add_3cell(row, globals.clean_holds + ' / ' + globals.offensive_points_completed);
+ add_3cell_ci(row, our_clean_holds);
+ add_3cell(row, globals.their_clean_holds + ' / ' + globals.defensive_points_completed);
+ add_3cell_ci(row, their_clean_holds);
+ rows.push(row);
+ }
+
+ // Clean breaks.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Clean breaks', 'name');
+ let our_clean_breaks = make_binomial_ci(globals.clean_breaks, globals.defensive_points_completed, z);
+ let their_clean_breaks = make_binomial_ci(globals.their_clean_breaks, globals.offensive_points_completed, z);
+ our_clean_breaks.desired = 0.3; // Arbitrary.
+ our_clean_breaks.format = 'percentage';
+ their_clean_breaks.desired = 0.3;
+ their_clean_breaks.format = 'percentage';
+ add_3cell(row, globals.clean_breaks + ' / ' + globals.defensive_points_completed);
+ add_3cell_ci(row, our_clean_breaks);
+ add_3cell(row, globals.their_clean_breaks + ' / ' + globals.offensive_points_completed);
+ add_3cell_ci(row, their_clean_breaks);
+ rows.push(row);
+ }
+
+ return rows;
+}
+
function make_table_offense(players) {
let rows = [];
{