mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +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:
@@ -915,4 +915,36 @@ describe("Warship", () => {
|
||||
}
|
||||
expect(tradeShip.owner()).toBe(player1);
|
||||
});
|
||||
|
||||
test("Warship doesn't accept a new patrol tile if in a different water component", async () => {
|
||||
const newPatrolTile = game.ref(coastX + 5, 15);
|
||||
|
||||
const warship = player1.buildUnit(
|
||||
UnitType.Warship,
|
||||
game.ref(coastX + 1, 10),
|
||||
{
|
||||
patrolTile: game.ref(coastX + 1, 10),
|
||||
},
|
||||
);
|
||||
|
||||
game.addExecution(new WarshipExecution(warship));
|
||||
|
||||
// Mock different water components
|
||||
game.getWaterComponent = (tile: TileRef) => {
|
||||
if (tile === newPatrolTile) return 1;
|
||||
return 2;
|
||||
};
|
||||
|
||||
game.hasWaterComponent = (tile: TileRef, component: number) => {
|
||||
return game.getWaterComponent(tile) === component;
|
||||
};
|
||||
|
||||
game.addExecution(
|
||||
new MoveWarshipExecution(player1, [warship.id()], newPatrolTile),
|
||||
);
|
||||
|
||||
executeTicks(game, 10);
|
||||
|
||||
expect(warship.warshipState().patrolTile).toBe(game.ref(coastX + 1, 10));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user