From 9f1d5dfa8b2eadbbd3f7b85e9e4a2548a188e8d9 Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Sat, 31 Dec 2022 12:50:46 +0000 Subject: [PATCH 1/5] SingleItemAuction: there should always be actions mid-auction It was possible to get stuck in an auction if entity != current_entity, which meant that it was not possible to pass on an auction in progress. --- lib/engine/game/g_1867/step/single_item_auction.rb | 1 + 1 file changed, 1 insertion(+) 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 From 9838de8013eac90d80102b3b655615a8504399b7 Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Sun, 1 Jan 2023 17:44:38 +0000 Subject: [PATCH 2/5] [18BF] Allow London to be upgraded --- lib/engine/game/g_18_bf/game.rb | 2 +- lib/engine/game/g_18_bf/map.rb | 19 ++++++++++++++++++ lib/engine/game/g_18_bf/step/track.rb | 29 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 lib/engine/game/g_18_bf/step/track.rb diff --git a/lib/engine/game/g_18_bf/game.rb b/lib/engine/game/g_18_bf/game.rb index 8fe70490fe..3da120658b 100644 --- a/lib/engine/game/g_18_bf/game.rb +++ b/lib/engine/game/g_18_bf/game.rb @@ -85,7 +85,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, diff --git a/lib/engine/game/g_18_bf/map.rb b/lib/engine/game/g_18_bf/map.rb index 2e01e5b3af..79c53dd04a 100644 --- a/lib/engine/game/g_18_bf/map.rb +++ b/lib/engine/game/g_18_bf/map.rb @@ -259,19 +259,38 @@ 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 + 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..eeab3c50bd --- /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 From 7a710bcacc2cfb8ad223c0b7a88f9292f199841d Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Sun, 19 Feb 2023 14:23:38 +0000 Subject: [PATCH 3/5] [18BF] Fix rubocop warning --- lib/engine/game/g_18_bf/step/track.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/engine/game/g_18_bf/step/track.rb b/lib/engine/game/g_18_bf/step/track.rb index eeab3c50bd..53f6d2ddc8 100644 --- a/lib/engine/game/g_18_bf/step/track.rb +++ b/lib/engine/game/g_18_bf/step/track.rb @@ -14,7 +14,7 @@ def available_hex(entity, hex) end def london_available?(entity) - @london_zoomed.any? { |hex| available_hex(entity, hex)} + @london_zoomed.any? { |hex| available_hex(entity, hex) } end def lay_tile(action, extra_cost: 0, entity: nil, spender: nil) From 15160877a4b1f5c3da400b207cf783284461adb0 Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Thu, 20 Apr 2023 22:16:25 +0100 Subject: [PATCH 4/5] [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 From 27f234378e05450bfc37df0e526eb8a1ff9cf6e7 Mon Sep 17 00:00:00 2001 From: Oliver Burnett-Hall Date: Mon, 29 May 2023 14:11:39 +0100 Subject: [PATCH 5/5] [18BF] Fix making U1/U2 private companies available Array.delete doesn't take a block to find an element to delete, and doesn't return the elements deleted. --- lib/engine/game/g_18_bf/game.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/engine/game/g_18_bf/game.rb b/lib/engine/game/g_18_bf/game.rb index 13a1592354..63ea98fe2c 100644 --- a/lib/engine/game/g_18_bf/game.rb +++ b/lib/engine/game/g_18_bf/game.rb @@ -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