hedgewars/uStats.pas
author unc0rr
Tue, 01 Apr 2008 15:53:52 +0000
changeset 828 de0af1ad2610
parent 815 82ff416301bd
child 829 1209eb768acf
permissions -rw-r--r--
Fix tunnel drawing (specially for desert eagle)

(*
 * Hedgewars, a worms-like game
 * Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 *)

unit uStats;
interface
uses uGears;

type TStatistics = record
                   DamageRecv,
                   DamageGiven: Longword;
                   StepDamageRecv,
                   StepDamageGiven: Longword;
                   MaxStepDamageRecv,
                   MaxStepDamageGiven: Longword;
                   FinishedTurns: Longword;
                   end;

procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
procedure TurnReaction;
procedure SendStats;

implementation
uses uTeams, uSound, uConsts;
var DamageGiven : Longword = 0;
    DamageClan  : Longword = 0;

procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
begin
if Gear <> CurrentHedgehog^.Gear then
   inc(CurrentHedgehog^.stats.StepDamageGiven, Damage);

if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Damage);


inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Damage);
inc(DamageGiven, Damage)
end;

procedure TurnReaction;
var Gear: PGear;
begin
inc(CurrentHedgehog^.stats.FinishedTurns);

if CurrentHedgehog^.stats.StepDamageRecv > 0 then PlaySound(sndStupid, false)
else if DamageClan <> 0 then
else if DamageGiven <> 0 then
else PlaySound(sndMissed, false);

Gear:= GearsList;
while Gear <> nil do
  begin
  if Gear^.Kind = gtHedgehog then
    with PHedgehog(Gear^.Hedgehog)^.stats do
      begin
      inc(DamageRecv, StepDamageRecv);
      inc(DamageGiven, StepDamageGiven);
      if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv;
      if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven;
      StepDamageRecv:= 0;
      StepDamageGiven:= 0
      end;
  Gear:= Gear^.NextGear
  end;

DamageGiven:= 0;
DamageClan:= 0
end;

procedure SendStats;
//var i, t: LongInt;
//    msd: Longword; msdhh: PHedgehog;
begin
(*msd:= 0; msdhh:= nil;
for t:= 0 to Pred(TeamsCount) do
   with TeamsArray[t]^ do
      begin
      for i:= 0 to cMaxHHIndex do
          if Hedgehogs[i].MaxStepDamage > msd then
             begin
             msdhh:= @Hedgehogs[i];
             msd:= Hedgehogs[i].MaxStepDamage
             end;
      end;
if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msdhh^.MaxStepDamage) + ' ' +
                                               msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));*)
end;

end.