hedgewars/uTeams.pas
changeset 4014 e9baae83370b
parent 3996 eb549fd864a5
child 4082 bfe14b38dad1
equal deleted inserted replaced
4013:c9b20ed3566f 4014:e9baae83370b
    99     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
    99     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
   100     ClansCount: Longword;
   100     ClansCount: Longword;
   101     LocalClan: LongInt;  // last non-bot, non-extdriven clan
   101     LocalClan: LongInt;  // last non-bot, non-extdriven clan
   102     LocalAmmo: LongInt;  // last non-bot, non-extdriven clan's first team's ammo index
   102     LocalAmmo: LongInt;  // last non-bot, non-extdriven clan's first team's ammo index
   103     CurMinAngle, CurMaxAngle: Longword;
   103     CurMinAngle, CurMaxAngle: Longword;
       
   104     GameOver: boolean;
   104 
   105 
   105 procedure initModule;
   106 procedure initModule;
   106 procedure freeModule;
   107 procedure freeModule;
   107 function  AddTeam(TeamColor: Longword): PTeam;
   108 function  AddTeam(TeamColor: Longword): PTeam;
   108 procedure SwitchHedgehog;
   109 procedure SwitchHedgehog;
   137 or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false);
   138 or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false);
   138 CheckForWin:= true;
   139 CheckForWin:= true;
   139 
   140 
   140 TurnTimeLeft:= 0;
   141 TurnTimeLeft:= 0;
   141 ReadyTimeLeft:= 0;
   142 ReadyTimeLeft:= 0;
   142 if AliveCount = 0 then
   143 if not GameOver then
   143     begin // draw
   144     begin
   144     AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState);
   145     if AliveCount = 0 then
   145     SendStat(siGameResult, trmsg[sidDraw]);
   146         begin // draw
   146     AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
   147         AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState);
   147     end else // win
   148         SendStat(siGameResult, trmsg[sidDraw]);
   148     with AliveClan^ do
       
   149         begin
       
   150         if TeamsNumber = 1 then
       
   151             s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName)  // team wins
       
   152         else
       
   153             s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins
       
   154 
       
   155         for j:= 0 to Pred(TeamsNumber) do
       
   156             with Teams[j]^ do
       
   157                 for i:= 0 to cMaxHHIndex do
       
   158                     with Hedgehogs[i] do
       
   159                         if (Gear <> nil) then
       
   160                             Gear^.State:= gstWinner;
       
   161 
       
   162         AddCaption(s, cWhiteColor, capgrpGameState);
       
   163         SendStat(siGameResult, s);
       
   164         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
   149         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
   165         end;
   150         end else // win
   166 SendStats
   151         with AliveClan^ do
       
   152             begin
       
   153             if TeamsNumber = 1 then
       
   154                 s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName)  // team wins
       
   155             else
       
   156                 s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins
       
   157 
       
   158             for j:= 0 to Pred(TeamsNumber) do
       
   159                 with Teams[j]^ do
       
   160                     for i:= 0 to cMaxHHIndex do
       
   161                         with Hedgehogs[i] do
       
   162                             if (Gear <> nil) then
       
   163                                 Gear^.State:= gstWinner;
       
   164 
       
   165             AddCaption(s, cWhiteColor, capgrpGameState);
       
   166             SendStat(siGameResult, s);
       
   167             AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
       
   168             end;
       
   169     SendStats;
       
   170     end;
       
   171 GameOver:= true
   167 end;
   172 end;
   168 
   173 
   169 procedure SwitchHedgehog;
   174 procedure SwitchHedgehog;
   170 var c: LongWord;
   175 var c: LongWord;
   171     PrevHH, PrevTeam: LongWord;
   176     PrevHH, PrevTeam: LongWord;
   495     CurrentHedgehog:= nil;
   500     CurrentHedgehog:= nil;
   496     TeamsCount:= 0;
   501     TeamsCount:= 0;
   497     ClansCount:= 0;
   502     ClansCount:= 0;
   498     LocalClan:= -1;
   503     LocalClan:= -1;
   499     LocalAmmo:= -1;
   504     LocalAmmo:= -1;
       
   505     GameOver:= false
   500 end;
   506 end;
   501 
   507 
   502 procedure freeModule;
   508 procedure freeModule;
   503 var i: LongWord;
   509 var i: LongWord;
   504 begin
   510 begin