mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-29 03:44:40 +00:00
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:
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user