author | unc0rr |
Sun, 06 Jul 2008 17:45:16 +0000 | |
changeset 1054 | 80225c6af656 |
parent 874 | 964c0d5b3604 |
child 1058 | c53c5c4e7b48 |
permissions | -rw-r--r-- |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
1 |
(* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
2 |
* Hedgewars, a worms-like game |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
3 |
* Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com> |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
4 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
8 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
13 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
17 |
*) |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
18 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
19 |
unit uStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
20 |
interface |
829 | 21 |
uses uGears, uConsts; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
22 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
23 |
type TStatistics = record |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
24 |
DamageRecv, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
25 |
DamageGiven: Longword; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
26 |
StepDamageRecv, |
869 | 27 |
StepDamageGiven, |
28 |
StepKills: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
29 |
MaxStepDamageRecv, |
869 | 30 |
MaxStepDamageGiven, |
31 |
MaxStepKills: Longword; |
|
815 | 32 |
FinishedTurns: Longword; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
33 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
34 |
|
829 | 35 |
procedure AmmoUsed(am: TAmmoType); |
867 | 36 |
procedure HedgehogDamaged(Gear: PGear); |
871 | 37 |
procedure Skipped; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
38 |
procedure TurnReaction; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
39 |
procedure SendStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
40 |
|
1054 | 41 |
var FinishedTurnsTotal: LongInt = -1; |
42 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
43 |
implementation |
858 | 44 |
uses uTeams, uSound, uMisc; |
815 | 45 |
var DamageGiven : Longword = 0; |
46 |
DamageClan : Longword = 0; |
|
829 | 47 |
DamageTotal : Longword = 0; |
867 | 48 |
KillsClan : LongWord = 0; |
49 |
Kills : LongWord = 0; |
|
50 |
KillsTotal : LongWord = 0; |
|
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
51 |
AmmoUsedCount : Longword = 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
52 |
AmmoDamagingUsed : boolean = false; |
871 | 53 |
SkippedTurns: LongWord = 0; |
54 |
isTurnSkipped: boolean = false; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
55 |
|
867 | 56 |
procedure HedgehogDamaged(Gear: PGear); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
57 |
begin |
1054 | 58 |
if bBetweenTurns then exit; |
59 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
60 |
if Gear <> CurrentHedgehog^.Gear then |
867 | 61 |
inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); |
815 | 62 |
|
867 | 63 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); |
815 | 64 |
|
867 | 65 |
if Gear^.Health <= Gear^.Damage then |
66 |
begin |
|
869 | 67 |
inc(CurrentHedgehog^.stats.StepKills); |
867 | 68 |
inc(Kills); |
69 |
inc(KillsTotal); |
|
70 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); |
|
71 |
end; |
|
815 | 72 |
|
867 | 73 |
inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); |
74 |
inc(DamageGiven, Gear^.Damage); |
|
75 |
inc(DamageTotal, Gear^.Damage) |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
76 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
77 |
|
871 | 78 |
procedure Skipped; |
79 |
begin |
|
80 |
inc(SkippedTurns); |
|
81 |
isTurnSkipped:= true |
|
82 |
end; |
|
83 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
84 |
procedure TurnReaction; |
874 | 85 |
var i, t: LongInt; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
86 |
begin |
1054 | 87 |
TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
88 |
||
870 | 89 |
inc(FinishedTurnsTotal); |
90 |
if FinishedTurnsTotal = 0 then exit; |
|
91 |
||
815 | 92 |
inc(CurrentHedgehog^.stats.FinishedTurns); |
93 |
||
864 | 94 |
if (DamageGiven = DamageTotal) and (DamageTotal > 0) then |
95 |
PlaySound(sndFirstBlood, false) |
|
96 |
||
97 |
else if CurrentHedgehog^.stats.StepDamageRecv > 0 then |
|
98 |
PlaySound(sndStupid, false) |
|
99 |
||
815 | 100 |
else if DamageClan <> 0 then |
864 | 101 |
if DamageTotal > DamageClan then |
873 | 102 |
if random(2) = 0 then |
103 |
PlaySound(sndNutter, false) |
|
104 |
else |
|
105 |
PlaySound(sndWatchIt, false) |
|
864 | 106 |
else |
866 | 107 |
if random(2) = 0 then |
108 |
PlaySound(sndSameTeam, false) |
|
109 |
else |
|
110 |
PlaySound(sndTraitor, false) |
|
864 | 111 |
|
867 | 112 |
else if DamageGiven <> 0 then |
113 |
if Kills > 0 then |
|
114 |
PlaySound(sndEnemyDown, false) |
|
115 |
else |
|
116 |
PlaySound(sndRegret, false) |
|
864 | 117 |
|
867 | 118 |
else if AmmoDamagingUsed then |
870 | 119 |
PlaySound(sndMissed, false) |
1054 | 120 |
else if (AmmoUsedCount > 0) and not isTurnSkipped then |
870 | 121 |
// nothing ? |
871 | 122 |
else if isTurnSkipped then |
123 |
PlaySound(sndBoring, false) |
|
870 | 124 |
else |
125 |
PlaySound(sndCoward, false); |
|
126 |
||
815 | 127 |
|
869 | 128 |
for t:= 0 to Pred(TeamsCount) do |
129 |
with TeamsArray[t]^ do |
|
130 |
for i:= 0 to cMaxHHIndex do |
|
131 |
with Hedgehogs[i].stats do |
|
132 |
begin |
|
133 |
inc(DamageRecv, StepDamageRecv); |
|
134 |
inc(DamageGiven, StepDamageGiven); |
|
135 |
if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; |
|
136 |
if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; |
|
137 |
if StepKills > MaxStepKills then MaxStepKills:= StepKills; |
|
871 | 138 |
StepKills:= 0; |
869 | 139 |
StepDamageRecv:= 0; |
140 |
StepDamageGiven:= 0 |
|
141 |
end; |
|
815 | 142 |
|
867 | 143 |
Kills:= 0; |
144 |
KillsClan:= 0; |
|
815 | 145 |
DamageGiven:= 0; |
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
146 |
DamageClan:= 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
147 |
AmmoUsedCount:= 0; |
871 | 148 |
AmmoDamagingUsed:= false; |
149 |
isTurnSkipped:= false |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
150 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
151 |
|
829 | 152 |
procedure AmmoUsed(am: TAmmoType); |
153 |
begin |
|
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
154 |
inc(AmmoUsedCount); |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
155 |
AmmoDamagingUsed:= AmmoDamagingUsed or Ammoz[am].isDamaging |
829 | 156 |
end; |
157 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
158 |
procedure SendStats; |
858 | 159 |
var i, t: LongInt; |
869 | 160 |
msd, msk: Longword; msdhh, mskhh: PHedgehog; |
161 |
mskcnt: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
162 |
begin |
858 | 163 |
msd:= 0; msdhh:= nil; |
869 | 164 |
msk:= 0; mskhh:= nil; |
165 |
mskcnt:= 0; |
|
166 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
167 |
for t:= 0 to Pred(TeamsCount) do |
869 | 168 |
with TeamsArray[t]^ do |
169 |
begin |
|
170 |
for i:= 0 to cMaxHHIndex do |
|
171 |
begin |
|
172 |
if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
|
173 |
begin |
|
174 |
msdhh:= @Hedgehogs[i]; |
|
175 |
msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
|
176 |
end; |
|
177 |
if Hedgehogs[i].stats.MaxStepKills >= msk then |
|
178 |
if Hedgehogs[i].stats.MaxStepKills = msk then |
|
179 |
inc(mskcnt) |
|
180 |
else |
|
181 |
begin |
|
182 |
mskcnt:= 1; |
|
183 |
mskhh:= @Hedgehogs[i]; |
|
184 |
msk:= Hedgehogs[i].stats.MaxStepKills |
|
185 |
end; |
|
186 |
end |
|
187 |
end; |
|
188 |
if msdhh <> nil then |
|
189 |
SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
|
190 |
if mskcnt = 1 then |
|
191 |
SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
|
192 |
||
858 | 193 |
if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
194 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
195 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
196 |
end. |