Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/startingStrategy.js
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Assign the starting entities to the different bases | * Assign the starting entities to the different bases | ||||
*/ | */ | ||||
m.HQ.prototype.assignStartingEntities = function(gameState) | m.HQ.prototype.assignStartingEntities = function(gameState) | ||||
{ | { | ||||
for (let ent of gameState.getOwnEntities().values()) | for (let ent of gameState.getOwnEntities().values()) | ||||
{ | { | ||||
// do not affect merchant ship immediately to trade as they may-be useful for transport | // do not affect merchant ship immediately to trade as they may-be useful for transport | ||||
if (ent.hasClass("Trader") && !ent.hasClass("Ship")) | if (MatchesClassList(ent.classes(), ["Trader+!Ship"])) | ||||
Silier: wrong, you need to AND not OR | |||||
this.tradeManager.assignTrader(ent); | this.tradeManager.assignTrader(ent); | ||||
let pos = ent.position(); | let pos = ent.position(); | ||||
if (!pos) | if (!pos) | ||||
{ | { | ||||
// TODO should support recursive garrisoning. Make a warning for now | // TODO should support recursive garrisoning. Make a warning for now | ||||
if (ent.isGarrisonHolder() && ent.garrisoned().length) | if (ent.isGarrisonHolder() && ent.garrisoned().length) | ||||
API3.warn("Petra warning: support for garrisoned units inside garrisoned holders not yet implemented"); | API3.warn("Petra warning: support for garrisoned units inside garrisoned holders not yet implemented"); | ||||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | m.HQ.prototype.buildFirstBase = function(gameState) | ||||
} | } | ||||
if (!this.canBuild(gameState, templateName)) | if (!this.canBuild(gameState, templateName)) | ||||
return; | return; | ||||
// We first choose as startingPoint the point where we have the more units | // We first choose as startingPoint the point where we have the more units | ||||
let startingPoint = []; | let startingPoint = []; | ||||
for (let ent of gameState.getOwnUnits().values()) | for (let ent of gameState.getOwnUnits().values()) | ||||
{ | { | ||||
if (!ent.hasClass("Worker") && !(ent.hasClass("Support") && ent.hasClass("Elephant"))) | if (MatchesClassList(ent.classes(), ["!Worker", "Cavalry"])) | ||||
continue; | continue; | ||||
if (ent.hasClass("Cavalry")) | if (!MatchesClassList(ent.classes(), ["Support+Elephant"])) | ||||
continue; | continue; | ||||
let pos = ent.position(); | let pos = ent.position(); | ||||
if (!pos) | if (!pos) | ||||
{ | { | ||||
let holder = m.getHolder(gameState, ent); | let holder = m.getHolder(gameState, ent); | ||||
if (!holder || !holder.position()) | if (!holder || !holder.position()) | ||||
continue; | continue; | ||||
pos = holder.position(); | pos = holder.position(); | ||||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
wrong, you need to AND not OR