Differential D2952 Diff 14052 ps/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if (template.hasClass("CivCentre")) | ||||
pos = HQ.findEconomicCCLocation(gameState, template, this.metadata.resource, proximity); | pos = HQ.findEconomicCCLocation(gameState, template, this.metadata.resource, proximity); | ||||
} | } | ||||
else | else | ||||
pos = HQ.findStrategicCCLocation(gameState, template); | pos = HQ.findStrategicCCLocation(gameState, template); | ||||
if (pos) | if (pos) | ||||
return { "x": pos[0], "z": pos[1], "angle": 3*Math.PI/4, "base": 0 }; | return { "x": pos[0], "z": pos[1], "angle": 3*Math.PI/4, "base": 0 }; | ||||
// No possible location, try to build instead a dock in a not-enemy island | // No possible location, try to build instead a dock in a not-enemy island | ||||
let templateName = gameState.applyCiv("structures/{civ}_dock"); | let templateName = gameState.applyCiv("structures/{civ}/dock"); | ||||
if (gameState.ai.HQ.canBuild(gameState, templateName) && !gameState.isTemplateDisabled(templateName)) | if (gameState.ai.HQ.canBuild(gameState, templateName) && !gameState.isTemplateDisabled(templateName)) | ||||
{ | { | ||||
template = gameState.getTemplate(templateName); | template = gameState.getTemplate(templateName); | ||||
if (template && gameState.getResources().canAfford(new API3.Resources(template.cost()))) | if (template && gameState.getResources().canAfford(new API3.Resources(template.cost()))) | ||||
this.buildOverseaDock(gameState, template); | this.buildOverseaDock(gameState, template); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | PETRA.ConstructionPlan.prototype.findGoodPosition = function(gameState) | ||||
// note: not for houses and dropsites who ought to be closer to either each other or a resource. | // note: not for houses and dropsites who ought to be closer to either each other or a resource. | ||||
// also not for fields who can be stacked quite a bit | // also not for fields who can be stacked quite a bit | ||||
let obstructions = PETRA.createObstructionMap(gameState, 0, template); | let obstructions = PETRA.createObstructionMap(gameState, 0, template); | ||||
// obstructions.dumpIm(template.buildPlacementType() + "_obstructions.png"); | // obstructions.dumpIm(template.buildPlacementType() + "_obstructions.png"); | ||||
let radius = 0; | let radius = 0; | ||||
if (template.hasClass("Fortress") || template.hasClass("Arsenal") || | if (template.hasClass("Fortress") || template.hasClass("Arsenal") || | ||||
this.type == gameState.applyCiv("structures/{civ}_elephant_stables")) | this.type == gameState.applyCiv("structures/{civ}/elephant_stables")) | ||||
radius = Math.floor((template.obstructionRadius().max + 8) / obstructions.cellSize); | radius = Math.floor((template.obstructionRadius().max + 8) / obstructions.cellSize); | ||||
else if (template.resourceDropsiteTypes() === undefined && !template.hasClass("House") && | else if (template.resourceDropsiteTypes() === undefined && !template.hasClass("House") && | ||||
!template.hasClass("Field") && !template.hasClass("Market")) | !template.hasClass("Field") && !template.hasClass("Market")) | ||||
radius = Math.ceil((template.obstructionRadius().max + 4) / obstructions.cellSize); | radius = Math.ceil((template.obstructionRadius().max + 4) / obstructions.cellSize); | ||||
else | else | ||||
radius = Math.ceil(template.obstructionRadius().max / obstructions.cellSize); | radius = Math.ceil(template.obstructionRadius().max / obstructions.cellSize); | ||||
let bestTile; | let bestTile; | ||||
▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Lines | PETRA.ConstructionPlan.prototype.getResourcesAround = function(gameState, types, i, radius) | ||||
} | } | ||||
return nbcell ? total / nbcell : 0; | return nbcell ? total / nbcell : 0; | ||||
}; | }; | ||||
PETRA.ConstructionPlan.prototype.isGo = function(gameState) | PETRA.ConstructionPlan.prototype.isGo = function(gameState) | ||||
{ | { | ||||
if (this.goRequirement && this.goRequirement == "houseNeeded") | if (this.goRequirement && this.goRequirement == "houseNeeded") | ||||
{ | { | ||||
if (!gameState.ai.HQ.canBuild(gameState, "structures/{civ}_house")) | if (!gameState.ai.HQ.canBuild(gameState, "structures/{civ}/house")) | ||||
return false; | return false; | ||||
if (gameState.getPopulationMax() <= gameState.getPopulationLimit()) | if (gameState.getPopulationMax() <= gameState.getPopulationLimit()) | ||||
return false; | return false; | ||||
let freeSlots = gameState.getPopulationLimit() - gameState.getPopulation(); | let freeSlots = gameState.getPopulationLimit() - gameState.getPopulation(); | ||||
for (let ent of gameState.getOwnFoundations().values()) | for (let ent of gameState.getOwnFoundations().values()) | ||||
{ | { | ||||
let template = gameState.getBuiltTemplate(ent.templateName()); | let template = gameState.getBuiltTemplate(ent.templateName()); | ||||
if (template) | if (template) | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator