hedgewars/uStats.pas
changeset 3784 75aa91bea32b
parent 3770 f54e8cb9a12b
child 4357 a1fcfc341a52
equal deleted inserted replaced
3782:dc3531e49e4c 3784:75aa91bea32b
    30                    StepKills: Longword;
    30                    StepKills: Longword;
    31                    MaxStepDamageRecv,
    31                    MaxStepDamageRecv,
    32                    MaxStepDamageGiven,
    32                    MaxStepDamageGiven,
    33                    MaxStepKills: Longword;
    33                    MaxStepKills: Longword;
    34                    FinishedTurns: Longword;
    34                    FinishedTurns: Longword;
    35                    AIKills : LongInt;
       
    36                    end;
    35                    end;
    37 
    36 
    38 type TTeamStats = record
    37 type TTeamStats = record
    39     AIKills : LongInt;
    38     Kills : Longword;
       
    39     AIKills : Longword;
       
    40     TeamKills : Longword;
       
    41     TurnSkips : Longword;
       
    42     TeamDamage : Longword;
    40 end;
    43 end;
    41 
    44 
    42 var TotalRounds: LongInt;
    45 var TotalRounds: LongInt;
    43     FinishedTurnsTotal: LongInt;
    46     FinishedTurnsTotal: LongInt;
    44 
    47 
    85 if Gear^.Health <= Gear^.Damage then
    88 if Gear^.Health <= Gear^.Damage then
    86     begin
    89     begin
    87     inc(CurrentHedgehog^.stats.StepKills);
    90     inc(CurrentHedgehog^.stats.StepKills);
    88     inc(Kills);
    91     inc(Kills);
    89     inc(KillsTotal);
    92     inc(KillsTotal);
       
    93     inc(CurrentHedgehog^.Team^.stats.Kills);
       
    94     if (CurrentHedgehog^.Team^.TeamName =
       
    95             PHedgehog(Gear^.Hedgehog)^.Team^.TeamName) then begin
       
    96         inc(CurrentHedgehog^.Team^.stats.TeamKills);
       
    97         inc(CurrentHedgehog^.Team^.stats.TeamDamage, Gear^.Damage);
       
    98     end;
    90     if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan);
    99     if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan);
    91     end;
   100     end;
    92 
   101 
    93 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage);
   102 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage);
    94 inc(DamageGiven, Gear^.Damage);
   103 inc(DamageGiven, Gear^.Damage);
   188 
   197 
   189 procedure SendStats;
   198 procedure SendStats;
   190 var i, t: LongInt;
   199 var i, t: LongInt;
   191     msd, msk: Longword; msdhh, mskhh: PHedgehog;
   200     msd, msk: Longword; msdhh, mskhh: PHedgehog;
   192     mskcnt: Longword;
   201     mskcnt: Longword;
       
   202     maxTeamKills : Longword;
       
   203     maxTeamKillsName : shortstring;
       
   204     maxTurnSkips : Longword;
       
   205     maxTurnSkipsName : shortstring;
       
   206     maxTeamDamage : Longword;
       
   207     maxTeamDamageName : shortstring;
   193 begin
   208 begin
   194 msd:= 0; msdhh:= nil;
   209 msd:= 0; msdhh:= nil;
   195 msk:= 0; mskhh:= nil;
   210 msk:= 0; mskhh:= nil;
   196 mskcnt:= 0;
   211 mskcnt:= 0;
       
   212 maxTeamKills := 0;
       
   213 maxTurnSkips := 0;
       
   214 maxTeamDamage := 0;
   197 
   215 
   198 for t:= 0 to Pred(TeamsCount) do
   216 for t:= 0 to Pred(TeamsCount) do
   199     with TeamsArray[t]^ do
   217     with TeamsArray[t]^ do
   200         begin
   218     begin
   201         if not ExtDriven then
   219         if not ExtDriven then
   202             SendStat(siTeamStats, GetTeamStatString(TeamsArray[t]));
   220             SendStat(siTeamStats, GetTeamStatString(TeamsArray[t]));
   203         for i:= 0 to cMaxHHIndex do
   221         for i:= 0 to cMaxHHIndex do begin
   204             begin
       
   205             if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
   222             if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
   206                 begin
   223                 begin
   207                 msdhh:= @Hedgehogs[i];
   224                 msdhh:= @Hedgehogs[i];
   208                 msd:= Hedgehogs[i].stats.MaxStepDamageGiven
   225                 msd:= Hedgehogs[i].stats.MaxStepDamageGiven
   209                 end;
   226                 end;
   214                     begin
   231                     begin
   215                     mskcnt:= 1;
   232                     mskcnt:= 1;
   216                     mskhh:= @Hedgehogs[i];
   233                     mskhh:= @Hedgehogs[i];
   217                     msk:= Hedgehogs[i].stats.MaxStepKills
   234                     msk:= Hedgehogs[i].stats.MaxStepKills
   218                     end;
   235                     end;
   219             end
   236         end;
   220         end;
   237 
       
   238         { send player stats for winner teams }
       
   239         if Clan^.ClanHealth > 0 then begin
       
   240             SendStat(siPlayerKills, inttostr(Clan^.Color) + ' ' +
       
   241                 inttostr(stats.Kills) + ' ' + TeamName);
       
   242         end;
       
   243 
       
   244         { determine maximum values of TeamKills, TurnSkips, TeamDamage }
       
   245         if stats.TeamKills > maxTeamKills then begin
       
   246             maxTeamKills := stats.TeamKills;
       
   247             maxTeamKillsName := TeamName;
       
   248         end;
       
   249         if stats.TurnSkips > maxTurnSkips then begin
       
   250             maxTurnSkips := stats.TurnSkips;
       
   251             maxTurnSkipsName := TeamName;
       
   252         end;
       
   253         if stats.TeamDamage > maxTeamDamage then begin
       
   254             maxTeamDamage := stats.TeamDamage;
       
   255             maxTeamDamageName := TeamName;
       
   256         end;
       
   257 
       
   258     end;
       
   259 
       
   260 { now send player stats for loser teams }
       
   261 for t:= 0 to Pred(TeamsCount) do begin
       
   262     with TeamsArray[t]^ do begin
       
   263         if Clan^.ClanHealth = 0 then begin
       
   264             SendStat(siPlayerKills, inttostr(Clan^.Color) + ' ' +
       
   265                 inttostr(stats.Kills) + ' ' + TeamName);
       
   266         end;
       
   267     end;
       
   268 end;
       
   269 
   221 if msdhh <> nil then
   270 if msdhh <> nil then
   222     SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
   271     SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
   223 if mskcnt = 1 then
   272 if mskcnt = 1 then
   224     SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')');
   273     SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')');
   225 
   274 
       
   275 if maxTeamKills > 1 then
       
   276     SendStat(siMaxTeamKills, inttostr(maxTeamKills) + ' ' + maxTeamKillsName);
       
   277 if maxTurnSkips > 2 then
       
   278     SendStat(siMaxTurnSkips, inttostr(maxTurnSkips) + ' ' + maxTurnSkipsName);
       
   279 if maxTeamDamage > 30 then
       
   280     SendStat(siMaxTeamDamage, inttostr(maxTeamDamage) + ' ' + maxTeamDamageName);
       
   281 
   226 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
   282 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
   227 end;
   283 end;
   228 
   284 
   229 procedure initModule;
   285 procedure initModule;
   230 begin
   286 begin