Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if (this.Config.debug > 0) | ||||
gameState.getPlayerCiv() + " but no template found."); | gameState.getPlayerCiv() + " but no template found."); | ||||
return; | return; | ||||
} | } | ||||
queues.trader.addPlan(new m.TrainingPlan(gameState, template, metadata, 1, 1)); | queues.trader.addPlan(new m.TrainingPlan(gameState, template, metadata, 1, 1)); | ||||
}; | }; | ||||
m.TradeManager.prototype.updateTrader = function(gameState, ent) | m.TradeManager.prototype.updateTrader = function(gameState, ent) | ||||
{ | { | ||||
if (ent.hasClass("Ship") && gameState.ai.playedTurn % 5 === 0 && | |||||
!ent.unitAIState().startsWith("INDIVIDUAL.GATHER") && | |||||
m.gatherTreasure(gameState, ent, true)) | |||||
return; | |||||
if (!this.hasTradeRoute() || !ent.isIdle() || !ent.position()) | if (!this.hasTradeRoute() || !ent.isIdle() || !ent.position()) | ||||
return; | return; | ||||
if (ent.getMetadata(PlayerID, "transport") !== undefined) | if (ent.getMetadata(PlayerID, "transport") !== undefined) | ||||
return; | return; | ||||
// TODO if the trader is idle and has workOrders, restore them to avoid losing the current gain | |||||
Engine.ProfileStart("Trade Manager"); | Engine.ProfileStart("Trade Manager"); | ||||
let access = ent.hasClass("Ship") ? ent.getMetadata(PlayerID, "sea") : gameState.ai.accessibility.getAccessValue(ent.position()); | let access = ent.hasClass("Ship") ? ent.getMetadata(PlayerID, "sea") : gameState.ai.accessibility.getAccessValue(ent.position()); | ||||
let route = this.checkRoutes(gameState, access); | let route = this.checkRoutes(gameState, access); | ||||
if (!route) | if (!route) | ||||
{ | { | ||||
// TODO try to garrison land trader inside merchant ship when only sea routes available | // TODO try to garrison land trader inside merchant ship when only sea routes available | ||||
if (this.Config.debug > 0) | if (this.Config.debug > 0) | ||||
API3.warn(" no available route for " + ent.genericName() + " " + ent.id()); | API3.warn(" no available route for " + ent.genericName() + " " + ent.id()); | ||||
▲ Show 20 Lines • Show All 549 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator