Skip to content

Fixed pirating not being disabled when a warship's owner has no port in that body of water#4458

Open
TKTK123456 wants to merge 1 commit into
openfrontio:mainfrom
TKTK123456:Warship-bug-fix
Open

Fixed pirating not being disabled when a warship's owner has no port in that body of water#4458
TKTK123456 wants to merge 1 commit into
openfrontio:mainfrom
TKTK123456:Warship-bug-fix

Conversation

@TKTK123456

Copy link
Copy Markdown
Contributor

Before opening a PR: discuss new features on Discord first, and file bugs or small improvements as issues. You must be assigned to an approved issue — unsolicited PRs will be auto-closed.

Add approved & assigned issue number here:

Resolves #4291

Description:

Fixes pirating not being disabled when a warship's owner has no port in that body of water

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

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

tktk1234567

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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: 06464599-ebae-458a-b51a-3d3dd1596f53

📥 Commits

Reviewing files that changed from the base of the PR and between 0d2179f and 0a8751a.

📒 Files selected for processing (1)
  • src/core/execution/WarshipExecution.ts

Walkthrough

In WarshipExecution.findBestTarget, the trade-ship targeting filter now checks water-component reachability. The old hasPort variable (based on owner.unitCount(UnitType.Port) > 0) is replaced by hasReachablePort, which scans owner ports and verifies mg.hasWaterComponent(port.tile(), warshipComponent) before allowing piracy.

Changes

Warship Piracy Reachability Gate

Layer / File(s) Summary
Water-component reachability filter
src/core/execution/WarshipExecution.ts
hasPort variable renamed to hasReachablePort; filter now computes warshipComponent from the warship tile and iterates owner ports checking mg.hasWaterComponent to confirm a reachable port exists in the same water body before allowing trade-ship targeting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • evanpelle

Poem

⚓ A warship prowls the open sea,
But now it checks — "Can I reach thee?"
No port nearby? Then sails stay still,
No pirate raid, no stolen bill.
Water bodies keep their peace! 🌊

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: disabling pirating when the owner lacks a port in that water body.
Description check ✅ Passed The description matches the bug fix and linked issue, and it is consistent with the code change.
Linked Issues check ✅ Passed The change gates pirating on a reachable owner port in the same water body, matching #4291's expected behavior.
Out of Scope Changes check ✅ Passed No unrelated changes are evident; the diff stays focused on warship targeting and pirating eligibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@ryanbarlow97 ryanbarlow97 added this to the v33 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Pirating is not disabled when the warship's owner has no port in that body of water

2 participants