Skip to content

Commit 4339777

Browse files
Add trains (openfrontio#1159)
## Description: Add a rail network to handle train stations/railroad between structures. Changes: - `RailNetwork` is responsible for the train station graph. Use it to connect new `TrainStations` - A `RailRoad` connects two `TrainStation` - No loop possible in the rail network - Train stations handles its railroads - Added a layer to draw the railroads under the structures #### Clusters - To speed up computations, each `TrainStation` references its own cluster - A cluster is a list of `TrainStation` connected with each other, created by the `RailNetwork` when connecting the station - Train stations spawn trains randomly depending on its current cluster size - A `TrainStation` decides randomly of the train destination by picking one from the cluster #### Production building: - Added a factory which has no gameplay impact currently. _To be discussed._ #### Train stops: - When a train reaches a factory, it's filled with a "cargo". The loaded trains has no impact currently. _To be discussed._ - When a train reaches a city, the player earn 10k gold - When a train reaches a port, it sends a new tradeship if possible - If a destination/source is destroyed, the train & railroad are deleted too https://github.com/user-attachments/assets/42375c17-9e04-4a42-98d0-708c81ffd609 https://github.com/user-attachments/assets/fbecdb53-a516-4df8-87fb-1f9a62c4efa0 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] 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 - [x] 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 --------- Co-authored-by: Scott Anderson <scottanderson@users.noreply.github.com>
1 parent 0f2008a commit 4339777

60 files changed

Lines changed: 2427 additions & 104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "test-file-stub";

jest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export default {
55
extensionsToTreatAsEsm: [".ts"],
66
moduleNameMapper: {
77
"^(\\.{1,2}/.*)\\.js$": "$1",
8+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
9+
"<rootDir>/__mocks__/fileMock.js",
10+
"\\.(css|less)$": "<rootDir>/__mocks__/fileMock.js",
811
},
912
transform: {
1013
"^.+\\.tsx?$": [
Lines changed: 5 additions & 0 deletions
Loading
95 Bytes
Loading
176 Bytes
Loading

resources/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
"cooldown": "Cooldown",
417417
"type": "Type",
418418
"upgrade": "Upgrade",
419+
"create_station": "Create Station",
419420
"level": "Level"
420421
},
421422
"relation": {

resources/sprites/dust.png

160 Bytes
Loading
107 Bytes
Loading
114 Bytes
Loading

resources/sprites/trainEngine.png

98 Bytes
Loading

0 commit comments

Comments
 (0)