From 783484aa79a7be3e7fa4aa01fb61b40895e4602a Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Thu, 20 Apr 2023 22:16:25 +0100 Subject: [PATCH] [18BF] Can only run train to London if running to own token --- lib/engine/game/g_18_bf/game.rb | 13 +++++++++++++ lib/engine/game/g_18_bf/map.rb | 3 +++ 2 files changed, 16 insertions(+) diff --git a/lib/engine/game/g_18_bf/game.rb b/lib/engine/game/g_18_bf/game.rb index 273e77d9df..13a1592354 100644 --- a/lib/engine/game/g_18_bf/game.rb +++ b/lib/engine/game/g_18_bf/game.rb @@ -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 diff --git a/lib/engine/game/g_18_bf/map.rb b/lib/engine/game/g_18_bf/map.rb index d886994d58..246c5b669e 100644 --- a/lib/engine/game/g_18_bf/map.rb +++ b/lib/engine/game/g_18_bf/map.rb @@ -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