From 0a5608856ee8f08e7850cc8462532b59e2f414ec Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 26 Nov 2024 04:20:27 +0000 Subject: [PATCH] Fixed bug. --- presidential-election.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/presidential-election.js b/presidential-election.js index 1844de5..ed73854 100644 --- a/presidential-election.js +++ b/presidential-election.js @@ -250,7 +250,6 @@ async function CountVotesAndAwardPresidency() { const voteList = {}; const voteSum = {}; let voteCount = 0; - let validVoteCount = 0; let maxSum = 0; const users = UserCache.GetAllUsersAsFlatList(); for (const user of users) { @@ -267,15 +266,12 @@ async function CountVotesAndAwardPresidency() { voteList[v] = []; } voteCount++; - if (!user.ban_conviction_time) { - validVoteCount++; - voteSum[v] += weight; - voteList[v].push({ color, weight }); - maxSum = Math.max(voteSum[v], maxSum); - } + voteSum[v] += weight; + voteList[v].push({ color, weight }); + maxSum = Math.max(voteSum[v], maxSum); } } - if (!validVoteCount) { + if (!voteCount) { return; } const sortableCandidates = []; @@ -286,6 +282,9 @@ async function CountVotesAndAwardPresidency() { continue; } const cu = UserCache.GetCachedUserByCommissarId(candidate); + if (cu.ban_conviction_time) { + continue; + } sortableCandidates.push({ commissar_id: cu.commissar_id, label: cu.getNickname(), @@ -338,7 +337,7 @@ async function CountVotesAndAwardPresidency() { context.fillStyle = vote.color; const voteWidth = chartWidth * vote.weight / maxSum; if (voteWidth - voteGap < 1) { - const votePixels = Math.max(rightX - x, 1); + const votePixels = Math.max(rightX - voteGap - x, 1); context.fillRect(x, y, votePixels, barHeight); break; } else {