--- a/share/hedgewars/Data/Maps/Control/map.lua Fri May 17 02:08:44 2019 +0200
+++ b/share/hedgewars/Data/Maps/Control/map.lua Fri May 17 14:15:40 2019 +0200
@@ -348,6 +348,41 @@
end
+local RankTeams = function(teamList)
+ local teamRank = function(a, b)
+ if a.score ~= b.score then
+ return a.score > b.score
+ else
+ return a.clan > b.clan
+ end
+ end
+ table.sort(teamList, teamRank)
+ local rank, plusRank, score, clan
+ for i=1, #teamList do
+ if i == 1 then
+ rank = 1
+ plusRank = 1
+ score = teamList[i].score
+ clan = teamList[i].clan
+ end
+ if (teamList[i].score < score) then
+ rank = rank + plusRank
+ plusRank = 1
+ end
+ if (teamList[i].score == score and teamList[i].clan ~= clan) then
+ plusRank = plusRank + 1
+ end
+ teamList[i].rank = rank
+ score = teamList[i].score
+ clan = teamList[i].clan
+ end
+
+ for i=1, #teamList do
+ SendStat(siPointType, "!POINTS")
+ SendStat(siTeamRank, tostring(teamList[i].rank))
+ SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name)
+ end
+end
function onNewTurn()
@@ -385,15 +420,7 @@
local clan = GetTeamClan(name)
table.insert(teamList, { score = teamScore[teamClan[i]], name = name, clan = clan })
end
- local teamRank = function(a, b)
- return a.score > b.score
- end
- table.sort(teamList, teamRank)
-
- for i=1, #teamList do
- SendStat(siPointType, "!POINTS")
- SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name)
- end
+ RankTeams(teamList)
SendStat(siGraphTitle, loc("Score graph"))
end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Fri May 17 02:08:44 2019 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Fri May 17 14:15:40 2019 +0200
@@ -138,6 +138,42 @@
--flag methods
------------------------
+local RankTeams = function(teamList)
+ local teamRank = function(a, b)
+ if a.score ~= b.score then
+ return a.score > b.score
+ else
+ return a.clan > b.clan
+ end
+ end
+ table.sort(teamList, teamRank)
+ local rank, plusRank, score, clan
+ for i=1, #teamList do
+ if i == 1 then
+ rank = 1
+ plusRank = 1
+ score = teamList[i].score
+ clan = teamList[i].clan
+ end
+ if (teamList[i].score < score) then
+ rank = rank + plusRank
+ plusRank = 1
+ end
+ if (teamList[i].score == score and teamList[i].clan ~= clan) then
+ plusRank = plusRank + 1
+ end
+ teamList[i].rank = rank
+ score = teamList[i].score
+ clan = teamList[i].clan
+ end
+
+ for i=1, #teamList do
+ SendStat(siPointType, "!POINTS")
+ SendStat(siTeamRank, tostring(teamList[i].rank))
+ SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name)
+ end
+end
+
function CheckScore(clanID)
if fCaptures[clanID] == captureLimit then
@@ -165,15 +201,7 @@
local clan = GetTeamClan(name)
table.insert(teamList, { score = fCaptures[clan], name = name, clan = clan })
end
- local teamRank = function(a, b)
- return a.score > b.score
- end
- table.sort(teamList, teamRank)
-
- for i=1, #teamList do
- SendStat(siPointType, "!POINTS")
- SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name)
- end
+ RankTeams(teamList)
if mostCaptures >= 2 then
SendStat(siCustomAchievement, string.format(loc("%s (%s) has captured the flag %d times."), mostCapturesHogName, mostCapturesHogTeam, mostCaptures))
--- a/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua Fri May 17 02:08:44 2019 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua Fri May 17 14:15:40 2019 +0200
@@ -436,11 +436,22 @@
-- Score and stats stuff
local showScore = ""
+ local rank = 0
+ local rankPlus = 1
+ local prevScore
table.sort(teamsSorted, function(team1, team2) return getTeamValue(team1, "Score") > getTeamValue(team2, "Score") end)
for i=1, TeamsCount do
- SendStat(siPointType, "!POINTS")
local score = getTeamValue(teamsSorted[i], "Score")
local deaths = getTeamValue(teamsSorted[i], "DeadHogs")
+ if i == 1 or score < prevScore then
+ rank = rank + rankPlus
+ rankPlus = 1
+ prevScore = score
+ else
+ rankPlus = rankPlus + 1
+ end
+ SendStat(siPointType, "!POINTS")
+ SendStat(siTeamRank, rank)
SendStat(siPlayerKills, score, teamsSorted[i])
showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teamsSorted[i], score, deaths) .. "|"