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

[1837] Use backtracking graph in the token step #11602

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/engine/game/g_1837/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Game < Game::Base
include Entities
include Map

attr_reader :token_graph

CORPORATION_CLASS = G1837::Corporation
DEPOT_CLASS = G1837::Depot

Expand Down
4 changes: 2 additions & 2 deletions lib/engine/game/g_1837/step/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Copy link
Collaborator

@crericha crericha Mar 6, 2025

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)

Copy link
Collaborator Author

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).

can_afford_token?(token, buying_power(entity))
end

Expand All @@ -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|
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

token_price(token, city.tile.hex) <= cash
end
end
Expand Down