Petra: add missing changes in previous commit

This was SVN commit r16698.
This commit is contained in:
mimo 2015-05-30 19:15:36 +00:00
parent 9408860acc
commit c1594c4bc8
2 changed files with 11 additions and 20 deletions

View file

@ -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;

View file

@ -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)