Differential D2952 Diff 14052 ps/trunk/binaries/data/mods/public/simulation/ai/petra/navalManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/navalManager.js
Show First 20 Lines • Show All 709 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (!gameState.ai.HQ.navalMap || !gameState.ai.HQ.baseManagers[1]) | if (!gameState.ai.HQ.navalMap || !gameState.ai.HQ.baseManagers[1]) | ||||
return; | return; | ||||
if (gameState.ai.HQ.getAccountedPopulation(gameState) > this.Config.Economy.popForDock) | if (gameState.ai.HQ.getAccountedPopulation(gameState) > this.Config.Economy.popForDock) | ||||
{ | { | ||||
if (queues.dock.countQueuedUnitsWithClass("Dock") === 0 && | if (queues.dock.countQueuedUnitsWithClass("Dock") === 0 && | ||||
!gameState.getOwnStructures().filter(API3.Filters.and(API3.Filters.byClass("Dock"), API3.Filters.isFoundation())).hasEntities() && | !gameState.getOwnStructures().filter(API3.Filters.and(API3.Filters.byClass("Dock"), API3.Filters.isFoundation())).hasEntities() && | ||||
gameState.ai.HQ.canBuild(gameState, "structures/{civ}_dock")) | gameState.ai.HQ.canBuild(gameState, "structures/{civ}/dock")) | ||||
{ | { | ||||
let dockStarted = false; | let dockStarted = false; | ||||
for (let base of gameState.ai.HQ.baseManagers) | for (let base of gameState.ai.HQ.baseManagers) | ||||
{ | { | ||||
if (dockStarted) | if (dockStarted) | ||||
break; | break; | ||||
if (!base.anchor || base.constructing) | if (!base.anchor || base.constructing) | ||||
continue; | continue; | ||||
let remaining = this.getUnconnectedSeas(gameState, base.accessIndex); | let remaining = this.getUnconnectedSeas(gameState, base.accessIndex); | ||||
for (let sea of remaining) | for (let sea of remaining) | ||||
{ | { | ||||
if (!gameState.ai.HQ.navalRegions[sea]) | if (!gameState.ai.HQ.navalRegions[sea]) | ||||
continue; | continue; | ||||
let wantedLand = {}; | let wantedLand = {}; | ||||
wantedLand[base.accessIndex] = true; | wantedLand[base.accessIndex] = true; | ||||
queues.dock.addPlan(new PETRA.ConstructionPlan(gameState, "structures/{civ}_dock", { "land": wantedLand, "sea": sea })); | queues.dock.addPlan(new PETRA.ConstructionPlan(gameState, "structures/{civ}/dock", { "land": wantedLand, "sea": sea })); | ||||
dockStarted = true; | dockStarted = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (gameState.currentPhase() < 2 || gameState.ai.HQ.getAccountedPopulation(gameState) < this.Config.Economy.popPhase2 + 15 || | if (gameState.currentPhase() < 2 || gameState.ai.HQ.getAccountedPopulation(gameState) < this.Config.Economy.popPhase2 + 15 || | ||||
queues.militaryBuilding.hasQueuedUnits()) | queues.militaryBuilding.hasQueuedUnits()) | ||||
return; | return; | ||||
if (!this.docks.filter(API3.Filters.byClass("Dock")).hasEntities() || | if (!this.docks.filter(API3.Filters.byClass("Dock")).hasEntities() || | ||||
this.docks.filter(API3.Filters.byClass("Shipyard")).hasEntities()) | this.docks.filter(API3.Filters.byClass("Shipyard")).hasEntities()) | ||||
return; | return; | ||||
// Use in priority resources to build a Market. | // Use in priority resources to build a Market. | ||||
if (!gameState.getOwnEntitiesByClass("Market", true).hasEntities() && | if (!gameState.getOwnEntitiesByClass("Market", true).hasEntities() && | ||||
gameState.ai.HQ.canBuild(gameState, "structures/{civ}_market")) | gameState.ai.HQ.canBuild(gameState, "structures/{civ}/market")) | ||||
return; | return; | ||||
let template; | let template; | ||||
if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}_super_dock")) | if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/super_dock")) | ||||
template = "structures/{civ}_super_dock"; | template = "structures/{civ}/super_dock"; | ||||
else if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}_shipyard")) | else if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/shipyard")) | ||||
template = "structures/{civ}_shipyard"; | template = "structures/{civ}/shipyard"; | ||||
else | else | ||||
return; | return; | ||||
let wantedLand = {}; | let wantedLand = {}; | ||||
for (let base of gameState.ai.HQ.baseManagers) | for (let base of gameState.ai.HQ.baseManagers) | ||||
if (base.anchor) | if (base.anchor) | ||||
wantedLand[base.accessIndex] = true; | wantedLand[base.accessIndex] = true; | ||||
let sea = this.docks.toEntityArray()[0].getMetadata(PlayerID, "sea"); | let sea = this.docks.toEntityArray()[0].getMetadata(PlayerID, "sea"); | ||||
queues.militaryBuilding.addPlan(new PETRA.ConstructionPlan(gameState, template, { "land": wantedLand, "sea": sea })); | queues.militaryBuilding.addPlan(new PETRA.ConstructionPlan(gameState, template, { "land": wantedLand, "sea": sea })); | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator