Skip to content

Commit

Permalink
[18BF] Can only run train to London if running to own token
Browse files Browse the repository at this point in the history
  • Loading branch information
ollybh committed Aug 16, 2023
1 parent 56924bb commit 783484a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/engine/game/g_18_bf/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ def revenue_for(route, stops)
end
super + bonuses
end

def check_other(route)
check_london(route)
end

def check_london(route)
# Can only run to London if running to your own token.
london_stops = route.visited_stops & @london_cities
return if london_stops.all? { |city| city.tokened_by?(current_entity) }

raise GameError, 'Route may not include London unless running to a ' \
"#{current_entity.id} token."
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/engine/game/g_18_bf/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def setup_london_hexes
london = @hexes.find { |hex| hex.coordinates == LONDON_HEX_CENTRE }
london.neighbors.clear
@london_zoomed << london

# Keep references to the London cities for managing routes.
@london_cities = @london_zoomed.flat_map { |hex| hex.tile.cities }
end

# Keeps the zoomed London hex colour and city revenue in sync with the
Expand Down

0 comments on commit 783484a

Please sign in to comment.