Skip to content

Commit

Permalink
feat(rushroyale): compute incremental scores
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Sep 23, 2024
1 parent d9e05f1 commit b03694f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions public/views/mp/rushroyale.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@
function updateScore() {
const { sorted_players, active_players } = getSortedPlayers();

const top_score = sorted_players[0].getScore();

sorted_players.forEach((player, idx) => {
player.dom.full_node.classList.remove('first', 'last', 'penultimate');
player.dom.rank_node.classList.remove('first', 'last', 'penultimate');

if (idx > 0) {
const diff = player.getScore() - sorted_players[idx - 1].getScore(); // is always negative!
const diff = top_score - player.getScore();
player.dom.rank_node.querySelector('.diff').textContent =
readableScoreFomatter(diff);
'+' + readableScoreFomatter(diff);
} else {
player.dom.rank_node.querySelector('.diff').textContent = '';
}
Expand All @@ -324,6 +326,7 @@
peek(active_players).dom.full_node.classList.add('last');
peek(active_players).dom.rank_node.classList.add('last');
}

active_players[0].dom.full_node.classList.add('first');
active_players[0].dom.rank_node.classList.add('first');
}
Expand Down Expand Up @@ -356,7 +359,7 @@
if (remainder < cycle_settings.panic) {
leaderboard.classList.remove('warn');
leaderboard.classList.add('panic');
content = `!${content}!`;
content = `! ${content} !`;
} else if (remainder < cycle_settings.warn) {
leaderboard.classList.add('warn');
// content = `! ${content} !`;
Expand Down

0 comments on commit b03694f

Please sign in to comment.