ASA moon02: Add finishing times in ranking
authorWuzzy <Wuzzy2@mail.ru>
Mon, 14 Jan 2019 06:17:35 +0100
changeset 14577 221380cdee7e
parent 14576 2087e50e03e2
child 14578 50f511588635
ASA moon02: Add finishing times in ranking
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Mon Jan 14 05:58:07 2019 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Mon Jan 14 06:17:35 2019 +0100
@@ -41,6 +41,10 @@
 		{x = 3850,y = 1940, turnTime = 20000},
 	}
 }
+local runnerTimeTotal = 0
+for i=1, #runner.places do
+	runnerTimeTotal = runnerTimeTotal + runner.places[i].turnTime
+end
 -- teams
 local teamA = {
 	name = loc("Hog Solo"),
@@ -234,11 +238,7 @@
 		AddAnim(dialog02)
 
 		-- Update time record
-		local baseTime = 0
-		for i=1, #runner.places do
-			baseTime = baseTime + runner.places[i].turnTime
-		end
-		winningTime = baseTime - TurnTimeLeft
+		winningTime = runnerTimeTotal - TurnTimeLeft
 		SetTeamLabel(teamA.name, string.format(loc("%.3fs"), winningTime/1000))
 		SendStat(siCustomAchievement, string.format(loc("You have managed to catch the blue hedgehog in %.3f seconds."), winningTime/1000))
 		if record ~= nil and winningTime >= record then
@@ -278,14 +278,19 @@
 	SendStat(siCustomAchievement, loc("The time that you have left when you reach the blue hedgehog will be added to the next turn."))
 	SendStat(siCustomAchievement, loc("Each turn you'll have only one rope to use."))
 	SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up."))
-	sendSimpleTeamRankings({teamB.name, teamA.name})
+	SendStat(siPointType, loc("milliseconds"))
+	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
+	SendStat(siPlayerKills, tostring(GetTeamStats(teamA.name).Kills), teamA.name)
 	EndGame()
 end
 
 function win()
 	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
 	-- siCustomAchievements were added earlier
-	sendSimpleTeamRankings({teamA.name, teamB.name})
+	SendStat(siPointType, loc("milliseconds"))
+	SendStat(siPlayerKills, tostring(winningTime), teamA.name)
+	SendStat(siPointType, loc("milliseconds"))
+	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
 	SaveCampaignVar("Mission13Won", "true")
 	checkAllMissionsCompleted()
 	EndGame()