Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/entity.js
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | if (techRequired == "phase_town") | ||||
return 2; | return 2; | ||||
if (techRequired == "phase_city") | if (techRequired == "phase_city") | ||||
return 3; | return 3; | ||||
if (techRequired.startsWith("phase_")) | if (techRequired.startsWith("phase_")) | ||||
return 4; | return 4; | ||||
return 0; | return 0; | ||||
}, | }, | ||||
"cost": function(productionQueue) { | "cost": function(trainer) { | ||||
if (!this.get("Cost")) | if (!this.get("Cost")) | ||||
return {}; | return {}; | ||||
let ret = {}; | const ret = {}; | ||||
for (let type in this.get("Cost/Resources")) | for (const type in this.get("Cost/Resources")) | ||||
{ | |||||
ret[type] = +this.get("Cost/Resources/" + type); | ret[type] = +this.get("Cost/Resources/" + type); | ||||
if (trainer) | |||||
ret[type] *= trainer.trainCostMultiplier(type); | |||||
} | |||||
return ret; | return ret; | ||||
}, | }, | ||||
"costSum": function(productionQueue) { | "costSum": function(trainer) { | ||||
let cost = this.cost(productionQueue); | const cost = this.cost(trainer); | ||||
if (!cost) | if (!cost) | ||||
return 0; | return 0; | ||||
let ret = 0; | let ret = 0; | ||||
for (let type in cost) | for (let type in cost) | ||||
ret += cost[type]; | ret += cost[type]; | ||||
return ret; | return ret; | ||||
}, | }, | ||||
"techCostMultiplier": function(type) { | "techCostMultiplier": function(type) { | ||||
return +(this.get("Researcher/TechCostMultiplier/"+type) || 1); | return +(this.get("Researcher/TechCostMultiplier/"+type) || 1); | ||||
}, | }, | ||||
"trainCostMultiplier": function(type) { | |||||
return +(this.get("Trainer/TrainCostMultiplier/" + type) || 1); | |||||
Silier: ^ | |||||
}, | |||||
/** | /** | ||||
* Returns { "max": max, "min": min } or undefined if no obstruction. | * Returns { "max": max, "min": min } or undefined if no obstruction. | ||||
* max: radius of the outer circle surrounding this entity's obstruction shape | * max: radius of the outer circle surrounding this entity's obstruction shape | ||||
* min: radius of the inner circle | * min: radius of the inner circle | ||||
*/ | */ | ||||
"obstructionRadius": function() { | "obstructionRadius": function() { | ||||
if (!this.get("Obstruction")) | if (!this.get("Obstruction")) | ||||
return undefined; | return undefined; | ||||
▲ Show 20 Lines • Show All 885 Lines • ▼ Show 20 Lines | m.Entity = m.Class({ | ||||
"removeGuard": function() { | "removeGuard": function() { | ||||
Engine.PostCommand(PlayerID, { "type": "remove-guard", "entities": [this.id()] }); | Engine.PostCommand(PlayerID, { "type": "remove-guard", "entities": [this.id()] }); | ||||
return this; | return this; | ||||
} | } | ||||
}); | }); | ||||
return m; | return m; | ||||
}(API3); | }(API3); | ||||
Lint: no-use-before-define 'API3' was used before it was defined. Lint: no-use-before-define: 'API3' was used before it was defined. |
Wildfire Games · Phabricator
^