Page MenuHomeWildfire Games
Authored By
elexis
Sep 30 2017, 3:48 PM
Size
10 KB
Referenced Files
None
Subscribers
None

D567.diff

Index: binaries/data/mods/public/gui/summary/counters.js
===================================================================
--- binaries/data/mods/public/gui/summary/counters.js (revision 20238)
+++ binaries/data/mods/public/gui/summary/counters.js (working copy)
@@ -329,7 +329,37 @@ function calculateMiscellaneousTeam(team
return calculatePercent(g_TeamHelperData[team].femaleCitizen[index], g_TeamHelperData[team].worker[index]);
if (type == "killDeath")
return calculateRatio(g_TeamHelperData[team].enemyUnitsKilled[index], g_TeamHelperData[team].unitsLost[index]);
+ if (type == "bribes")
+ return calculateBribesTeam(team, index, type);
+
return { "percent": g_TeamHelperData[team][type][index] };
}
+
+function calculateBribes(playerState, index, type)
+{
+ return {
+ "succeeded": playerState.sequences.successfulBribes[index],
+ "failed": playerState.sequences.failedBribes[index]
+ };
+}
+
+function calculateBribesTeam(team, index, type)
+{
+ let teamBribesStats = {
+ "succeeded": 0,
+ "failed": 0
+ }
+ for (let i = 0; i < g_PlayerCount; ++i)
+ {
+ let playerState = g_GameData.sim.playerStates[i + 1];
+ if (playerState.team == team)
+ {
+ teamBribesStats.succeeded += playerState.sequences.successfulBribes[index];
+ teamBribesStats.failed += playerState.sequences.failedBribes[index];
+ }
+ }
+
+ return teamBribesStats;
+};
Index: binaries/data/mods/public/gui/summary/layout.js
===================================================================
--- binaries/data/mods/public/gui/summary/layout.js (revision 20238)
+++ binaries/data/mods/public/gui/summary/layout.js (working copy)
@@ -180,19 +180,30 @@ var g_ScorePanelsData = {
"headings": [
{ "identifier": "playername", "caption": translate("Player name"), "yStart": 26, "width": 200 },
{ "identifier": "vegetarianRatio", "caption": translate("Vegetarian ratio"), "yStart": 16, "width": 100 },
{ "identifier": "feminization", "caption": translate("Feminization"), "yStart": 16, "width": 100 },
{ "identifier": "killDeath", "caption": translate("Kill / Death ratio"), "yStart": 16, "width": 100 },
+ {
+ "identifier": "bribes",
+ "caption": sprintf(translate("Bribes \n(%(succeeded)s / %(failed)s)"),
+ {
+ "succeeded": getColoredTypeTranslation("succeeded"),
+ "failed": getColoredTypeTranslation("failed")
+ }),
+ "yStart": 16,
+ "width": 139
+ },
{ "identifier": "mapExploration", "caption": translate("Map exploration"), "yStart": 16, "width": 100 },
{ "identifier": "mapControlPeak", "caption": translate("Map control (peak)"), "yStart": 16, "width": 100 },
{ "identifier": "mapControl", "caption": translate("Map control (finish)"), "yStart": 16, "width": 100 }
],
"titleHeadings": [],
"counters": [
{ "width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12 },
{ "width": 100, "fn": calculateFeminization, "verticalOffset": 12 },
{ "width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12 },
+ { "width": 139, "fn": calculateBribes, "verticalOffset": 12 },
{ "width": 100, "fn": calculateMapExploration, "verticalOffset": 12 },
{ "width": 100, "fn": calculateMapPeakControl, "verticalOffset": 12 },
{ "width": 100, "fn": calculateMapFinalControl, "verticalOffset": 12 }
],
"teamCounterFn": calculateMiscellaneousTeam
Index: binaries/data/mods/public/gui/summary/summary.js
===================================================================
--- binaries/data/mods/public/gui/summary/summary.js (revision 20238)
+++ binaries/data/mods/public/gui/summary/summary.js (working copy)
@@ -56,10 +56,15 @@ var g_SummaryTypes = {
"captured": {
"color": g_TypeColors.yellow,
"caption": translate("Captured"),
"postfix": " / "
},
+ "succeeded": {
+ "color": g_TypeColors.green,
+ "caption": translate("Succeeded"),
+ "postfix": " / "
+ },
"destroyed": {
"color": g_TypeColors.blue,
"caption": translate("Destroyed"),
"postfix": "\n"
},
@@ -90,10 +95,15 @@ var g_SummaryTypes = {
},
"outcome": {
"color": g_TypeColors.red,
"caption": translate("Outcome"),
"postfix": "\n"
+ },
+ "failed": {
+ "color": g_TypeColors.red,
+ "caption": translate("Failed"),
+ "postfix": "\n"
}
};
/**
* Translation: Unicode encoded infinity symbol indicating a division by zero in the summary screen.
Index: binaries/data/mods/public/maps/random/unknown.js
===================================================================
--- binaries/data/mods/public/maps/random/unknown.js (revision 20238)
+++ binaries/data/mods/public/maps/random/unknown.js (working copy)
@@ -67,11 +67,11 @@ var clLand = createTileClass();
var clShallow = createTileClass();
initTerrain(tWater);
var iberianTowers = false;
-var md = randIntInclusive(1,13);
+var md = 6//randIntInclusive(1,13);
var needsAdditionalWood = false;
//*****************************************************************************************************************************
if (md == 1) //archipelago and island
{
needsAdditionalWood = true;
Index: binaries/data/mods/public/simulation/components/StatisticsTracker.js
===================================================================
--- binaries/data/mods/public/simulation/components/StatisticsTracker.js (revision 20238)
+++ binaries/data/mods/public/simulation/components/StatisticsTracker.js (working copy)
@@ -143,10 +143,12 @@ StatisticsTracker.prototype.Init = funct
this.tradeIncome = 0;
this.treasuresCollected = 0;
this.lootCollected = 0;
this.peakPercentMapControlled = 0;
this.teamPeakPercentMapControlled = 0;
+ this.successfulBribes = 0;
+ this.failedBribes = 0;
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
this.updateTimer = cmpTimer.SetInterval(
this.entity, IID_StatisticsTracker, "UpdateSequences", 0, g_UpdateSequenceInterval);
};
@@ -203,11 +205,13 @@ StatisticsTracker.prototype.GetStatistic
"percentMapExplored": this.GetPercentMapExplored(),
"teamPercentMapExplored": this.GetTeamPercentMapExplored(),
"percentMapControlled": this.GetPercentMapControlled(),
"teamPercentMapControlled": this.GetTeamPercentMapControlled(),
"peakPercentMapControlled": this.peakPercentMapControlled,
- "teamPeakPercentMapControlled": this.teamPeakPercentMapControlled
+ "teamPeakPercentMapControlled": this.teamPeakPercentMapControlled,
+ "successfulBribes": this.successfulBribes,
+ "failedBribes": this.failedBribes
};
};
StatisticsTracker.prototype.GetSequences = function()
{
@@ -460,10 +464,20 @@ StatisticsTracker.prototype.IncreaseTrib
StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount)
{
this.tradeIncome += amount;
};
+StatisticsTracker.prototype.IncreaseSuccessfulBribesCounter = function()
+{
+ ++this.successfulBribes;
+};
+
+StatisticsTracker.prototype.IncreaseFailedBribesCounter = function()
+{
+ ++this.failedBribes;
+};
+
StatisticsTracker.prototype.GetPercentMapExplored = function()
{
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
return cmpRangeManager.GetPercentMapExplored(cmpPlayer.GetPlayerID());
Index: binaries/data/mods/public/simulation/components/VisionSharing.js
===================================================================
--- binaries/data/mods/public/simulation/components/VisionSharing.js (revision 20238)
+++ binaries/data/mods/public/simulation/components/VisionSharing.js (working copy)
@@ -147,10 +147,15 @@ VisionSharing.prototype.AddSpy = functio
cmpTimer.SetTimeout(this.entity, IID_VisionSharing, "RemoveSpy", duration * 1000, { "id": this.spyId });
}
this.Activate();
this.CheckVisionSharings();
+ // update statistics for successful bribes
+ let cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker);
+ if (cmpBribesStatisticsTracker)
+ cmpBribesStatisticsTracker.IncreaseSuccessfulBribesCounter();
+
return this.spyId;
};
VisionSharing.prototype.RemoveSpy = function(data)
{
Index: binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js
===================================================================
--- binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js (revision 20238)
+++ binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js (working copy)
@@ -4,10 +4,11 @@ Engine.LoadHelperScript("Commands.js");
Engine.LoadComponentScript("interfaces/GarrisonHolder.js");
Engine.LoadComponentScript("interfaces/TechnologyManager.js");
Engine.LoadComponentScript("interfaces/AuraManager.js");
Engine.LoadComponentScript("interfaces/Timer.js");
Engine.LoadComponentScript("interfaces/VisionSharing.js");
+Engine.LoadComponentScript("interfaces/StatisticsTracker.js");
Engine.LoadComponentScript("VisionSharing.js");
const ent = 170;
let template = {
"Bribable": "true"
@@ -130,10 +131,14 @@ AddMock(14, IID_TechnologyManager, {
});
AddMock(14, IID_Player, {
"GetSpyCostMultiplier": () => 1,
"TrySubtractResources": costs => false
});
+AddMock(4, IID_StatisticsTracker, {
+ "IncreaseSuccessfulBribesCounter": () => {},
+ "IncreaseFailedBribesCounter": ()
+});
cmpVisionSharing.AddSpy(4, 25);
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.shared], [1, 2, 5]);
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.spies], [[5, 2], [17, 5]]);
TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20);
Index: binaries/data/mods/public/simulation/helpers/Commands.js
===================================================================
--- binaries/data/mods/public/simulation/helpers/Commands.js (revision 20238)
+++ binaries/data/mods/public/simulation/helpers/Commands.js (working copy)
@@ -793,10 +793,14 @@ var g_Commands = {
}
else
{
let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy");
IncurBribeCost(template, player, cmd.player, true);
+ // update statistics for failed bribes
+ let cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker);
+ if (cmpBribesStatisticsTracker)
+ cmpBribesStatisticsTracker.IncreaseFailedBribesCounter();
cmpGUIInterface.PushNotification({
"type": "text",
"players": [player],
"message": markForTranslation("There are no bribable units"),
"translateMessage": true

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
184582
Default Alt Text
D567.diff (10 KB)

Event Timeline