# HG changeset patch # User Wuzzy # Date 1520516867 -3600 # Node ID 75afd374b764af676010261b24872c00203b06c3 # Parent 714f6e5b89fdc693bd2769a7f8d73ce511253016 CTF: Show team scores and score graph in stats screen diff -r 714f6e5b89fd -r 75afd374b764 ChangeLog.txt --- a/ChangeLog.txt Thu Mar 08 13:42:36 2018 +0100 +++ b/ChangeLog.txt Thu Mar 08 14:47:47 2018 +0100 @@ -49,6 +49,7 @@ + Battalion (King Mode): If the king dies, the hogs die normally instead of disappearing + Space Invasion: Add a default Space Invasion game scheme + Capture the Flag: Can now be played with more than 2 clans + + Capture the Flag: Show team scores and score graphi in stats screen + HedgeEditor: Show cursor coordinates in top left corner + Control: Always remove TimeBox and Resurrector * Battalion: Some texts in the mission panel were wrong and misleading diff -r 714f6e5b89fd -r 75afd374b764 share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Thu Mar 08 13:42:36 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Thu Mar 08 14:47:47 2018 +0100 @@ -151,6 +151,24 @@ AddCaption(string.format(loc("Victory for %s!"), GetHogTeamName(CurrentHedgehog)), 0xFFFFFFFF, capgrpGameState) updateScores() end + + -- Calculate team rankings + + local teamList = {} + for i=0, TeamsCount-1 do + local name = GetTeamName(i) + 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, loc("point(s)")) + SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name) + end end end @@ -254,6 +272,19 @@ end +-- Advance the clan score graph by one step +function DrawScores() + local clansUsed = {} + for i=0, TeamsCount-1 do + local team = GetTeamName(i) + local clan = GetTeamClan(team) + if not clansUsed[clan] then + local captures = fCaptures[clan] + SendStat(siClanHealth, captures, team) + clansUsed[clan] = true + end + end +end function FlagThiefDead(gear) @@ -408,7 +439,6 @@ -- Disable Sudden Death WaterRise = 0 HealthDecrease = 0 - end function showCTFMission() @@ -456,12 +486,16 @@ updateScores() + SendStat(siGraphTitle, loc("Score graph")) + SendHealthStatsOff() + SendRankingStatsOff() + end function onNewTurn() - if gameStarted == true then + if gameStarted == true and not gameOver then HandleRespawns() end @@ -474,7 +508,6 @@ if not gameStarted and flagsPlaced == ClansCount then StartTheGame() end - end function onEndTurn() @@ -487,6 +520,10 @@ fSpawnY[clan] = GetY(CurrentHedgehog) end end + + if gameStarted == true then + DrawScores() + end end function onGameTick()