Skip to content

Trade3#3436

Draft
ryanbarlow97 wants to merge 10 commits intomainfrom
trade3
Draft

Trade3#3436
ryanbarlow97 wants to merge 10 commits intomainfrom
trade3

Conversation

@ryanbarlow97
Copy link
Copy Markdown
Contributor

If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)

Description:

Describe the PR.

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
  • 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:

DISCORD_USERNAME

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 15, 2026

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: 1903e7ba-1c18-4341-953a-57e4d56edbd8

📥 Commits

Reviewing files that changed from the base of the PR and between c7c9ed9 and bb7e43a.

📒 Files selected for processing (1)
  • src/core/configuration/DefaultConfig.ts

Walkthrough

Renamed tradeShipSpawnRate second parameter to numPlayerPorts, changed spawn-rate calculation to use player ports, simplified trade ship gold formula, made MIRV cost a fixed value (35,000,000), and removed a timeout wrapper from the startup supervisord invocation.

Changes

Cohort / File(s) Summary
Config API
src/core/configuration/Config.ts, src/core/configuration/DefaultConfig.ts
Renamed tradeShipSpawnRate(..., numTradeShips)(..., numPlayerPorts). DefaultConfig: replaced sigmoid/decay spawn-rate with fixed thresholds, changed final division to /50, simplified tradeShipGold to toInt(10000 + 150 * dist^1.1), and made unitInfo(UnitType.MIRV) cost a fixed 35_000_000 via costWrapper.
Port Execution
src/core/execution/PortExecution.ts
shouldSpawnTradeShip now counts player ports (numPlayerPorts) instead of existing trade ships when calling tradeShipSpawnRate.
Startup Script
startup.sh
Removed the timeout 18h wrapper around /usr/bin/supervisord for the specific openfront.dev/non-main-subdomain branch.

Sequence Diagram(s)

sequenceDiagram
    participant PortExec as PortExecution
    participant Config as Config
    participant Player as PlayerPorts
    participant RNG as Random

    PortExec->>Player: count player ports (numPlayerPorts)
    PortExec->>Config: tradeShipSpawnRate(tradeShipSpawnRejections, numPlayerPorts)
    Config-->>PortExec: spawnRate (number)
    PortExec->>RNG: roll random() per port-level loop
    alt success
        PortExec->>PortExec: spawn trade ship, reset rejections
    else failure
        PortExec->>PortExec: increment tradeShipSpawnRejections
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • use v22 trade meta #2935: Makes the same code-level changes to tradeShipSpawnRate parameter naming, DefaultConfig spawn/gold logic, MIRV cost, and PortExecution counting.

Poem

🚢 Ports now call the tune, not ships adrift,
Gold curves smoothed and MIRV set swift.
A timeout gone, thresholds set true,
Spawn rates hum with a streamlined view. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is an unfilled template with placeholders and no meaningful information about the actual changes made. Replace the template with a clear description of the changes, explain why trade ship spawn rate now uses player port count instead of trade ship count, and complete or remove the checklist items appropriately.
Title check ❓ Inconclusive The title 'Trade3' is vague and does not clearly describe the main changes in the pull request. Use a more descriptive title that summarizes the key changes, such as 'Refactor trade ship spawn logic to use player port count' or 'Update trade ship mechanics for v22 metadata'.
✅ Passed checks (1 passed)
Check name Status Explanation
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: 2

🧹 Nitpick comments (1)
startup.sh (1)

88-92: Redundant conditional: both branches do the same thing.

After removing the timeout wrapper, the if and else branches now execute identical commands. This conditional can be simplified.

♻️ Proposed simplification
-if [ "$DOMAIN" = openfront.dev ] && [ "$SUBDOMAIN" != main ]; then
-    exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
-else
-    exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
-fi
+exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@startup.sh` around lines 88 - 92, The if/else conditional checking DOMAIN and
SUBDOMAIN is redundant because both branches call exec /usr/bin/supervisord -c
/etc/supervisor/conf.d/supervisord.conf; remove the entire if/else block and
replace it with a single exec /usr/bin/supervisord -c
/etc/supervisor/conf.d/supervisord.conf line (references: variables DOMAIN and
SUBDOMAIN, and the supervisord command path).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/core/configuration/DefaultConfig.ts`:
- Around line 387-390: In DefaultConfig (method returning the object with cost:
this.costWrapper(() => 35_000_000)), remove the unreachable `break` that follows
the `return` — locate the block in DefaultConfig where the function returns `{
cost: this.costWrapper(...) }` and delete the redundant `break` statement to
eliminate dead code.
- Around line 319-328: The current fallback for numPlayerPorts > 12 uses
Math.floor((100 * rejectionModifier) / 50) which produces an unexpected large
jump; replace this with a scaling formula that continues with numPlayerPorts
(e.g., return Math.max(2, Math.min(95, Math.floor((100 * rejectionModifier) /
Math.max(1, numPlayerPorts))))), referencing numPlayerPorts and
tradeShipSpawnRejections/rejectionModifier so spawn chance scales smoothly and
is clamped to reasonable bounds.

---

Nitpick comments:
In `@startup.sh`:
- Around line 88-92: The if/else conditional checking DOMAIN and SUBDOMAIN is
redundant because both branches call exec /usr/bin/supervisord -c
/etc/supervisor/conf.d/supervisord.conf; remove the entire if/else block and
replace it with a single exec /usr/bin/supervisord -c
/etc/supervisor/conf.d/supervisord.conf line (references: variables DOMAIN and
SUBDOMAIN, and the supervisord command path).
🪄 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: 0291d1b4-17a9-4904-af22-d80a04e33656

📥 Commits

Reviewing files that changed from the base of the PR and between 371c51f and c7c9ed9.

📒 Files selected for processing (4)
  • src/core/configuration/Config.ts
  • src/core/configuration/DefaultConfig.ts
  • src/core/execution/PortExecution.ts
  • startup.sh

Comment on lines +319 to +328
if (numPlayerPorts <= 3) return 18;
if (numPlayerPorts <= 5) return 25;
if (numPlayerPorts <= 8) return 35;
if (numPlayerPorts <= 10) return 40;
if (numPlayerPorts <= 12) return 45;

// Pity timer: increases spawn chance after consecutive rejections
const rejectionModifier = 1 / (tradeShipSpawnRejections + 1);

return Math.floor((100 * rejectionModifier) / baseSpawnRate);
return Math.floor((100 * rejectionModifier) / 50);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Possible logic issue: spawn rate drops sharply for >12 ports.

For numPlayerPorts <= 12, the function returns 45 (about 2.2% spawn chance). But for numPlayerPorts > 12, it returns Math.floor(100 / 50) = 2 when there are no rejections, meaning a 50% spawn chance.

This seems like a big jump. Is this intentional? If you meant to continue the scaling pattern, consider something like:

🐛 If this is unintentional, here is a possible fix
     if (numPlayerPorts <= 12) return 45;

     // Pity timer: increases spawn chance after consecutive rejections
     const rejectionModifier = 1 / (tradeShipSpawnRejections + 1);

-    return Math.floor((100 * rejectionModifier) / 50);
+    // Continue scaling for larger port counts
+    const baseRate = 45 + Math.floor((numPlayerPorts - 12) * 5);
+    return Math.floor(baseRate * rejectionModifier);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/configuration/DefaultConfig.ts` around lines 319 - 328, The current
fallback for numPlayerPorts > 12 uses Math.floor((100 * rejectionModifier) / 50)
which produces an unexpected large jump; replace this with a scaling formula
that continues with numPlayerPorts (e.g., return Math.max(2, Math.min(95,
Math.floor((100 * rejectionModifier) / Math.max(1, numPlayerPorts))))),
referencing numPlayerPorts and tradeShipSpawnRejections/rejectionModifier so
spawn chance scales smoothly and is clamped to reasonable bounds.

Comment on lines +387 to 390
return {
cost: this.costWrapper(() => 35_000_000),
};
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Dead code: break after return is unreachable.

The return statement exits the function, so the break on Line 390 never executes.

🧹 Proposed fix
       case UnitType.MIRV:
         return {
           cost: this.costWrapper(() => 35_000_000),
         };
-        break;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
cost: this.costWrapper(() => 35_000_000),
};
break;
return {
cost: this.costWrapper(() => 35_000_000),
};
🧰 Tools
🪛 Biome (2.4.6)

[error] 390-390: This code is unreachable

(lint/correctness/noUnreachable)

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

In `@src/core/configuration/DefaultConfig.ts` around lines 387 - 390, In
DefaultConfig (method returning the object with cost: this.costWrapper(() =>
35_000_000)), remove the unreachable `break` that follows the `return` — locate
the block in DefaultConfig where the function returns `{ cost:
this.costWrapper(...) }` and delete the redundant `break` statement to eliminate
dead code.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Mar 15, 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.

2 participants