| ${formatRanking(player.placement)} |
${escapeHtml(player.name)}${player.stats.lollipops > 0 ? `${player.stats.lollipops > 1 ? `π x${player.stats.lollipops}` : 'π'}` : ''} |
${points} |
${Array.isArray(player.stats.shortLegs) && player.stats.shortLegs.length > 0 ? player.stats.shortLegs.join(',') : 'β'} |
${Array.isArray(player.stats.highOuts) && player.stats.highOuts.length > 0 ? player.stats.highOuts.join(',') : 'β'} |
${player.stats.oneEighties || 0} |
${player.stats.tons || 0} |
${legs.legsWon} |
${legs.legsLost} |
`;
}).join('');
}
/**
* Calculate legs won/lost for a player from completed matches
*/
function calculatePlayerLegs(playerId) {
let legsWon = 0;
let legsLost = 0;
matches.forEach(match => {
// a qualifier's legs don't count (Docs/QUALIFIERS.md)
if (match.completed && match.finalScore && match.side !== 'qualifier') {
const { winnerLegs, loserLegs, winnerId, loserId } = match.finalScore;
if (winnerId === playerId) {
legsWon += winnerLegs;
legsLost += loserLegs;
} else if (loserId === playerId) {
legsWon += loserLegs;
legsLost += winnerLegs;
}
}
});
return { legsWon, legsLost };
}
/**
* Placement β the point setting it earns. 5th-6th and 7th-8th are shared places, stored
* as 5 and 7; 6 and 8 map the same way.
* @type {Object