Share ranks across linked games in results

This commit is contained in:
2026-02-05 11:36:14 +01:00
parent a5c39d1263
commit 39cad5da44

View File

@@ -241,11 +241,19 @@ export function renderResults() {
<tbody></tbody>
`;
const tbody = table.querySelector("tbody");
state.results.forEach((r, idx) => {
const rankByRoot = new Map();
let nextRank = 1;
state.results.forEach((r) => {
const root = linkRootId(r);
let rank = rankByRoot.get(root);
if (!rank) {
rank = nextRank++;
rankByRoot.set(root, rank);
}
const medal = rank === 1 ? "🥇" : rank === 2 ? "🥈" : rank === 3 ? "🥉" : `${rank}`;
const row = document.createElement("tr");
const podiumClass = idx === 0 ? "podium podium-1" : idx === 1 ? "podium podium-2" : idx === 2 ? "podium podium-3" : "";
const podiumClass = rank === 1 ? "podium podium-1" : rank === 2 ? "podium podium-2" : rank === 3 ? "podium podium-3" : "";
row.className = podiumClass;
const medal = idx === 0 ? "🥇" : idx === 1 ? "🥈" : idx === 2 ? "🥉" : `${idx + 1}`;
row.innerHTML = `
<td class="rank-cell"><span class="medal">${medal}</span></td>
<td class="game-cell">