Trading in lakes 🚤 (#3653)

## Description:

- Widened port placement and warship spawn/patrol checks from
`isOcean`/`isOceanShore` to `isWater`/`isShore`, so ports can be built
on lake shores and ships can operate on lakes, we discussed it here:

<img width="996" height="423" alt="image"
src="https://github.com/user-attachments/assets/acf1e970-9631-4848-a0ed-6d0470616e1d"
/>

- Filtered `tradingPorts()` by water component so ports only attempt
trades with reachable ports - prevents silent path-not-found failures
across disconnected water bodies
- Applied the same water component filter when a captured trade ship
reroutes to its new owner's nearest port
- Removed the `WaterManager` fallback that force-marked isolated
water-nuked-tiles as ocean (no longer needed since lakes are now
navigable)
- Added a check to prevent nations from building ports on water bodies
that aren't accessible to other players

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

FloPinguin

---------

Co-authored-by: Evan <evanpelle@gmail.com>
This commit is contained in:
FloPinguin
2026-04-13 02:18:52 +02:00
committed by GitHub
parent 6c836b00e5
commit 17c1a6300f
10 changed files with 86 additions and 75 deletions
+13 -15
View File
@@ -109,15 +109,15 @@ export class AiAttackBehavior {
return;
}
// Check if we have any ocean shore tiles to launch from
const oceanShore = Array.from(this.player.borderTiles()).filter((t) =>
this.game.isOceanShore(t),
// Check if we have any shore tiles to launch from
const shore = Array.from(this.player.borderTiles()).filter((t) =>
this.game.isShore(t),
);
if (oceanShore.length === 0) {
if (shore.length === 0) {
return;
}
const src = this.random.randElement(oceanShore);
const src = this.random.randElement(shore);
// First look for high-interest targets (unowned or bot-owned). Mainly relevant for earlygame
let dst = this.findRandomBoatTarget(src, borderingEnemies, true);
@@ -574,11 +574,11 @@ export class AiAttackBehavior {
return null;
}
// Check if we have any ocean shore tiles to launch from
const hasOceanShore = Array.from(this.player.borderTiles()).some((t) =>
this.game.isOceanShore(t),
// Check if we have any shore tiles to launch from
const hasShore = Array.from(this.player.borderTiles()).some((t) =>
this.game.isShore(t),
);
if (!hasOceanShore) return null;
if (!hasShore) return null;
const filteredPlayers = this.game.players().filter((p) => {
if (p === this.player) return false;
@@ -615,10 +615,10 @@ export class AiAttackBehavior {
const closest = closestTwoTiles(
this.game,
Array.from(this.player.borderTiles()).filter((t) =>
this.game.isOceanShore(t),
this.game.isShore(t),
),
Array.from(entry.player.borderTiles()).filter((t) =>
this.game.isOceanShore(t),
this.game.isShore(t),
),
);
if (closest === null) continue;
@@ -786,10 +786,8 @@ export class AiAttackBehavior {
private sendBoatAttack(target: Player) {
const closest = closestTwoTiles(
this.game,
Array.from(this.player.borderTiles()).filter((t) =>
this.game.isOceanShore(t),
),
Array.from(target.borderTiles()).filter((t) => this.game.isOceanShore(t)),
Array.from(this.player.borderTiles()).filter((t) => this.game.isShore(t)),
Array.from(target.borderTiles()).filter((t) => this.game.isShore(t)),
);
if (closest === null) {
return;