Establish vote count ordering (#997)

* Establish vote count ordering

* Localize vote_count

Yay luacheck
master
Lars Müller 2022-03-16 23:35:33 +01:00 committed by GitHub
parent 2be697e3f6
commit 45b9c4c382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 11 deletions

View File

@ -105,17 +105,19 @@ function ctf_modebase.mode_vote.end_vote()
local votes_result = ""
local average_vote = 0
local entry_count = 0
for length, vote_count in pairs(length_votes) do
votes_result = votes_result .. string.format(
" %d vote%s for %d match%s\n",
vote_count,
vote_count == 1 and "" or "s",
length,
length == 1 and "" or "es"
)
entry_count = entry_count + vote_count
average_vote = average_vote + (length * vote_count)
for length = 1, MAX_ROUNDS do
local vote_count = length_votes[length]
if vote_count then
votes_result = votes_result .. string.format(
" %d vote%s for %d match%s\n",
vote_count,
vote_count == 1 and "" or "s",
length,
length == 1 and "" or "es"
)
entry_count = entry_count + vote_count
average_vote = average_vote + (length * vote_count)
end
end
if entry_count > 0 then