Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/gamestate.js
Show First 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
m.GameState.prototype.getFishableSupplies = function() | m.GameState.prototype.getFishableSupplies = function() | ||||
{ | { | ||||
return this.updatingGlobalCollection("resource-fish", m.Filters.isFishable(), this.getEntities()); | return this.updatingGlobalCollection("resource-fish", m.Filters.isFishable(), this.getEntities()); | ||||
}; | }; | ||||
/** This returns only units from buildings. */ | /** This returns only units from buildings. */ | ||||
m.GameState.prototype.findTrainableUnits = function(classes, anticlasses) | m.GameState.prototype.findTrainableUnits = function(classes) | ||||
{ | { | ||||
let allTrainable = []; | let allTrainable = []; | ||||
let civ = this.playerData.civ; | let civ = this.playerData.civ; | ||||
this.getOwnTrainingFacilities().forEach(function(ent) { | this.getOwnTrainingFacilities().forEach(function(ent) { | ||||
let trainable = ent.trainableEntities(civ); | let trainable = ent.trainableEntities(civ); | ||||
if (!trainable) | if (!trainable) | ||||
return; | return; | ||||
for (let unit of trainable) | for (let unit of trainable) | ||||
Show All 9 Lines | for (let trainable of allTrainable) | ||||
if (this.isTemplateDisabled(trainable)) | if (this.isTemplateDisabled(trainable)) | ||||
continue; | continue; | ||||
let template = this.getTemplate(trainable); | let template = this.getTemplate(trainable); | ||||
if (!template || !template.available(this)) | if (!template || !template.available(this)) | ||||
continue; | continue; | ||||
let limit = template.matchLimit(); | let limit = template.matchLimit(); | ||||
if (matchCounts && limit && matchCounts[trainable] >= limit) | if (matchCounts && limit && matchCounts[trainable] >= limit) | ||||
continue; | continue; | ||||
if (classes.some(c => !template.hasClass(c))) | if (!template.hasClasses(classes)) | ||||
continue; | |||||
if (anticlasses.some(c => template.hasClass(c))) | |||||
continue; | continue; | ||||
let category = template.trainingCategory(); | let category = template.trainingCategory(); | ||||
if (category && limits[category] && current[category] >= limits[category]) | if (category && limits[category] && current[category] >= limits[category]) | ||||
continue; | continue; | ||||
ret.push([trainable, template]); | ret.push([trainable, template]); | ||||
} | } | ||||
return ret; | return ret; | ||||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | if (supportTraderTemplate) | ||||
ret.landGainMultiplier = norm * supportTraderTemplate.gainMultiplier(); | ret.landGainMultiplier = norm * supportTraderTemplate.gainMultiplier(); | ||||
if (shipMerchantTemplate) | if (shipMerchantTemplate) | ||||
ret.navalGainMultiplier = norm * shipMerchantTemplate.gainMultiplier(); | ret.navalGainMultiplier = norm * shipMerchantTemplate.gainMultiplier(); | ||||
return ret; | return ret; | ||||
}; | }; | ||||
return m; | return m; | ||||
}(API3); | }(API3); | ||||
Lint: no-use-before-define: 'API3' was used before it was defined. | |||||
Wildfire Games · Phabricator
'API3' was used before it was defined.