hedgewars/uStats.pas
changeset 6580 6155187bf599
parent 6453 11c578d30bd3
child 6700 e04da46ee43c
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
    69     begin
    69     begin
    70     inc(Attacker^.stats.StepKills);
    70     inc(Attacker^.stats.StepKills);
    71     inc(Kills);
    71     inc(Kills);
    72     inc(KillsTotal);
    72     inc(KillsTotal);
    73     inc(Attacker^.Team^.stats.Kills);
    73     inc(Attacker^.Team^.stats.Kills);
    74     if (Attacker^.Team^.TeamName =
    74     if (Attacker^.Team^.TeamName = Gear^.Hedgehog^.Team^.TeamName) then
    75             Gear^.Hedgehog^.Team^.TeamName) then begin
    75         begin
    76         inc(Attacker^.Team^.stats.TeamKills);
    76         inc(Attacker^.Team^.stats.TeamKills);
    77         inc(Attacker^.Team^.stats.TeamDamage, Gear^.Damage);
    77         inc(Attacker^.Team^.stats.TeamDamage, Gear^.Damage);
    78     end;
    78     end;
    79     if Gear = Attacker^.Gear then inc(Attacker^.Team^.stats.Suicides);
    79     if Gear = Attacker^.Gear then
    80     if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then inc(KillsClan);
    80         inc(Attacker^.Team^.stats.Suicides);
       
    81     if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
       
    82         inc(KillsClan);
    81     end;
    83     end;
    82 
    84 
    83 inc(DamageTotal, Damage)
    85 inc(DamageTotal, Damage)
    84 end;
    86 end;
    85 
    87 
   146         for i:= 0 to cMaxHHIndex do
   148         for i:= 0 to cMaxHHIndex do
   147             with Hedgehogs[i].stats do
   149             with Hedgehogs[i].stats do
   148                 begin
   150                 begin
   149                 inc(DamageRecv, StepDamageRecv);
   151                 inc(DamageRecv, StepDamageRecv);
   150                 inc(DamageGiven, StepDamageGiven);
   152                 inc(DamageGiven, StepDamageGiven);
   151                 if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv;
   153                 if StepDamageRecv > MaxStepDamageRecv then
   152                 if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven;
   154                     MaxStepDamageRecv:= StepDamageRecv;
   153                 if StepKills > MaxStepKills then MaxStepKills:= StepKills;
   155                 if StepDamageGiven > MaxStepDamageGiven then
       
   156                     MaxStepDamageGiven:= StepDamageGiven;
       
   157                 if StepKills > MaxStepKills then
       
   158                     MaxStepKills:= StepKills;
   154                 StepKills:= 0;
   159                 StepKills:= 0;
   155                 StepDamageRecv:= 0;
   160                 StepDamageRecv:= 0;
   156                 StepDamageGiven:= 0
   161                 StepDamageGiven:= 0
   157                 end;
   162                 end;
   158 
   163 
   210 for t:= 0 to Pred(TeamsCount) do
   215 for t:= 0 to Pred(TeamsCount) do
   211     with TeamsArray[t]^ do
   216     with TeamsArray[t]^ do
   212     begin
   217     begin
   213         if not ExtDriven then
   218         if not ExtDriven then
   214             SendStat(siTeamStats, GetTeamStatString(TeamsArray[t]));
   219             SendStat(siTeamStats, GetTeamStatString(TeamsArray[t]));
   215         for i:= 0 to cMaxHHIndex do begin
   220         for i:= 0 to cMaxHHIndex do
       
   221             begin
   216             if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
   222             if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
   217                 begin
   223                 begin
   218                 msdhh:= @Hedgehogs[i];
   224                 msdhh:= @Hedgehogs[i];
   219                 msd:= Hedgehogs[i].stats.MaxStepDamageGiven
   225                 msd:= Hedgehogs[i].stats.MaxStepDamageGiven
   220                 end;
   226                 end;
   228                     msk:= Hedgehogs[i].stats.MaxStepKills
   234                     msk:= Hedgehogs[i].stats.MaxStepKills
   229                     end;
   235                     end;
   230         end;
   236         end;
   231 
   237 
   232         { send player stats for winner teams }
   238         { send player stats for winner teams }
   233         if Clan^.ClanHealth > 0 then begin
   239         if Clan^.ClanHealth > 0 then
       
   240             begin
   234             winnersClan:= Clan;
   241             winnersClan:= Clan;
   235             SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' +
   242             SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' +
   236                 IntToStr(stats.Kills) + ' ' + TeamName);
   243                 IntToStr(stats.Kills) + ' ' + TeamName);
   237         end;
   244         end;
   238 
   245 
   239         { determine maximum values of TeamKills, TurnSkips, TeamDamage }
   246         { determine maximum values of TeamKills, TurnSkips, TeamDamage }
   240         if stats.TeamKills > maxTeamKills then begin
   247         if stats.TeamKills > maxTeamKills then
       
   248             begin
   241             maxTeamKills := stats.TeamKills;
   249             maxTeamKills := stats.TeamKills;
   242             maxTeamKillsName := TeamName;
   250             maxTeamKillsName := TeamName;
   243         end;
   251         end;
   244         if stats.TurnSkips > maxTurnSkips then begin
   252         if stats.TurnSkips > maxTurnSkips then
       
   253             begin
   245             maxTurnSkips := stats.TurnSkips;
   254             maxTurnSkips := stats.TurnSkips;
   246             maxTurnSkipsName := TeamName;
   255             maxTurnSkipsName := TeamName;
   247         end;
   256         end;
   248         if stats.TeamDamage > maxTeamDamage then begin
   257         if stats.TeamDamage > maxTeamDamage then
       
   258             begin
   249             maxTeamDamage := stats.TeamDamage;
   259             maxTeamDamage := stats.TeamDamage;
   250             maxTeamDamageName := TeamName;
   260             maxTeamDamageName := TeamName;
   251         end;
   261         end;
   252 
   262 
   253     end;
   263     end;
   254 
   264 
   255 { now send player stats for loser teams }
   265 { now send player stats for loser teams }
   256 for t:= 0 to Pred(TeamsCount) do begin
   266 for t:= 0 to Pred(TeamsCount) do
   257     with TeamsArray[t]^ do begin
   267     begin
   258         if Clan^.ClanHealth = 0 then begin
   268     with TeamsArray[t]^ do
       
   269         begin
       
   270         if Clan^.ClanHealth = 0 then
       
   271             begin
   259             SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' +
   272             SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' +
   260                 IntToStr(stats.Kills) + ' ' + TeamName);
   273                 IntToStr(stats.Kills) + ' ' + TeamName);
   261         end;
   274         end;
   262     end;
   275     end;
   263 end;
   276 end;
   272 if maxTurnSkips > 2 then
   285 if maxTurnSkips > 2 then
   273     SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName);
   286     SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName);
   274 if maxTeamDamage > 30 then
   287 if maxTeamDamage > 30 then
   275     SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName);
   288     SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName);
   276 
   289 
   277 if KilledHHs > 0 then SendStat(siKilledHHs, IntToStr(KilledHHs));
   290 if KilledHHs > 0 then
       
   291     SendStat(siKilledHHs, IntToStr(KilledHHs));
   278 
   292 
   279 // now to console
   293 // now to console
   280 if winnersClan <> nil then 
   294 if winnersClan <> nil then 
   281     begin
   295     begin
   282     writeln('WINNERS');
   296     writeln('WINNERS');
   283     for t:= 0 to winnersClan^.TeamsNumber - 1 do
   297     for t:= 0 to winnersClan^.TeamsNumber - 1 do
   284         writeln(winnersClan^.Teams[t]^.TeamName);
   298         writeln(winnersClan^.Teams[t]^.TeamName);
   285     end else
   299     end
       
   300 else
   286     writeln('DRAW');
   301     writeln('DRAW');
   287 
   302 
   288 writeln;
   303 writeln;
   289 end;
   304 end;
   290 
   305