ASA, The first stop: Fix team ranking and kills in stats screen (bug 147)
authorWuzzy <almikes@aol.com>
Tue, 26 Sep 2017 16:25:57 +0200
changeset 12537 66566cfe0a7e
parent 12536 e54039ea3934
child 12538 952afc3d2df2
ASA, The first stop: Fix team ranking and kills in stats screen (bug #147)
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Tue Sep 26 16:07:44 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Tue Sep 26 16:25:57 2017 +0200
@@ -183,3 +183,12 @@
 	end
 	return res
 end
+
+-- Send team ranking stats. Teams is a list of teams in the desired order.
+-- The default kills counter is used.
+function sendSimpleTeamRankings(teams)
+	for t=1, #teams do
+		local teamname = teams[t]
+		SendStat(siPlayerKills, GetTeamStats(teamname).Kills, teamname)
+	end
+end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Tue Sep 26 16:07:44 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Tue Sep 26 16:25:57 2017 +0200
@@ -342,8 +342,7 @@
 function heroDeath(gear)
 	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
 	SendStat(siCustomAchievement, loc("You have to get the weapons and rescue the PAotH researchers."))
-	SendStat(siPlayerKills,'1',teamC.name)
-	SendStat(siPlayerKills,'0',teamD.name)
+	sendSimpleTeamRankings({teamC.name, teamB.name, teamD.name, teamA.name})
 	EndGame()
 end
 
@@ -367,8 +366,7 @@
 	AnimCaption(hero.gear, loc("Congrats! You won!"), 6000)
 	saveCompletedStatus(1)
 	SendStat(siGameResult, loc("Hog Solo wins, congratulations!"))
-	SendStat(siPlayerKills,'1',teamD.name)
-	SendStat(siPlayerKills,'0',teamC.name)
+	sendSimpleTeamRankings({teamD.name, teamA.name, teamC.name, teamB.name})
 	SaveCampaignVar("CosmosCheckPoint", "5") -- hero got fuels
 	resetCheckpoint() -- reset this mission
 	gameOver = true