hedgewars/uTeams.pas
changeset 814 7fb4417b7bc1
parent 801 0323e5c7ee54
child 883 07a568ba44e0
equal deleted inserted replaced
813:36fffe78ff11 814:7fb4417b7bc1
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 unit uTeams;
    19 unit uTeams;
    20 interface
    20 interface
    21 uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat;
    21 uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats;
    22 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    23 
    23 
    24 type PHHAmmo = ^THHAmmo;
    24 type PHHAmmo = ^THHAmmo;
    25      THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo;
    25      THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo;
    26 
    26 
    38                  AltSlot, AltAmmo: LongWord;
    38                  AltSlot, AltAmmo: LongWord;
    39                  Team: PTeam;
    39                  Team: PTeam;
    40                  AttacksNum: Longword;
    40                  AttacksNum: Longword;
    41                  visStepPos: LongWord;
    41                  visStepPos: LongWord;
    42                  BotLevel  : LongWord; // 0 - Human player
    42                  BotLevel  : LongWord; // 0 - Human player
    43                  DamageGiven: Longword;
    43                  stats: TStatistics;
    44                  MaxStepDamage: Longword;
       
    45                  end;
    44                  end;
    46      TTeam = record
    45      TTeam = record
    47              Clan: PClan;
    46              Clan: PClan;
    48              TeamName: string[MAXNAMELEN];
    47              TeamName: string[MAXNAMELEN];
    49              ExtDriven: boolean;
    48              ExtDriven: boolean;
    85 procedure InitTeams;
    84 procedure InitTeams;
    86 function  TeamSize(p: PTeam): Longword;
    85 function  TeamSize(p: PTeam): Longword;
    87 procedure RecountTeamHealth(team: PTeam);
    86 procedure RecountTeamHealth(team: PTeam);
    88 procedure RestoreTeamsFromSave;
    87 procedure RestoreTeamsFromSave;
    89 function CheckForWin: boolean;
    88 function CheckForWin: boolean;
    90 procedure SendStats;
       
    91 
    89 
    92 implementation
    90 implementation
    93 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound;
    91 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound;
    94 const MaxTeamHealth: LongInt = 0;
    92 const MaxTeamHealth: LongInt = 0;
    95 
    93 
   323 begin
   321 begin
   324 for t:= 0 to Pred(TeamsCount) do
   322 for t:= 0 to Pred(TeamsCount) do
   325    TeamsArray[t]^.ExtDriven:= false
   323    TeamsArray[t]^.ExtDriven:= false
   326 end;
   324 end;
   327 
   325 
   328 procedure SendStats;
       
   329 var i, t: LongInt;
       
   330     msd: Longword; msdhh: PHedgehog;
       
   331 begin
       
   332 msd:= 0; msdhh:= nil;
       
   333 for t:= 0 to Pred(TeamsCount) do
       
   334    with TeamsArray[t]^ do
       
   335       begin
       
   336       for i:= 0 to cMaxHHIndex do
       
   337           if Hedgehogs[i].MaxStepDamage > msd then
       
   338              begin
       
   339              msdhh:= @Hedgehogs[i];
       
   340              msd:= Hedgehogs[i].MaxStepDamage
       
   341              end;
       
   342       end;
       
   343 if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msdhh^.MaxStepDamage) + ' ' +
       
   344                                                msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
       
   345 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
       
   346 end;
       
   347 
       
   348 initialization
   326 initialization
   349 
   327 
   350 finalization
   328 finalization
   351 
   329 
   352 FreeTeamsList
   330 FreeTeamsList