Fix/warship freezing no path (#4151)

**Add approved & assigned issue number here:**
Resolves #4113

## Description:

Warships now reject the PatrolTile change when the new one is a
different water component.
Adds a test ensuring this behavior.

## Please complete the following:

- [x] I have added screenshots for all UI updates
There are none
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
No texts
- [x] I have added relevant tests to the test directory
I also have tested in game and tested that the test does indeed fail if
my fix is not present.

## Please put your Discord username so you can be contacted if a bug or
regression is found:
Katokoda
This commit is contained in:
Katokoda
2026-06-05 22:42:52 +02:00
committed by GitHub
parent 075547b7b6
commit c6296c0bb1
2 changed files with 38 additions and 0 deletions
@@ -13,6 +13,8 @@ export class MoveWarshipExecution implements Execution {
console.warn(`MoveWarshipExecution: position ${this.position} not valid`);
return;
}
// Get water component of new TargetTile for connectivity check
const newPatrolTileWaterComponent = mg.getWaterComponent(this.position);
// Cache warship list and build a lookup map — avoids repeated iteration
const warshipMap = new Map(
this.owner.units(UnitType.Warship).map((u) => [u.id(), u]),
@@ -28,6 +30,10 @@ export class MoveWarshipExecution implements Execution {
console.warn(`MoveWarshipExecution: warship ${unitId} is not active`);
continue;
}
// Do not update the warship's patrolTile if it is in a different Water Component
if (!mg.hasWaterComponent(warship.tile(), newPatrolTileWaterComponent!)) {
continue;
}
warship.updateWarshipState({
patrolTile: this.position,
});