Skip to content

Commit a91fed0

Browse files
committed
Enhance structure building logic to consider coastal tiles for factory spawning
1 parent 3eafb2c commit a91fed0

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/core/execution/nation/NationStructureBehavior.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export class NationStructureBehavior {
7474
continue;
7575
}
7676

77-
if (this.shouldBuildStructure(structureType, cityCount)) {
77+
if (
78+
this.shouldBuildStructure(structureType, cityCount, hasCoastalTiles)
79+
) {
7880
if (this.maybeSpawnStructure(structureType)) {
7981
return true;
8082
}
@@ -92,14 +94,25 @@ export class NationStructureBehavior {
9294
* Determines if we should build more of this structure type based on
9395
* the current city count and the configured ratio.
9496
*/
95-
private shouldBuildStructure(type: UnitType, cityCount: number): boolean {
97+
private shouldBuildStructure(
98+
type: UnitType,
99+
cityCount: number,
100+
hasCoastalTiles: boolean,
101+
): boolean {
96102
const config = STRUCTURE_RATIOS[type];
97103
if (config === undefined) {
98104
return false;
99105
}
100106

107+
let ratio = config.ratioPerCity;
108+
109+
// Heavily reduce factory spawning if we have coastal tiles
110+
if (type === UnitType.Factory && hasCoastalTiles) {
111+
ratio *= 0.25;
112+
}
113+
101114
const owned = this.player.unitsOwned(type);
102-
const targetCount = Math.floor(cityCount * config.ratioPerCity);
115+
const targetCount = Math.floor(cityCount * ratio);
103116

104117
return owned < targetCount;
105118
}

0 commit comments

Comments
 (0)