From 21798caa45568504761c08ef46b497cf9330d66f Mon Sep 17 00:00:00 2001 From: mimo Date: Mon, 6 Mar 2017 19:23:18 +0000 Subject: [PATCH] petra support of disabled technologies, fixes #4500 Reviewed By: Sandarac Differential Revision: https://code.wildfiregames.com/D178 This was SVN commit r19275. --- .../public/simulation/ai/common-api/gamestate.js | 12 ++++++++---- .../public/simulation/components/GuiInterface.js | 1 + .../simulation/components/tests/test_GuiInterface.js | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/common-api/gamestate.js b/binaries/data/mods/public/simulation/ai/common-api/gamestate.js index 65ff8985e6..99f0065802 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/gamestate.js +++ b/binaries/data/mods/public/simulation/ai/common-api/gamestate.js @@ -203,6 +203,9 @@ m.GameState.prototype.isResearching = function(template) /** this is an "in-absolute" check that doesn't check if we have a building to research from. */ m.GameState.prototype.canResearch = function(techTemplateName, noRequirementCheck) { + if (this.playerData.disabledTechnologies[techTemplateName]) + return false; + let template = this.getTemplate(techTemplateName); if (!template) return false; @@ -739,14 +742,15 @@ m.GameState.prototype.findAvailableTech = function() { let allResearchable = []; let civ = this.playerData.civ; - this.getOwnEntities().forEach(function(ent) { + for (let ent of this.getOwnEntities().values()) + { let searchable = ent.researchableTechs(civ); if (!searchable) - return; + continue; for (let tech of searchable) - if (allResearchable.indexOf(tech) === -1) + if (!this.playerData.disabledTechnologies[tech] && allResearchable.indexOf(tech) === -1) allResearchable.push(tech); - }); + } let ret = []; for (let tech of allResearchable) diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index 63b41e6273..05dae8f2f3 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -106,6 +106,7 @@ GuiInterface.prototype.GetSimulationState = function() "teamsLocked": cmpPlayer.GetLockTeams(), "cheatsEnabled": cmpPlayer.GetCheatsEnabled(), "disabledTemplates": cmpPlayer.GetDisabledTemplates(), + "disabledTechnologies": cmpPlayer.GetDisabledTechnologies(), "hasSharedDropsites": cmpPlayer.HasSharedDropsites(), "hasSharedLos": cmpPlayer.HasSharedLos(), "phase": phase, diff --git a/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js b/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js index 3be85767c9..cc098757fb 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js @@ -107,6 +107,7 @@ AddMock(100, IID_Player, { IsNeutral: function() { return false; }, IsEnemy: function() { return true; }, GetDisabledTemplates: function() { return {}; }, + GetDisabledTechnologies: function() { return {}; }, HasSharedDropsites: function() { return false; }, HasSharedLos: function() { return false; }, }); @@ -191,6 +192,7 @@ AddMock(101, IID_Player, { IsNeutral: function() { return false; }, IsEnemy: function() { return false; }, GetDisabledTemplates: function() { return {}; }, + GetDisabledTechnologies: function() { return {}; }, HasSharedDropsites: function() { return false; }, HasSharedLos: function() { return false; }, }); @@ -275,6 +277,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), { teamsLocked: false, cheatsEnabled: false, disabledTemplates: {}, + disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, phase: "village", @@ -317,6 +320,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), { teamsLocked: false, cheatsEnabled: false, disabledTemplates: {}, + disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, phase: "village", @@ -387,6 +391,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), { teamsLocked: false, cheatsEnabled: false, disabledTemplates: {}, + disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, phase: "village", @@ -442,6 +447,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), { teamsLocked: false, cheatsEnabled: false, disabledTemplates: {}, + disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, phase: "village",