Control (style): Implement proper ranking screen and score graph
authorWuzzy <Wuzzy2@mail.ru>
Fri, 17 May 2019 01:55:37 +0200
changeset 14985 851f1687439d
parent 14984 6e17abf7b8ef
child 14986 d09208b34713
Control (style): Implement proper ranking screen and score graph
share/hedgewars/Data/Maps/Control/map.lua
--- a/share/hedgewars/Data/Maps/Control/map.lua	Fri May 17 01:16:14 2019 +0200
+++ b/share/hedgewars/Data/Maps/Control/map.lua	Fri May 17 01:55:37 2019 +0200
@@ -178,10 +178,15 @@
 		end
 	end
 
-	-- Update team labels
+	-- Update team labels and graph
+	local clanGraphPointWritten = {}
 	for i = 0,(TeamsCount-1) do
 		if teamNameArr[i] ~= " " then
 			SetTeamLabel(teamNameArr[i], teamScore[teamClan[i]])
+			if not clanGraphPointWritten[teamClan[i]] then
+				SendStat(siClanHealth, teamScore[teamClan[i]], teamNameArr[i])
+				clanGraphPointWritten[teamClan[i]] = true
+			end
 		end
 	end
 
@@ -275,6 +280,9 @@
 	WaterRise = 0
 	HealthDecrease = 0
 
+	SendHealthStatsOff()
+	SendRankingStatsOff()
+
 end
 
 
@@ -371,7 +379,26 @@
 					end
 				end
 			end
-			SetTurnTimeLeft(1)
+			EndTurn(true)
+
+			-- Rankings
+			local teamList = {}
+			for i=0, TeamsCount-1 do
+				local name = GetTeamName(i)
+				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
+			SendStat(siGraphTitle, loc("Score graph"))
+
 		end
 
 	end