Skip to content

Pr naval balance#3327

Open
hkio120 wants to merge 3 commits intoopenfrontio:mainfrom
hkio120:pr-naval-balance
Open

Pr naval balance#3327
hkio120 wants to merge 3 commits intoopenfrontio:mainfrom
hkio120:pr-naval-balance

Conversation

@hkio120
Copy link
Contributor

@hkio120 hkio120 commented Mar 2, 2026

Description:

This PR rebalances naval interactions to make transport-vs-warship engagements less binary and more readable during fights, while keeping the existing combat system intact.
What changed
1. Warship firing cadence adjusted by target type
◦ Warship shell cadence is now context-aware:
▪ Faster cadence against transport ships.
2. Transport hits now apply fixed troop loss
◦ When a shell reaches a transport, damage is resolved primarily through troop loss, using a -8000 troops fixed per-hit amount.

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
  • [x ] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

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

HulKiora

@CLAassistant
Copy link

CLAassistant commented Mar 2, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

Walkthrough

TransportShips gain a maximum health property and warship shell attack rates increase from 20 to 40. Shell execution now applies fixed troop losses to transport targets instead of standard HP damage, and warship firing logic adjusts attack rates based on target type, with special handling for transport ships to prevent immediate one-shot elimination.

Changes

Cohort / File(s) Summary
Configuration Updates
src/core/configuration/DefaultConfig.ts
Added maxHealth property (500) to TransportShip unit info; increased warship shell attack rate from 20 to 40.
Transport Hit Resolution
src/core/execution/ShellExecution.ts
Introduced new private method applyFixedTroopLossOnTransport() that applies fixed troop loss (80000) per shell hit on transport targets. If troops depleted, target is deleted and shell processing ends early; otherwise falls back to standard HP damage logic.
Warship Attack Rate & Targeting
src/core/execution/WarshipExecution.ts
Added null guard for current target in shootTarget(). Implemented target-based attack rate computation: transport targets fire at floor(shellAttackRate/20) capped at 1, while other targets use full rate. Updated oneshot protection to check target health and prevent firing on weakened transports.

Sequence Diagram

sequenceDiagram
    actor Warship
    participant WarshipExecution
    participant ShellExecution
    participant TransportShip

    Warship->>WarshipExecution: shootTarget()
    WarshipExecution->>WarshipExecution: Compute effectiveAttackRate<br/>(reduced for TransportShip)
    alt Firing condition met
        WarshipExecution->>ShellExecution: fireShell(target)
        ShellExecution->>ShellExecution: Shell path completes
        ShellExecution->>TransportShip: Check if target is TransportShip
        alt Is TransportShip
            ShellExecution->>TransportShip: applyFixedTroopLossOnTransport(80000)
            TransportShip->>TransportShip: Reduce troops, check if depleted
            alt Troops depleted
                TransportShip-->>ShellExecution: Signal deletion
                ShellExecution->>ShellExecution: Mark shell reached & remove
            else Troops remain
                ShellExecution->>ShellExecution: Continue to HP damage
            end
        else Not TransportShip
            ShellExecution->>TransportShip: Apply standard HP damage
            ShellExecution->>ShellExecution: Mark shell reached & remove
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

⚔️ Warships now measure their shot,
Transports lose troops, not just health in one blot,
Attack rates recalculate with care,
Ships balance power beyond compare! 🚢✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Pr naval balance' is vague and generic, lacking specific details about the changes made. Use a more descriptive title that clearly identifies the main change, such as 'Adjust naval combat: transport-specific attack rates and fixed troop loss'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the rebalancing of naval interactions, target-dependent firing cadence, and fixed troop loss mechanics.
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.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
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.

🧹 Nitpick comments (2)
src/core/execution/ShellExecution.ts (2)

85-88: Edge case: transport with zero troops is not deleted.

When currentTroops <= 0, the method returns true (shell handled) but the transport is not deleted. If a transport can exist with zero troops, it would remain alive after this hit.

If this is intentional (e.g., transport already marked for deletion elsewhere), this is fine. Otherwise, consider deleting the transport here too:

♻️ Optional: delete transport when already at zero troops
     const currentTroops = this.target.troops();
     if (currentTroops <= 0) {
+      this.target.delete(true, this._owner);
       return true;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/execution/ShellExecution.ts` around lines 85 - 88, The early-return
when currentTroops <= 0 in ShellExecution (using this.target.troops() stored in
currentTroops) leaves a transport object alive; modify the branch so that when
currentTroops <= 0 you also remove/delete the transport (call the appropriate
deletion method on the target/transport manager or mark it for removal) before
returning true; locate the code in the ShellExecution method that reads
currentTroops and ensure you invoke the transport deletion API (e.g.,
this.target.destroy(), this.target.delete(), or the project’s transport removal
helper) then return true.

91-91: Move shell troop loss constant to config for easier balance adjustments.

The code has 80000 as the fixed troop loss per shell hit on transport ships. While the suggestion to move this constant to DefaultConfig (like other balance values such as warshipShellAttackRate()) is reasonable for maintainability, note that balance tuning constants change frequently and do not require code changes if properly configured—this is an optional refactoring for consistency with the existing pattern, not a critical fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/execution/ShellExecution.ts` at line 91, Move the hardcoded
fixedLossPerHit = 80000 into the configuration system: add a new getter (e.g.,
transportShellFixedLoss()) to DefaultConfig alongside existing getters like
warshipShellAttackRate(), update ShellExecution to read
DefaultConfig.transportShellFixedLoss() instead of the literal fixedLossPerHit,
and ensure any tests or call sites referencing fixedLossPerHit are updated to
use the config getter so balance tuning can be changed without code edits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/core/execution/ShellExecution.ts`:
- Around line 85-88: The early-return when currentTroops <= 0 in ShellExecution
(using this.target.troops() stored in currentTroops) leaves a transport object
alive; modify the branch so that when currentTroops <= 0 you also remove/delete
the transport (call the appropriate deletion method on the target/transport
manager or mark it for removal) before returning true; locate the code in the
ShellExecution method that reads currentTroops and ensure you invoke the
transport deletion API (e.g., this.target.destroy(), this.target.delete(), or
the project’s transport removal helper) then return true.
- Line 91: Move the hardcoded fixedLossPerHit = 80000 into the configuration
system: add a new getter (e.g., transportShellFixedLoss()) to DefaultConfig
alongside existing getters like warshipShellAttackRate(), update ShellExecution
to read DefaultConfig.transportShellFixedLoss() instead of the literal
fixedLossPerHit, and ensure any tests or call sites referencing fixedLossPerHit
are updated to use the config getter so balance tuning can be changed without
code edits.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17f32a5 and de58259.

📒 Files selected for processing (3)
  • src/core/configuration/DefaultConfig.ts
  • src/core/execution/ShellExecution.ts
  • src/core/execution/WarshipExecution.ts

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.

2 participants