diff --git a/lib/engine/game/g_1867/step/single_item_auction.rb b/lib/engine/game/g_1867/step/single_item_auction.rb index 0e1b21c432..61688feba0 100644 --- a/lib/engine/game/g_1867/step/single_item_auction.rb +++ b/lib/engine/game/g_1867/step/single_item_auction.rb @@ -15,6 +15,7 @@ class SingleItemAuction < Engine::Step::Base def actions(entity) return [] if @companies.empty? + return %w[bid pass] if @auctioning entity == current_entity ? ACTIONS : [] end diff --git a/lib/engine/game/g_18_bf/game.rb b/lib/engine/game/g_18_bf/game.rb index 67228b4e4f..63ea98fe2c 100644 --- a/lib/engine/game/g_18_bf/game.rb +++ b/lib/engine/game/g_18_bf/game.rb @@ -84,7 +84,7 @@ def operating_round(round_num) Engine::Step::BuyCompany, G1867::Step::RedeemShares, G18BF::Step::SpecialTrack, - G1867::Step::Track, + G18BF::Step::Track, G1867::Step::Token, Engine::Step::Route, G1867::Step::Dividend, @@ -105,12 +105,14 @@ def event_minors_batch3! end def event_u1_available! - u1 = @future_companies.delete { |company| company.sym == 'U1' } + u1 = @future_companies.find { |company| company.sym == 'U1' } + @future_companies.delete(u1) @companies << u1 end def event_u2_available! - u2 = @future_companies.delete { |company| company.sym == 'U2' } + u2 = @future_companies.find { |company| company.sym == 'U2' } + @future_companies.delete(u2) @companies << u2 end @@ -146,6 +148,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 efa0afa1b8..246c5b669e 100644 --- a/lib/engine/game/g_18_bf/map.rb +++ b/lib/engine/game/g_18_bf/map.rb @@ -259,19 +259,41 @@ module Map { coord1: 'M29', edge1: 5, coord2: 'V24', edge2: 2 }, ].freeze LONDON_HEX_CENTRE = 'L28' + LONDON_HEX_ON_MAP = 'U23' def setup_london_hexes + # Keep references to London hexes for tracking upgrades. + @london_small = @hexes.find { |hex| hex.coordinates == LONDON_HEX_ON_MAP } + @london_zoomed = [] + # Join the hexes adjacent to London to the expanded hexes. LONDON_HEX_NEIGHBOURS.each do |item| hex1 = @hexes.find { |hex| hex.coordinates == item[:coord1] } hex2 = @hexes.find { |hex| hex.coordinates == item[:coord2] } hex1.neighbors[item[:edge1]] = hex2 hex2.neighbors[item[:edge2]] = hex1 + @london_zoomed << hex1 end # Sever all connections from the London hex on the main map. 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 + # London tile on the map. + def london_upgraded(new_tile) + color = new_tile.color + revenue = new_tile.offboards.first.revenue[color] + + @london_zoomed.each do |hex| + hex.color = color + hex.cities.each { |city| city.revenue = revenue } + end end # Bonus revenues are shown on the map as detached offboard areas. diff --git a/lib/engine/game/g_18_bf/step/track.rb b/lib/engine/game/g_18_bf/step/track.rb new file mode 100644 index 0000000000..53f6d2ddc8 --- /dev/null +++ b/lib/engine/game/g_18_bf/step/track.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require_relative '../../g_1867/step/track' + +module Engine + module Game + module G18BF + module Step + class Track < G1867::Step::Track + def available_hex(entity, hex) + return super unless hex == @london_small + + london_available?(entity) + end + + def london_available?(entity) + @london_zoomed.any? { |hex| available_hex(entity, hex) } + end + + def lay_tile(action, extra_cost: 0, entity: nil, spender: nil) + super + + @game.london_upgraded(action.hex.tile) if action.hex == @london_small + end + end + end + end + end +end