hedgewars/uTeams.pas
changeset 13846 b2cc4e4e380c
parent 13837 10a3b80130b5
child 13869 f68bb13f7bc7
equal deleted inserted replaced
13845:219c2e588874 13846:b2cc4e4e380c
    56 function CheckForWin: boolean;
    56 function CheckForWin: boolean;
    57 var AliveClan: PClan;
    57 var AliveClan: PClan;
    58     s, cap: ansistring;
    58     s, cap: ansistring;
    59     ts: array[0..(cMaxTeams - 1)] of ansistring;
    59     ts: array[0..(cMaxTeams - 1)] of ansistring;
    60     t, AliveCount, i, j: LongInt;
    60     t, AliveCount, i, j: LongInt;
       
    61     allWin, winCamera: boolean;
    61 begin
    62 begin
    62 CheckForWin:= false;
    63 CheckForWin:= false;
    63 AliveCount:= 0;
    64 AliveCount:= 0;
    64 for t:= 0 to Pred(ClansCount) do
    65 for t:= 0 to Pred(ClansCount) do
    65     if ClansArray[t]^.ClanHealth > 0 then
    66     if ClansArray[t]^.ClanHealth > 0 then
    73 CheckForWin:= true;
    74 CheckForWin:= true;
    74 
    75 
    75 TurnTimeLeft:= 0;
    76 TurnTimeLeft:= 0;
    76 ReadyTimeLeft:= 0;
    77 ReadyTimeLeft:= 0;
    77 
    78 
    78 // if the game ends during a multishot, do last TurnStats + TurnReaction
    79 // If the game ends during a multishot, or after the Sudden Death
    79 if (not bBetweenTurns) and isInMultiShoot then
    80 // water has risen, do last turn stats / reaction.
       
    81 if ((not bBetweenTurns) and isInMultiShoot) or (bDuringWaterRise) then
    80     begin
    82     begin
    81     TurnStats();
    83     TurnStats();
    82     TurnReaction();
    84     if (not bDuringWaterRise) then
       
    85         TurnReaction();
    83     TurnStatsReset();
    86     TurnStatsReset();
    84     end;
    87     end;
    85 
    88 
    86 if not TeamsGameOver then
    89 if not TeamsGameOver then
    87     begin
    90     begin
    96             AddVoice(sndNutter, TeamsArray[0]^.voicepack);
    99             AddVoice(sndNutter, TeamsArray[0]^.voicepack);
    97         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000);
   100         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000);
    98         end
   101         end
    99     else // win
   102     else // win
   100         begin
   103         begin
       
   104         allWin:= false;
   101         with AliveClan^ do
   105         with AliveClan^ do
   102             begin
   106             begin
   103             if TeamsNumber = 1 then // single team wins
   107             if TeamsNumber = 1 then // single team wins
   104                 begin
   108                 begin
   105                 s:= ansistring(Teams[0]^.TeamName);
   109                 s:= ansistring(Teams[0]^.TeamName);
   116                     ts[j] := Teams[j]^.TeamName;
   120                     ts[j] := Teams[j]^.TeamName;
   117                     end;
   121                     end;
   118 
   122 
   119                 // Write victory message for caption and stats page
   123                 // Write victory message for caption and stats page
   120                 if (TeamsNumber = cMaxTeams) or (TeamsCount = TeamsNumber) then
   124                 if (TeamsNumber = cMaxTeams) or (TeamsCount = TeamsNumber) then
       
   125                     begin
   121                     // No enemies for some reason … Everyone wins!!1!
   126                     // No enemies for some reason … Everyone wins!!1!
   122                     s:= trmsg[sidWinnerAll]
   127                     s:= trmsg[sidWinnerAll];
       
   128                     allWin:= true;
       
   129                     end
   123                 else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then
   130                 else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then
   124                     // List all winning teams in a list
   131                     // List all winning teams in a list
   125                     s:= FormatA(trmsg[TMsgStrId(Ord(sidWinner2) + (TeamsNumber - 2))], ts);
   132                     if (TeamsNumber = 2) then
       
   133                         s:= FormatA(trmsg[TMsgStrId(sidWinner2)], ts[0], ts[1])
       
   134                     else if (TeamsNumber = 3) then
       
   135                         s:= FormatA(trmsg[TMsgStrId(sidWinner3)], ts[0], ts[1], ts[2])
       
   136                     else if (TeamsNumber = 4) then
       
   137                         s:= FormatA(trmsg[TMsgStrId(sidWinner4)], ts[0], ts[1], ts[2], ts[3])
       
   138                     else if (TeamsNumber = 5) then
       
   139                         s:= FormatA(trmsg[TMsgStrId(sidWinner5)], ts[0], ts[1], ts[2], ts[3], ts[4])
       
   140                     else if (TeamsNumber = 6) then
       
   141                         s:= FormatA(trmsg[TMsgStrId(sidWinner6)], ts[0], ts[1], ts[2], ts[3], ts[4], ts[5])
       
   142                     else if (TeamsNumber = 7) then
       
   143                         s:= FormatA(trmsg[TMsgStrId(sidWinner7)], ts[0], ts[1], ts[2], ts[3], ts[4], ts[5], ts[6]);
   126 
   144 
   127                 // The winner caption is the same as the stats message and not randomized
   145                 // The winner caption is the same as the stats message and not randomized
   128                 cap:= s;
   146                 cap:= s;
   129                 AddCaption(cap, capcolDefault, capgrpGameState);
   147                 AddCaption(cap, capcolDefault, capgrpGameState);
   130                 // TODO (maybe): Show victory animation/captions per-team instead of all winners at once?
   148                 // TODO (maybe): Show victory animation/captions per-team instead of all winners at once?
   131                 end;
   149                 end;
   132 
   150 
       
   151             // Enable winner state for winning hogs and move camera to a winning hedgehog
       
   152             winCamera:= false;
   133             for j:= 0 to Pred(TeamsNumber) do
   153             for j:= 0 to Pred(TeamsNumber) do
   134                 with Teams[j]^ do
   154                 with Teams[j]^ do
   135                     for i:= 0 to cMaxHHIndex do
   155                     for i:= 0 to cMaxHHIndex do
   136                         with Hedgehogs[i] do
   156                         with Hedgehogs[i] do
   137                             if (Gear <> nil) then
   157                             if (Gear <> nil) then
       
   158                                 begin
       
   159                                 if (not winCamera) then
       
   160                                     begin
       
   161                                     FollowGear:= Gear;
       
   162                                     winCamera:= true;
       
   163                                     end;
   138                                 Gear^.State:= gstWinner;
   164                                 Gear^.State:= gstWinner;
       
   165                                 end;
   139             if Flawless then
   166             if Flawless then
   140                 AddVoice(sndFlawless, Teams[0]^.voicepack)
   167                 AddVoice(sndFlawless, Teams[0]^.voicepack)
   141             else
   168             else
   142                 AddVoice(sndVictory, Teams[0]^.voicepack);
   169                 AddVoice(sndVictory, Teams[0]^.voicepack);
   143             end;
   170             end;
   144 
   171 
   145         if SendGameResultOn then
   172         if SendGameResultOn then
   146             SendStat(siGameResult, shortstring(s));
   173             SendStat(siGameResult, shortstring(s));
       
   174         if allWin and SendAchievementsStatsOn then
       
   175             SendStat(siEverAfter, '');
   147         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
   176         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
   148         end;
   177         end;
   149     SendStats;
   178     SendStats;
   150     end;
   179     end;
   151 TeamsGameOver:= true;
   180 TeamsGameOver:= true;