Skip to content

Commit

Permalink
[Core] Placing tokens can affect both graphs, so simplify code by alw…
Browse files Browse the repository at this point in the history
…ays clearing both
  • Loading branch information
crericha committed Jan 26, 2025
1 parent 5aac45a commit f8a9380
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 17 deletions.
3 changes: 0 additions & 3 deletions lib/engine/game/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1667,9 +1667,6 @@ def clear_graph

def clear_graph_for_entity(entity)
graph_for_entity(entity).clear
end

def clear_token_graph_for_entity(entity)
token_graph_for_entity(entity).clear
end

Expand Down
4 changes: 2 additions & 2 deletions lib/engine/game/g_1832/step/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def buy_coal_token(corporation)
log_message += "#{@game.coal_token_counter} Coal tokens left in the game"
@log << log_message
corporation.coal_token = true
@game.clear_token_graph_for_entity(corporation)
@game.clear_graph_for_entity(corporation)
end

def hex_neighbors(entity, hex)
connected = super
@game.clear_token_graph_for_entity(entity) if entity.tokens.none?(&:city)
@game.clear_graph_for_entity(entity) if entity.tokens.none?(&:city)
connected
end

Expand Down
4 changes: 0 additions & 4 deletions lib/engine/game/g_1841/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ def clear_graph_for_entity(_entity)
@border_paths = nil
end

def clear_token_graph_for_entity(entity)
clear_graph_for_entity(entity)
end

def event_phase4_regions!
modify_regions(2, false)
modify_regions(4, true)
Expand Down
4 changes: 2 additions & 2 deletions lib/engine/game/g_1850/step/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def buy_mesabi_token(corporation)
log_message += "#{@game.mesabi_token_counter} Mesabi tokens left in the game"
@log << log_message
corporation.mesabi_token = true
@game.clear_token_graph_for_entity(corporation)
@game.clear_graph_for_entity(corporation)
end

def hex_neighbors(entity, hex)
connected = super
@game.clear_token_graph_for_entity(entity) if entity.tokens.none?(&:city)
@game.clear_graph_for_entity(entity) if entity.tokens.none?(&:city)
connected
end

Expand Down
4 changes: 0 additions & 4 deletions lib/engine/game/g_1858/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ def clear_graph_for_entity(_entity)
@graph_metre.clear
end

def clear_token_graph_for_entity(entity)
clear_graph_for_entity(entity)
end

def init_round
if option_quick_start?
quick_start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def map_twisting_tracks_post_lay_tile(entity, tile)

tile.cities.first.place_token(entity, tc, check_tokenable: false)
@log << "#{entity.name} places a Ticket Counter on tile"
clear_token_graph_for_entity(entity)
clear_graph_for_entity(entity)
end

# allow 2nd token on hex if it's a different type
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/step/tokener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def place_token(entity, city, token, connected: true, extra_action: false,
end

@round.tokened = true unless extra_action
@game.clear_token_graph_for_entity(entity)
@game.clear_graph_for_entity(entity)
end

def pay_token_cost(entity, cost, _city)
Expand Down

0 comments on commit f8a9380

Please sign in to comment.