Improve/fix messaging when multiple teams win
authorWuzzy <Wuzzy2@mail.ru>
Wed, 21 Feb 2018 15:05:50 +0100
changeset 13052 eadf8259306f
parent 13051 eb9f9608158b
child 13053 9dd724e8d620
Improve/fix messaging when multiple teams win
hedgewars/uTeams.pas
hedgewars/uTypes.pas
share/hedgewars/Data/Locale/de.txt
share/hedgewars/Data/Locale/en.txt
--- a/hedgewars/uTeams.pas	Wed Feb 21 03:08:19 2018 +0100
+++ b/hedgewars/uTeams.pas	Wed Feb 21 15:05:50 2018 +0100
@@ -54,7 +54,8 @@
 
 function CheckForWin: boolean;
 var AliveClan: PClan;
-    s, ts, cap: ansistring;
+    s, cap: ansistring;
+    ts: array[0..(cMaxTeams - 1)] of ansistring;
     t, AliveCount, i, j: LongInt;
 begin
 CheckForWin:= false;
@@ -90,33 +91,34 @@
         begin
         with AliveClan^ do
             begin
-            ts:= ansistring(Teams[0]^.TeamName);
-            if TeamsNumber = 1 then // team wins
+            if TeamsNumber = 1 then // single team wins
                 begin
-                s:= FormatA(trmsg[sidWinner], ts);
-                cap:= FormatA(GetEventString(eidRoundWin), ts);
+                s:= ansistring(Teams[0]^.TeamName);
+                // Victory caption is randomly selected
+                cap:= FormatA(GetEventString(eidRoundWin), s);
                 AddCaption(cap, cWhiteColor, capgrpGameState);
+                s:= FormatA(trmsg[sidWinner], s);
                 end
-            else // clan wins
+            else // clan with at least 2 teams wins
                 begin
                 s:= '';
                 for j:= 0 to Pred(TeamsNumber) do
                     begin
-                    (*
-                    Currently, the game result string is just the victory
-                    string concatenated multiple times. This assumes that
-                    sidWinner is a complete sentence.
-                    This might not work well for some languages.
+                    ts[j] := Teams[j]^.TeamName;
+                    end;
 
-                    FIXME/TODO: Add event strings for 2, 3, 4 and >4 teams winning.
-                                 This requires FormatA to work with multiple parameters. *)
-                    ts:= Teams[j]^.TeamName;
-                    s:= s + ' ' + FormatA(trmsg[sidWinner], ts);
+                // Write victory message for caption and stats page
+                if (TeamsNumber = cMaxTeams) or (TeamsCount = TeamsNumber) then
+                    // No enemies for some reason … Everyone wins!!1!
+                    s:= trmsg[sidWinnerAll]
+                else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then
+                    // List all winning teams in a list
+                    s:= FormatA(trmsg[TMsgStrId(Ord(sidWinner2) + (TeamsNumber - 2))], ts);
 
-                    // FIXME: Show victory captions one-by-one, not all at once
-                    cap:= FormatA(GetEventString(eidRoundWin), ts);
-                    AddCaption(cap, cWhiteColor, capgrpGameState);
-                    end;
+                // The winner caption is the same as the stats message and not randomized
+                cap:= s;
+                AddCaption(cap, cWhiteColor, capgrpGameState);
+                // TODO (maybe): Show victory animation/captions per-team instead of all winners at once?
                 end;
 
             for j:= 0 to Pred(TeamsNumber) do
--- a/hedgewars/uTypes.pas	Wed Feb 21 03:08:19 2018 +0100
+++ b/hedgewars/uTypes.pas	Wed Feb 21 15:05:50 2018 +0100
@@ -470,7 +470,9 @@
             sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady,
             sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce,
             sidMute, sidAFK, sidAutoCameraOff, sidAutoCameraOn, sidPressTarget,
-            sidNotAvailableInSD, sidHealthGain, sidEmptyCrate, sidUnknownKey);
+            sidNotAvailableInSD, sidHealthGain, sidEmptyCrate, sidUnknownKey,
+            sidWinner2, sidWinner3, sidWinner4, sidWinner5, sidWinner6,
+            sidWinner7, sidWinnerAll);
 
     // Events that are important for the course of the game or at least interesting for other reasons
     TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
--- a/share/hedgewars/Data/Locale/de.txt	Wed Feb 21 03:08:19 2018 +0100
+++ b/share/hedgewars/Data/Locale/de.txt	Wed Feb 21 15:05:50 2018 +0100
@@ -94,6 +94,13 @@
 01:27=+%1
 01:28=Leer!
 01:29=Unbekannte Taste
+01:30=%1 und %2 gewinnen!
+01:31=%1, %2 und %3 gewinnen!
+01:32=%1, %2, %3 und %4 gewinnen!
+01:33=%1, %2, %3, %4 und %5 gewinnen!
+01:34=%1, %2, %3, %4, %5 und %6 gewinnen!
+01:35=%1, %2, %3, %4, %5, %6 und %7 gewinnen!
+01:36=Alle gewinnen!
 
 ; Event messages
 ; Hog (%1) died
@@ -335,7 +342,7 @@
 02:02=Jetzt geht's los!
 02:02=Auf geht's!
 
-; Round ends and team/clan (%1) wins
+; Round ends and team (%1) wins
 02:03=%1 gewinnt!
 02:03=%1 ist der Champion
 02:03=%1 ist der Sieger!
--- a/share/hedgewars/Data/Locale/en.txt	Wed Feb 21 03:08:19 2018 +0100
+++ b/share/hedgewars/Data/Locale/en.txt	Wed Feb 21 15:05:50 2018 +0100
@@ -94,6 +94,13 @@
 01:27=+%1
 01:28=Empty!
 01:29=Unknown key
+01:30=%1 and %2 win!
+01:31=%1, %2 and %3 win!
+01:32=%1, %2, %3 and %4 win!
+01:33=%1, %2, %3, %4 and %5 win!
+01:34=%1, %2, %3, %4, %5 and %6 win!
+01:35=%1, %2, %3, %4, %5, %6 and %7 win!
+01:36=Everyone wins!
 
 ; Event messages
 ; Normal hog (%1) died (0 health)
@@ -309,7 +316,7 @@
 02:02=Have no fear!
 02:02=Be brave and conquer
 
-; Round ends and a team/clan (%1) wins
+; Round ends and a team (%1) wins
 02:03=%1 wins!
 02:03=%1 is the champion!
 02:03=%1 is the winner!