Skip to content

Commit

Permalink
Allow ties to be reported as such in the turns_over_advantage calcula…
Browse files Browse the repository at this point in the history
…tion (fixes #1341)
  • Loading branch information
joeylmaalouf authored and Pentarctagon committed Sep 3, 2018
1 parent 6b5edeb commit 3d481c1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions data/multiplayer/eras.lua
Expand Up @@ -41,7 +41,8 @@ res.turns_over_advantage = function()

local income_factor = 5

local side_num = -1
local winning_sides = {}
local tie = true
local total_score = -1
local side_comparison = ""
local color = "#000000"
Expand Down Expand Up @@ -76,14 +77,23 @@ res.turns_over_advantage = function()
r, g, b, side, income, units, team.gold, total)
if total > total_score then
color = string.format("#%02x%02x%02x", r, g, b)
side_num = side
winning_sides = {side}
tie = false
total_score = total
elseif total == total_score then
table.insert(winning_sides, side)
tie = true
end
end
end
end

side_comparison = side_comparison .. string.format( "\n" .. tostring( _ "<span foreground='%s'>Side %d</span> has the advantage."), color, side_num)
if tie then
local last_winning_side = table.remove(winning_sides)
side_comparison = side_comparison .. string.format( "\n" .. tostring( _ "Sides %s and %d are tied."), table.concat(winning_sides, ", "), last_winning_side)
else
side_comparison = side_comparison .. string.format( "\n" .. tostring( _ "<span foreground='%s'>Side %d</span> has the advantage."), color, winning_sides[1])
end
wesnoth.fire("message", { message = side_comparison, speaker = "narrator", image = "wesnoth-icon.png"})
end
return res

0 comments on commit 3d481c1

Please sign in to comment.