Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/startingStrategy.js
Show First 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | if (!total.canAfford(new API3.Resources(template.cost()))) | ||||||||||||||
for (let ent of gameState.getOwnUnits().values()) | for (let ent of gameState.getOwnUnits().values()) | ||||||||||||||
{ | { | ||||||||||||||
if (!ent.position()) | if (!ent.position()) | ||||||||||||||
continue; | continue; | ||||||||||||||
// If we can get a treasure around, just do it | // If we can get a treasure around, just do it | ||||||||||||||
if (ent.isIdle()) | if (ent.isIdle()) | ||||||||||||||
PETRA.gatherTreasure(gameState, ent); | PETRA.gatherTreasure(gameState, ent); | ||||||||||||||
// Then count the resources from the treasures being collected | // Then count the resources from the treasures being collected | ||||||||||||||
let supplyId = ent.getMetadata(PlayerID, "supply"); | let treasureId = ent.getMetadata(PlayerID, "treasure"); | ||||||||||||||
if (!supplyId) | if (!treasureId) | ||||||||||||||
continue; | continue; | ||||||||||||||
let supply = gameState.getEntityById(supplyId); | let treasure = gameState.getEntityById(treasureId); | ||||||||||||||
if (!supply || supply.resourceSupplyType().generic != "treasure") | if (!treasure) | ||||||||||||||
Stan: Why do we need to check for is treasure? Is it not known? | |||||||||||||||
continue; | continue; | ||||||||||||||
let type = supply.resourceSupplyType().specific; | let types = treasure.treasureResources(); | ||||||||||||||
if (!(type in totalExpected)) | for (let type in types) | ||||||||||||||
continue; | if (type in totalExpected) | ||||||||||||||
totalExpected[type] += supply.resourceSupplyMax(); | totalExpected[type] += types[type]; | ||||||||||||||
// If we can collect enough resources from these treasures, wait for them | // If we can collect enough resources from these treasures, wait for them. | ||||||||||||||
Done Inline Actionsbot is correct wraitii: bot is correct | |||||||||||||||
if (totalExpected.canAfford(new API3.Resources(template.cost()))) | if (totalExpected.canAfford(new API3.Resources(template.cost()))) | ||||||||||||||
Done Inline Actions
Does totalExpected contain more types ? If not you might want to iterate that instead. Stan: Does totalExpected contain more types ? If not you might want to iterate that instead. | |||||||||||||||
Done Inline Actionslet totalExpected = gameState.getResources(); Freagarach: `let totalExpected = gameState.getResources();` | |||||||||||||||
return; | return; | ||||||||||||||
} | } | ||||||||||||||
// not enough resource to build a cc, try with a dock to accumulate resources if none yet | // not enough resource to build a cc, try with a dock to accumulate resources if none yet | ||||||||||||||
if (!this.navalManager.docks.filter(API3.Filters.byClass("Dock")).hasEntities()) | if (!this.navalManager.docks.filter(API3.Filters.byClass("Dock")).hasEntities()) | ||||||||||||||
{ | { | ||||||||||||||
if (gameState.ai.queues.dock.hasQueuedUnits()) | if (gameState.ai.queues.dock.hasQueuedUnits()) | ||||||||||||||
return; | return; | ||||||||||||||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Why do we need to check for is treasure? Is it not known?