diff --git a/binaries/data/mods/public/simulation/ai/common-api/entity.js b/binaries/data/mods/public/simulation/ai/common-api/entity.js index 5b16bb4a6b..b6b38aacc1 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/entity.js +++ b/binaries/data/mods/public/simulation/ai/common-api/entity.js @@ -717,27 +717,24 @@ m.Entity = m.Class({ if (this.unitAIOrderData().length && (this.unitAIState().split(".")[1] === "GATHER" || this.unitAIState().split(".")[1] === "RETURNRESOURCE")) { - var ress = undefined; + let res; // this is an abuse of "_ai" but it works. if (this.unitAIState().split(".")[1] === "GATHER" && this.unitAIOrderData()[0]["target"] !== undefined) - ress = this._ai._entities.get(this.unitAIOrderData()[0]["target"]); + res = this._ai._entities.get(this.unitAIOrderData()[0]["target"]); else if (this.unitAIOrderData()[1] !== undefined && this.unitAIOrderData()[1]["target"] !== undefined) - ress = this._ai._entities.get(this.unitAIOrderData()[1]["target"]); - - if (ress == undefined) + res = this._ai._entities.get(this.unitAIOrderData()[1]["target"]); + if (res === undefined) return undefined; - var type = ress.resourceSupplyType(); - var tstring = type.generic + "." + type.specific; - - if (type.generic == "treasure") + let type = res.resourceSupplyType(); + if (type.generic === "treasure") return 1000; - var speed = +this.get("ResourceGatherer/BaseSpeed"); - speed *= +this.get("ResourceGatherer/Rates/" +tstring); - - if (speed) - return speed; + let tstring = type.generic + "." + type.specific; + let rate = +this.get("ResourceGatherer/BaseSpeed"); + rate *= +this.get("ResourceGatherer/Rates/" +tstring); + if (rate) + return rate; return 0; } return undefined; 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 072e8ee663..1648dcc484 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/gamestate.js +++ b/binaries/data/mods/public/simulation/ai/common-api/gamestate.js @@ -9,9 +9,6 @@ var API3 = function(m) m.GameState = function() { this.ai = null; // must be updated by the AIs. this.cellSize = 4.0; // Size of each map tile - - this.buildingsBuilt = 0; - this.turnCache = {}; }; m.GameState.prototype.init = function(SharedScript, state, player) { @@ -40,9 +37,6 @@ m.GameState.prototype.update = function(SharedScript, state) { this.playerData = SharedScript.playersData[this.player]; this.techModifications = SharedScript._techModifications[this.player]; this.barterPrices = SharedScript.barterPrices; - - this.buildingsBuilt = 0; - this.turnCache = {}; }; m.GameState.prototype.updatingCollection = function(id, filter, collection)