if (chosen_category === 'general') {
rows = make_table_general(players);
} else if (chosen_category === 'pulls') {
- console.log("PULL STATS");
- for (const [q,p] of Object.entries(players)) {
- if (p.pulls === 0) {
- continue;
- }
- let sum_time = 0;
- for (const t of p.pull_times) {
- sum_time += t;
- }
- let avg_time = 1e-3 * sum_time / p.pulls;
- let msg = p.name + ' did ' + p.pulls + ' pull(s), ' + p.oob_pulls + ' OOB';
- if (p.oob_pulls < p.pulls) {
- msg += ', avg. hangtime ' + avg_time.toFixed(1) + ' sec for others';
- }
- console.log(msg, p.pull_times);
- }
+ rows = make_table_pulls(players);
}
document.getElementById('stats').replaceChildren(...rows);
}
}
return rows;
}
+
+function make_table_pulls(players) {
+ let rows = [];
+ {
+ let header = document.createElement('tr');
+ add_cell(header, 'th', 'Player');
+ add_cell(header, 'th', 'Pulls');
+ add_cell(header, 'th', 'OOB pulls');
+ add_cell(header, 'th', 'Avg. hang time (IB)');
+ rows.push(header);
+ }
+ for (const [q,p] of Object.entries(players)) {
+ if (p.pulls === 0) {
+ continue;
+ }
+ let sum_time = 0;
+ for (const t of p.pull_times) {
+ sum_time += t;
+ }
+ let avg_time = 1e-3 * sum_time / p.pulls;
+ let oob_pct = 100 * p.oob_pulls / p.pulls;
+
+ let row = document.createElement('tr');
+ add_cell(row, 'td', p.name); // TODO: number?
+ add_cell(row, 'td', p.pulls);
+ add_cell(row, 'td', p.oob_pulls + ' (' + oob_pct.toFixed(0) + '%)');
+ if (p.pulls > p.oob_pulls) {
+ add_cell(row, 'td', avg_time.toFixed(1) + ' sec');
+ } else {
+ add_cell(row, 'td', 'N/A');
+ }
+ rows.push(row);
+ }
+ return rows;
+}