--- a/QTfrontend/hwform.cpp Thu Jan 04 16:27:45 2007 +0000
+++ b/QTfrontend/hwform.cpp Thu Jan 04 18:54:24 2007 +0000
@@ -290,13 +290,37 @@
void HWForm::GameStateChanged(GameState gameState)
{
if (gameState == gsStarted)
+ {
GoToPage(ID_PAGE_GAMESTATS);
+ ui.pageGameStats->labelGameStats->setText("");
+ }
+}
+
+void HWForm::AddStatText(const QString & msg)
+{
+ ui.pageGameStats->labelGameStats->setText(
+ ui.pageGameStats->labelGameStats->text() + msg);
}
void HWForm::GameStats(char type, const QString & info)
{
switch(type) {
- case 'r' : { ui.pageGameStats->labelGameResult->setText(info); break; }
+ case 'r' : {
+ AddStatText(QString("<h1 align=\"center\">%1</h1>").arg(info));
+ break;
+ }
+ case 'D' : {
+ int i = info.indexOf(' ');
+ QString message = QLabel::tr("<p>The best shot award was won by <b>%1</b> with <b>%2</b> pts.</p>")
+ .arg(info.mid(i + 1), info.left(i));
+ AddStatText(message);
+ break;
+ }
+ case 'K' : {
+ QString message = QLabel::tr("<p>A total of <b>%1</b> Hedgehog(s) were killed during this round.</p>").arg(info);
+ AddStatText(message);
+ break;
+ }
}
}
--- a/QTfrontend/hwform.h Thu Jan 04 16:27:45 2007 +0000
+++ b/QTfrontend/hwform.h Thu Jan 04 18:54:24 2007 +0000
@@ -92,6 +92,7 @@
QStack<quint8> PagesStack;
void CreateGame(GameCFGWidget * gamecfg);
+ void AddStatText(const QString & msg);
};
#endif
--- a/QTfrontend/pages.cpp Thu Jan 04 16:27:45 2007 +0000
+++ b/QTfrontend/pages.cpp Thu Jan 04 18:54:24 2007 +0000
@@ -494,7 +494,7 @@
BtnBack->setText(QPushButton::tr("Back"));
pageLayout->addWidget(BtnBack, 1, 0);
- labelGameResult = new QLabel(this);
- labelGameResult->setFont(*font14);
- pageLayout->addWidget(labelGameResult, 0, 1);
+ labelGameStats = new QLabel(this);
+ labelGameStats->setTextFormat(Qt::RichText);
+ pageLayout->addWidget(labelGameStats, 0, 0, 1, 3);
}
--- a/QTfrontend/pages.h Thu Jan 04 16:27:45 2007 +0000
+++ b/QTfrontend/pages.h Thu Jan 04 18:54:24 2007 +0000
@@ -209,7 +209,7 @@
PageGameStats(QWidget* parent = 0);
QPushButton *BtnBack;
- QLabel *labelGameResult;
+ QLabel *labelGameStats;
};
--- a/hedgewars/uConsts.pas Thu Jan 04 16:27:45 2007 +0000
+++ b/hedgewars/uConsts.pas Thu Jan 04 18:54:24 2007 +0000
@@ -62,7 +62,7 @@
TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpNetSay, capgrpVolume);
- TStatInfoType = (siGameResult);
+ TStatInfoType = (siGameResult, siMaxStepDamage, siKilledHHs);
THHFont = record
Handle: PTTF_Font;
--- a/hedgewars/uGears.pas Thu Jan 04 16:27:45 2007 +0000
+++ b/hedgewars/uGears.pas Thu Jan 04 18:54:24 2007 +0000
@@ -64,6 +64,7 @@
var CurAmmoGear: PGear = nil;
GearsList: PGear = nil;
+ KilledHHs: Longword = 0;
implementation
uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
@@ -77,6 +78,7 @@
b: boolean;
end;
end;
+ StepDamage: Longword = 0;
procedure DeleteGear(Gear: PGear); forward;
procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
@@ -275,6 +277,7 @@
procedure DeleteGear(Gear: PGear);
var team: PTeam;
+ t: Longword;
begin
if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
if Gear.Surf <> nil then SDL_FreeSurface(Gear.Surf);
@@ -288,11 +291,16 @@
end else
begin
if Gear.Y >= cWaterLine then
- AddGear(Round(Gear.X), Round(Gear.Y), gtHealthTag, max(Gear.Damage, Gear.Health)).Hedgehog:= Gear.Hedgehog;
+ begin
+ t:= max(Gear.Damage, Gear.Health);
+ AddGear(Round(Gear.X), Round(Gear.Y), gtHealthTag, t).Hedgehog:= Gear.Hedgehog;
+ inc(StepDamage, t)
+ end;
team:= PHedgehog(Gear.Hedgehog).Team;
if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then
FreeActionsList; // to avoid ThinkThread on drawned gear
PHedgehog(Gear.Hedgehog).Gear:= nil;
+ inc(KilledHHs);
RecountTeamHealth(team);
end;
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF}
@@ -313,6 +321,7 @@
if Gear.Damage <> 0 then
begin
Result:= false;
+ inc(StepDamage, Gear.Damage);
if Gear.Health < Gear.Damage then Gear.Health:= 0
else dec(Gear.Health, Gear.Damage);
AddGear(Round(Gear.X), round(Gear.Y) - cHHRadius - 12 - PHedgehog(Gear.Hedgehog)^.HealthTag.h,
@@ -374,7 +383,12 @@
stNTurn: begin
AwareOfExplosion(0, 0, 0);
if isInMultiShoot then isInMultiShoot:= false
- else ParseCommand('/nextturn');
+ else begin
+ with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+ if MaxStepDamage < StepDamage then MaxStepDamage:= StepDamage;
+ StepDamage:= 0;
+ ParseCommand('/nextturn');
+ end;
step:= Low(step)
end;
end;
@@ -673,9 +687,11 @@
procedure AmmoShove(Ammo: PGear; Damage, Power: integer);
var t: PGearArray;
i: integer;
+ hh: PHedgehog;
begin
t:= CheckGearsCollision(Ammo);
i:= t.Count;
+hh:= Ammo.Hedgehog;
while i > 0 do
begin
dec(i);
@@ -685,6 +701,7 @@
gtMine,
gtCase: begin
inc(t.ar[i].Damage, Damage);
+ inc(hh.DamageGiven, Damage);
t.ar[i].dX:= Ammo.dX * Power * 0.01;
t.ar[i].dY:= Ammo.dY * Power * 0.01;
t.ar[i].Active:= true;
--- a/hedgewars/uMisc.pas Thu Jan 04 16:27:45 2007 +0000
+++ b/hedgewars/uMisc.pas Thu Jan 04 18:54:24 2007 +0000
@@ -220,7 +220,7 @@
end;
procedure SendStat(sit: TStatInfoType; s: shortstring);
-const stc: array [TStatInfoType] of char = 'r';
+const stc: array [TStatInfoType] of char = 'rDK';
begin
SendIPC('i' + stc[sit] + s)
end;
--- a/hedgewars/uTeams.pas Thu Jan 04 16:27:45 2007 +0000
+++ b/hedgewars/uTeams.pas Thu Jan 04 18:54:24 2007 +0000
@@ -34,6 +34,8 @@
AttacksNum: Longword;
visStepPos: LongWord;
BotLevel : LongWord; // 0 - Human player
+ DamageGiven: Longword;
+ MaxStepDamage: Longword;
end;
TTeam = record
Next: PTeam;
@@ -67,6 +69,7 @@
procedure RestoreTeamsFromSave;
function CheckForWin: boolean;
procedure SetWeapon(weap: TAmmoType);
+procedure SendStats;
implementation
uses uMisc, uWorld, uAI, uLocale, uConsole;
@@ -109,6 +112,7 @@
SendStat(siGameResult, s);
AddGear(0, 0, gtATFinishGame, 0, 0, 0, 2000)
end;
+SendStats
end;
procedure SwitchHedgehog;
@@ -317,6 +321,28 @@
end
end;
+procedure SendStats;
+var p: PTeam;
+ i: integer;
+ msd: Longword; msdhh: PHedgehog;
+begin
+msd:= 0; msdhh:= nil;
+p:= TeamsList;
+while p <> nil do
+ begin
+ for i:= 0 to cMaxHHIndex do
+ if p.Hedgehogs[i].MaxStepDamage > msd then
+ begin
+ msdhh:= @p.Hedgehogs[i];
+ msd:= p.Hedgehogs[i].MaxStepDamage
+ end;
+ p:= p.Next
+ end;
+if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msdhh.MaxStepDamage) + ' ' +
+ msdhh.Name + ' (' + msdhh.Team.TeamName + ')');
+if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
+end;
+
initialization
finalization