Skip to content

Commit

Permalink
Merge pull request OpenRA#7529 from delftswa2014/feature/kdr_stat
Browse files Browse the repository at this point in the history
Add Kill/Death ratio in statistics window
  • Loading branch information
Mailaender committed Mar 20, 2015
2 parents d7a373f + da546fc commit dc1862f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
7 changes: 7 additions & 0 deletions OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ ScrollItemWidget BasicStats(Player player)
if (stats == null) return template;
template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString();
template.Get<LabelWidget>("DEATHS").GetText = () => (stats.UnitsDead + stats.BuildingsDead).ToString();
template.Get<LabelWidget>("KD_RATIO").GetText = () => KillDeathRatio(stats.UnitsKilled + stats.BuildingsKilled, stats.UnitsDead + stats.BuildingsDead);
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount);

return template;
Expand Down Expand Up @@ -301,6 +302,12 @@ string AverageEarnedPerMinute(double earned)
return "$" + (world.WorldTick == 0 ? 0 : earned / (world.WorldTick / 1500.0)).ToString("F2");
}

string KillDeathRatio(int killed, int dead)
{
var kdr = (float)killed / Math.Max(1.0, dead);
return kdr.ToString("F2");
}

static Color GetPowerColor(PowerState state)
{
if (state == PowerState.Critical) return Color.Red;
Expand Down
18 changes: 16 additions & 2 deletions mods/cnc/chrome/ingame-observerstats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
Font: Bold
Text: Deaths
Align: Right
Label@KD_RATIO_HEADER:
X: 615
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Kills/Deaths
Align: Right
Label@ACTIONS_MIN_HEADER:
X: 655
X: 745
Y: 40
Width: 40
Height: 25
Expand Down Expand Up @@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@KD_RATIO:
X: 595
Y: 0
Width: 80
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN:
X: 635
X: 725
Y: 0
Width: 40
Height: PARENT_BOTTOM
Expand Down
18 changes: 16 additions & 2 deletions mods/ra/chrome/ingame-observerstats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
Font: Bold
Text: Deaths
Align: Right
Label@KD_RATIO_HEADER:
X: 625
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Kills/Deaths
Align: Right
Label@ACTIONS_MIN_HEADER:
X: 665
X: 755
Y: 40
Width: 40
Height: 25
Expand Down Expand Up @@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@KD_RATIO:
X: 595
Y: 0
Width: 80
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN:
X: 635
X: 725
Y: 0
Width: 40
Height: PARENT_BOTTOM
Expand Down

0 comments on commit dc1862f

Please sign in to comment.