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

[1849] modification to code for variants #11417

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

Conversation

philcampeau
Copy link
Collaborator

@philcampeau philcampeau commented Dec 23, 2024

Hopefully fixes issues with Variants rules. I'll manually close the bug reports after confirming. (see below)

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

Players trying the variants have all encountered variations of this error at various points:

image

Often, refreshing and trying again and again seems to resolve the issue temporarily, but that's obviously not a solution. This issue has proven difficult to troubleshoot, since it doesn't happen in Hotseat mode, or even when playing multiplayer on my local environment.

I tried changing the code for def operating_round, removing the logic that gates the inclusion of the variant steps, and instead adding log_pass and log_skip methods to those steps to mask those steps unless using the variants.

Once I did this, rake would fail on the fixture files, which I found interesting since the fixture doesn't use the variants. I went through the logic of the variants themselves, and added a gate to the def actions to return [] if that variant isn't active.

That resolved the Rake error, and I still seem to be able to play through local games, so at worst this is no worse than the current state, and I think the code is cleaner and closer to the standard code seen throughout the site.

Screenshots

Any Assumptions / Hacks

This may well require archiving/pinning any games using the Bonds/Electric Dreams/Buy Tokens variants, but I don't believe it would affect other games of 1849.

@philcampeau philcampeau added pins PR that will require some games to be pinned archive_alpha_games Needs alpha games archiving 1849 variants labels Dec 23, 2024
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.

This change looks fine to me. I don't think that this should break any existing games as the steps will be skipped if the variants aren't selected. But leave the pins tag in place to make sure that this gets tested before the code is deployed.

bonds? ? G1849::Step::BondInterestPayment : nil,
bonds? ? G1849::Step::Bond : nil,
G1849::Step::BondInterestPayment,
G1849::Step::Bond,
[Engine::Step::BuyCompany, { blocks: true }],
].compact, round_num: round_num)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don´t need to compact the array any more, as it will not contain any nils.

Suggested change
].compact, round_num: round_num)
], round_num: round_num)

@@ -30,7 +30,12 @@ def description
end

def log_skip(entity)
super if @game.bonds? && @game.issue_bonds_enabled
print "hi #{can_take_loan?(entity)}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

A stray debugging statement has made it through to the pull request.

Suggested change
print "hi #{can_take_loan?(entity)}"

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.

A couple of small fixes are needed before this gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1849 variants archive_alpha_games Needs alpha games archiving pins PR that will require some games to be pinned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants