-
Notifications
You must be signed in to change notification settings - Fork 191
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
[1837] Use backtracking graph in the token step #11602
base: master
Are you sure you want to change the base?
Conversation
1837 has two graphs: a standard one and one that allows track to backtrack at junctions. The latter is needed for placing station tokens, where this type of route is allowed. The token step was not using this graph, it was using the standard one. This meant that not all possible token locations were being included, and an auto-pass was being generated for the token step if the only possible token locations involved backtracking. Fixes tobymao#11600.
lib/engine/game/g_1837/step/token.rb
Outdated
@@ -27,7 +27,7 @@ def can_place_token?(entity) | |||
# Cheaper to do the graph first, then check affordability | |||
current_entity == entity && | |||
!(token = entity.next_token).nil? && | |||
@game.graph.can_token?(entity) && | |||
@game.token_graph.can_token?(entity) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@game.token_graph_for_entity(entity).can_token?(entity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated (even though it does the same thing).
lib/engine/game/g_1837/step/token.rb
Outdated
@@ -40,7 +40,7 @@ def multiple_tokens?(entity) | |||
end | |||
|
|||
def can_afford_token?(token, cash) | |||
@game.graph.tokenable_cities(token.corporation).any? do |city| | |||
@game.token_graph.tokenable_cities(token.corporation).any? do |city| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@game.token_graph_for_entity(entity).tokenable_cities(token.corporation).any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Change requested from code review.
Explanation of Change
1837 has two graphs: a standard one and one that allows track to backtrack at junctions. The latter is needed for placing station tokens, where this type of route is allowed.
The token step was not using this graph, it was using the standard one. This meant that not all possible token locations were being included, and an auto-pass was being generated for the token step if the only possible token locations involved backtracking.
Fixes #11600.
This shouldn't break any games. There will be games where the BH should have been able to lay a token on its first turn but wasn't allowed to, but a pass action will have been generated for those turns and that will be in the game actions.
Before clicking "Create"
master
Add thepins
orarchive_alpha_games
label if this change will break existing gamesdocker compose exec rack rubocop -a
docker compose exec rack rake