hedgewars/uTeams.pas
changeset 13656 56a925256039
parent 13655 34aeaa627400
child 13657 de2b7bc00d40
equal deleted inserted replaced
13655:34aeaa627400 13656:56a925256039
    49     uGearsUtils, uGearsList, uVisualGearsList, uTextures
    49     uGearsUtils, uGearsList, uVisualGearsList, uTextures
    50     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    50     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    51 
    51 
    52 var TeamsGameOver: boolean;
    52 var TeamsGameOver: boolean;
    53     NextClan: boolean;
    53     NextClan: boolean;
    54     SwapClan: LongInt;
    54     SwapClanPre, SwapClanReal: LongInt;
    55 
    55 
    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;
   202                 TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber;
   202                 TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber;
   203                 CurrTeam:= Pred(CurrTeam) mod TeamsNumber;
   203                 CurrTeam:= Pred(CurrTeam) mod TeamsNumber;
   204                 inc(c);
   204                 inc(c);
   205                 if c = ClansCount then
   205                 if c = ClansCount then
   206                     c:= 0;
   206                     c:= 0;
       
   207                 if c = SwapClanReal then
       
   208                     inc(TotalRoundsReal);
   207                 NextClan:= true;
   209                 NextClan:= true;
   208                 end;
   210                 end;
   209             end;
   211             end;
   210 
   212 
   211         with ClansArray[c]^ do
   213         with ClansArray[c]^ do
   212             begin
   214             begin
   213             if (c = SwapClan) and (not PlacingHogs) and ((Succ(CurrTeam) mod TeamsNumber) = TagTeamIndex) then
   215             if (not PlacingHogs) and ((Succ(CurrTeam) mod TeamsNumber) = TagTeamIndex) then
   214                 begin
   216                 begin
   215                 inc(TotalRounds);
   217                 if c = SwapClanPre then
       
   218                     inc(TotalRoundsPre);
   216                 end;
   219                 end;
   217             end;
   220             end;
   218         end
   221         end
   219     else
   222     else
   220         begin
   223         begin
   221         inc(c);
   224         inc(c);
   222         if c = ClansCount then
   225         if c = ClansCount then
   223             c:= 0;
   226             c:= 0;
   224         if (c = SwapClan) and (not PlacingHogs) then
   227         if (not PlacingHogs) then
   225             begin
   228             begin
   226             inc(TotalRounds);
   229             if c = SwapClanPre then
       
   230                 inc(TotalRoundsPre);
       
   231             if c = SwapClanReal then
       
   232                 inc(TotalRoundsReal);
   227             end;
   233             end;
   228         end;
   234         end;
   229 
   235 
   230     with ClansArray[c]^ do
   236     with ClansArray[c]^ do
   231         begin
   237         begin
   303         ResetWeapons
   309         ResetWeapons
   304         end;
   310         end;
   305 
   311 
   306     end;
   312     end;
   307 
   313 
   308 // Determine clan ID to check to determine whether to increase TotalRounds
   314 if not PlacingHogs then
   309 if (SwapClan = -1) and (not PlacingHogs) then
   315     if (TotalRoundsReal = -1) then
   310     begin
   316         TotalRoundsReal:= 0;
   311     if (GameFlags and gfRandomOrder) <> 0 then
   317 
   312         SwapClan:= 0
   318 // Determine clan ID to check to determine whether to increase TotalRoundsPre/TotalRoundsReal
   313     else
   319 if (not PlacingHogs) then
   314         SwapClan:= ClansCount - 1;
   320     begin
       
   321     if SwapClanPre = -1 then
       
   322         begin
       
   323         if (GameFlags and gfRandomOrder) <> 0 then
       
   324             SwapClanPre:= 0
       
   325         else
       
   326             SwapClanPre:= ClansCount - 1;
       
   327         end;
       
   328     if SwapClanReal = -1 then
       
   329         SwapClanReal:= CurrentTeam^.Clan^.ClanIndex;
   315     end;
   330     end;
   316 
   331 
   317 inc(CurrentTeam^.Clan^.TurnNumber);
   332 inc(CurrentTeam^.Clan^.TurnNumber);
   318 with CurrentTeam^.Clan^ do
   333 with CurrentTeam^.Clan^ do
   319     for t:= 0 to Pred(TeamsNumber) do
   334     for t:= 0 to Pred(TeamsNumber) do
   898 LocalClan:= -1;
   913 LocalClan:= -1;
   899 LocalTeam:= -1;
   914 LocalTeam:= -1;
   900 LocalAmmo:= -1;
   915 LocalAmmo:= -1;
   901 TeamsGameOver:= false;
   916 TeamsGameOver:= false;
   902 NextClan:= true;
   917 NextClan:= true;
   903 SwapClan:= -1;
   918 SwapClanPre:= -1;
       
   919 SwapClanReal:= -1;
   904 MaxTeamHealth:= 0;
   920 MaxTeamHealth:= 0;
   905 end;
   921 end;
   906 
   922 
   907 procedure freeModule;
   923 procedure freeModule;
   908 var i, h: LongWord;
   924 var i, h: LongWord;
   944         Dispose(ClansArray[i])
   960         Dispose(ClansArray[i])
   945         end
   961         end
   946     end;
   962     end;
   947 TeamsCount:= 0;
   963 TeamsCount:= 0;
   948 ClansCount:= 0;
   964 ClansCount:= 0;
   949 SwapClan:= -1;
   965 SwapClanPre:= -1;
       
   966 SwapClanReal:= -1;
   950 end;
   967 end;
   951 
   968 
   952 end.
   969 end.