Skip to content

[1880] Add log message after SR when corp can't buy train #11691

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

philcampeau
Copy link
Collaborator

Fixes #8808

Before clicking "Create"

  • Branch is derived from the latest master
  • Add the pins or archive_alpha_games label if this change will break existing games
  • Code passes linter with docker compose exec rack rubocop -a
  • Tests pass cleanly with docker compose exec rack rake

Implementation Notes

Explanation of Change

Initially I was going to add this log message only if the corp was coming out of an SR, but I wasn't sure that I was really limiting it to that scenario. I realised though, these added log messages works fine even if the corp isn't coming out of an SR, so I simplified the code.

I don't even think super is needed at this point, but I figured I'd leave it as a catch-all

Screenshots

Any Assumptions / Hacks

@philcampeau philcampeau requested a review from crericha as a code owner April 17, 2025 14:34
Copy link
Collaborator

@ollybh ollybh left a comment

Choose a reason for hiding this comment

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

Does this work if a company had bought the last train of a type, triggering the stock round? I suspect that log_skip might not be called in that case.

@ollybh ollybh added the 1880 label Apr 19, 2025
@philcampeau
Copy link
Collaborator Author

You were correct. I added a log_pass method that checks if the id of the first available train from the depot ends in '-0', as well as the previous checks, to return the same messages.

By the way, the initial change has the side effect of also returning the log message when the buy_train step is skipped normally for the reasons of not having room or enough money to buy a train. Personally, I think it's an improvement, and something that we could even consider adding to the base code. But for now I've just left it to this game,

@ollybh
Copy link
Collaborator

ollybh commented Apr 26, 2025

This is going to produce inconsistent logging. For example if a company buys a train from a friend and hits train limit then you may or may not see the log message about being at train limit, depending on which is the next train in the depot. And, IMHO, we don't generally need to be adding more to the log, it's noisy enough as is.

I would have thought that a better place to try and add the log message would be before the start_operating line in G1880::Round::Operating.setup. That block of code is only being executed when an operating round is being resumed after a stock round, you could check if current is at train limit.

def setup
return super unless self == @game.saved_or_round
current = @entities[@entity_index]
@entities = select_entities
@entity_index = @entities.find_index(current)
@entities.each { |c| @game.place_home_token(c) } if @home_token_timing == :operating_round
start_operating
end

@philcampeau
Copy link
Collaborator Author

Wow. Not sure how I missed that! I'll agree that's definitely the right place for it, and significantly easier too.

Copy link
Collaborator

@ollybh ollybh left a comment

Choose a reason for hiding this comment

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

Setting this PR to changes requested, so it doesn't get merged until it has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1880] Add log message if a company can't afford a train after the SR.
2 participants