Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18Uruguay] Adding support for delivering goods #10207

Merged

Conversation

patrikolesen
Copy link
Contributor

@patrikolesen patrikolesen commented Jan 28, 2024

Farms will generate goods once per OR which can be delivered to a near by town of city

The trains can then ship them to a close by port and then RTPLA can ship them to England

This commit covers the delivery both for trains and ships

Before clicking "Create"

  • Branch is derived from the latest master
  • Code passes linter with docker compose exec rack rubocop -a
  • Tests pass cleanly with docker compose exec rack rake

Implementation Notes

  • Explanation of Change

  • Screenshots

  • Any Assumptions / Hacks

@patrikolesen patrikolesen force-pushed the 18_uruguay_pre_alpha_deliver_goods branch 4 times, most recently from c85c88b to baeae29 Compare February 4, 2024 15:04
end

def ship_capacity(train)
(train.name.scan(/\d/)[0].to_f / 2).ceil
Copy link
Collaborator

Choose a reason for hiding this comment

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

The train name shouldn't be the source of truth for this data. Regex code generally isn't very readable and since the data is semantically numeric, it should be stored as a number.

Maybe the game class could have a constant mapping train names to the integer value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code updated according to recommendation

capacity = ship_capacity(train)
goods_count = [remaining, capacity].min
remaining -= goods_count
train.name += '+' + @game.class::GOODS_TRAIN + '(' + goods_count.to_s + ')' if goods_count.positive?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Up in attach_good_to_train, the train name has the hex id included, but here it's the current goods count. Are there some scenarios where it's a hex and others where it's the count?

Maybe instead of in the train name, this changing data about the train could be listed in the corporations status_str? (that's a method in Game::Base that's used to show data on the bottom of a player card) I would generally feel better with fewer total modifications made to the train name if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code updated

@patrikolesen patrikolesen force-pushed the 18_uruguay_pre_alpha_deliver_goods branch 4 times, most recently from 9cf631c to 93cafb0 Compare February 7, 2024 20:01
Farms will generate goods once per OR which can be delivered to a near by town of city

The trains can then ship them to a close by port and then RTPLA can ship them to England

This commit covers the delivery both for trains and ships

Co-authored-by: Michael Brandt <[email protected]>
@patrikolesen patrikolesen force-pushed the 18_uruguay_pre_alpha_deliver_goods branch from 93cafb0 to f1767ef Compare February 7, 2024 20:16
@michaeljb michaeljb self-assigned this Feb 9, 2024
@michaeljb michaeljb merged commit e17d4b9 into tobymao:master Feb 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants