Skip to content

Fix/warship freezing no path#4151

Open
Katokoda wants to merge 4 commits into
openfrontio:mainfrom
Katokoda:fix/warship-freezing-no-path
Open

Fix/warship freezing no path#4151
Katokoda wants to merge 4 commits into
openfrontio:mainfrom
Katokoda:fix/warship-freezing-no-path

Conversation

@Katokoda
Copy link
Copy Markdown

@Katokoda Katokoda commented Jun 3, 2026

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:

  • 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

Katokoda added 2 commits June 3, 2026 21:52
…current water component - Warship rejects new PatrolTile when in a different water component
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 3, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd43ca30-fc4f-4c49-82ca-386ecf70ae0f

📥 Commits

Reviewing files that changed from the base of the PR and between a7f46ef and bbfced6.

📒 Files selected for processing (1)
  • tests/Warship.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Warship.test.ts

Walkthrough

Adds water-component checks to MoveWarshipExecution: it aborts if the target is not water and skips per-warship patrol updates when the warship's water component differs from the target. A test verifies patrolTile is unchanged when components differ.

Changes

Warship water component validation

Layer / File(s) Summary
Water component connectivity validation
src/core/execution/MoveWarshipExecution.ts
MoveWarshipExecution.init performs an early check: it calls getWaterComponent for the target position and returns early with a warning if the tile is not water. When applying the order to selected warships, it calls hasWaterComponent to ensure the warship's current water component matches the target before updating patrolTile; otherwise the warship is skipped.
Test: reject patrolTile in disconnected component
tests/Warship.test.ts
Adds a test that mocks game.getWaterComponent/game.hasWaterComponent to place the proposed patrol tile in a different water component and asserts the warship's patrolTile remains unchanged after executing the move.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A ship once sailed toward a distant blue,
But waters split and the path withdrew.
Now checks ask first where seas align,
Patrols stay safe in the water's confine.
Sail on, steady fleet ⚓

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title refers to fixing warship freezing caused by unreachable patrol tiles, which directly matches the main changes in the PR.
Description check ✅ Passed The description accurately explains that warships now reject PatrolTile changes for different water components and adds a corresponding test.
Linked Issues check ✅ Passed The PR implements the core fix from issue #4113 by preventing patrolTile assignments to unreachable water components via connectivity checks.
Out of Scope Changes check ✅ Passed All changes directly address the scope of issue #4113: water-component validation in MoveWarshipExecution and a corresponding test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/Warship.test.ts`:
- Around line 920-950: This test is declared outside the describe("Warship",
...) so it never gets the describe's beforeEach (game and player1 are
undefined); either move this test body into the existing describe("Warship",
...) block so it runs under the same beforeEach, or convert the test to create
its own isolated fixtures by calling the tests/util/Setup.ts helper (setup()) to
obtain a fresh game and player1, then build the Warship via player1.buildUnit,
register WarshipExecution and MoveWarshipExecution, mock
game.getWaterComponent/hasWaterComponent, call executeTicks, and assert
warship.warshipState().patrolTile — reference symbols: describe("Warship"),
setup(), game, player1, player1.buildUnit, WarshipExecution,
MoveWarshipExecution, executeTicks, warship.warshipState().patrolTile.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd86dbd9-f3db-4312-9b94-e0c234333168

📥 Commits

Reviewing files that changed from the base of the PR and between 297e1f5 and a7f46ef.

📒 Files selected for processing (2)
  • src/core/execution/MoveWarshipExecution.ts
  • tests/Warship.test.ts

Comment thread tests/Warship.test.ts Outdated
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Jun 3, 2026
@iiamlewis iiamlewis added this to the v32 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

Warship freezes when patrolTile is too far from the warship's current body of water.

3 participants