Skip to content

Conversation

@DevelopingTom
Copy link
Contributor

@DevelopingTom DevelopingTom commented Jul 6, 2025

Description:

Train stations are now built automatically when a factory is constructed.

Changes:
- When a factory is built, nearby structures are connected to the rail network
- When a city is built near a factory, it is connected to the rail network
- All structures behave the same when a train stops: to be defined
- Removed station badge
- Gold income is now related to the structure's level

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
  • I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors

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

IngloriousTom

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

Walkthrough

This update removes support for creating train stations and the "train" unit type from both the user interface and core game logic. All related schemas, events, and UI options for trains and station creation are deleted. Factory integration is updated, and train-specific logic is simplified or removed throughout the codebase.

Changes

Files/Paths Change Summary
resources/lang/en.json Removed "train" and "create_station" translation keys.
src/client/HostLobbyModal.ts,
src/client/SinglePlayerModal.ts
Removed UnitType.Train from disabled units in lobby and single player modals.
src/client/Transport.ts Deleted SendCreateTrainStationIntentEvent and related event handling for train stations.
src/client/graphics/layers/UILayer.ts Removed all code for loading and drawing train station badges on units.
src/client/utilities/RenderUnitTypeOptions.ts Removed UnitType.Train from unit options list.
src/core/Schemas.ts Deleted CreateStationIntent type and schema from all intent unions.
src/core/StatsSchemas.ts Added "fact" (factory) to other unit schema and mappings.
src/core/configuration/DefaultConfig.ts Increased multiplier in trainSpawnRate calculation from 60 to 70.
src/core/execution/CityExecution.ts Added createStation method to link city creation with nearby factories for station setup.
src/core/execution/ExecutionManager.ts Removed intent handling for "create_station" and related execution.
src/core/execution/FactoryExecution.ts Changed factory build logic to first tick, added createStation for nearby units.
src/core/execution/FakeHumanExecution.ts Removed logic for spawning train stations; now only spawns factories.
src/core/execution/TrainExecution.ts Reduced train speed and simplified constructor (removed cargo logic).
src/core/execution/TrainStationExecution.ts Changed constructor to accept unit directly, simplified initialization, removed disabled check.
src/core/game/Game.ts,
src/core/game/GameImpl.ts
Added hasUnitNearby method to game interface and implementation.
src/core/game/RailNetworkImpl.ts Ensured trainStation flag is unset on station removal.
src/core/game/TrainStation.ts Unified gold bonus logic for all stop handlers, removed port-specific trade ship logic.
src/core/game/UnitImpl.ts Added factory units to destruction stats update in delete method.
src/server/GameServer.ts Removed check for disabled train units when handling "create_station" intent.
tests/core/game/RailNetwork.test.ts Added mocked setTrainStation method to unit mock in test helper.
tests/core/game/TrainStation.test.ts Updated tests to use BigInt for gold, removed port and factory stop tests, adjusted city stop test.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant UI
    participant GameServer
    participant GameCore

    Note over Player,UI: Train station creation and train units are no longer available

    Player->>UI: Attempt to create train station (option removed)
    UI-->>Player: No option available

    Player->>GameServer: No "create_station" intent sent
    GameServer-->>GameCore: No train station creation processed

    Note over GameCore: Factory and city creation logic now handles station setup internally
Loading

Possibly related PRs

Suggested labels

Feature - Revision, UI/UX, Release Blocker

Suggested reviewers

  • evanpelle
  • scottanderson

Poem

🚂 The trains have left, their whistles fade,
No stations built, no tracks are laid.
Factories rise where engines slept,
Simpler code, intentions kept.
Gold for all, the bonus fair—
The rails are gone, but progress is there!
🎉✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-06T13_03_46_864Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b300fe2 and 15006fb.

📒 Files selected for processing (2)
  • tests/core/game/RailNetwork.test.ts (1 hunks)
  • tests/core/game/TrainStation.test.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andrewNiziolek
PR: openfrontio/OpenFrontIO#1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
Learnt from: its-sii
PR: openfrontio/OpenFrontIO#1089
File: src/client/graphics/layers/ControlPanel.ts:160-183
Timestamp: 2025-06-07T20:01:52.720Z
Learning: The user its-sii prefers simpler, more readable code over complex type-safe approaches when the benefits don't justify the added complexity. They value maintainability and clarity in code implementation.
tests/core/game/TrainStation.test.ts (2)
Learnt from: scottanderson
PR: openfrontio/OpenFrontIO#784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.
Learnt from: 1brucben
PR: openfrontio/OpenFrontIO#977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: 🏗️ Build
🔇 Additional comments (4)
tests/core/game/RailNetwork.test.ts (1)

14-17: Good addition of the mock method.

The setTrainStation mock properly supports testing the new automatic train station functionality. The Jest mock setup is clean and follows standard practices.

tests/core/game/TrainStation.test.ts (3)

18-18: LGTM: Consistent BigInt usage for gold handling

The change from number to BigInt aligns with the updated gold handling system and prevents precision issues with large gold values.


31-31: LGTM: Level mock supports new gold bonus calculations

Adding the level mock method is needed to support the revised gold bonus calculations based on station level mentioned in the implementation changes.


48-48: LGTM: Test expectation matches BigInt config change

The test expectation correctly uses BigInt (10n) to match the updated trainGold configuration, ensuring test consistency.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@evanpelle evanpelle added this to the v25 milestone Jul 6, 2025
Copy link
Collaborator

@evanpelle evanpelle left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-project-automation github-project-automation bot moved this from Triage to Final Review in OpenFront Release Management Jul 6, 2025
@evanpelle evanpelle merged commit 6353a5d into openfrontio:main Jul 6, 2025
8 of 9 checks passed
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Jul 6, 2025
@scottanderson scottanderson modified the milestones: v25, v24 Jul 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 11, 2025
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Aug 13, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants