From 87cd2ff362dcb59b53a64601e1ab9b04b1373af2 Mon Sep 17 00:00:00 2001 From: Galatolol Date: Tue, 17 Dec 2024 22:54:19 +0100 Subject: [PATCH 1/4] [1894] Fix bug allowing for upgrading cities you can't access --- lib/engine/game/g_1894/step/tracker.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/engine/game/g_1894/step/tracker.rb b/lib/engine/game/g_1894/step/tracker.rb index 90433c5b1a..0527520766 100644 --- a/lib/engine/game/g_1894/step/tracker.rb +++ b/lib/engine/game/g_1894/step/tracker.rb @@ -10,7 +10,18 @@ module Tracker def check_track_restrictions!(entity, old_tile, new_tile) return if @game.loading || !entity.operator? - return if @game.class::BROWN_CITY_TILES.include?(new_tile.name) + + if @game.class::GREEN_CITY_TILES.include?(old_tile.name) + graph = @game.graph_for_entity(entity) + graph.clear + new_tile.paths.each do |path| + next unless graph.connected_paths(entity)[path] + + return true + end + + raise GameError, 'Corporation cannot upgrade a green city it doesn\'t have access to' + end super end From 5d2722407aafd9de3d7489b54dc7ffb6a5f067bf Mon Sep 17 00:00:00 2001 From: Galatolol Date: Fri, 20 Dec 2024 11:49:43 +0100 Subject: [PATCH 2/4] Revert "[1894] Fix bug allowing for upgrading cities you can't access" This reverts commit 87cd2ff362dcb59b53a64601e1ab9b04b1373af2. --- lib/engine/game/g_1894/step/tracker.rb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/engine/game/g_1894/step/tracker.rb b/lib/engine/game/g_1894/step/tracker.rb index 0527520766..90433c5b1a 100644 --- a/lib/engine/game/g_1894/step/tracker.rb +++ b/lib/engine/game/g_1894/step/tracker.rb @@ -10,18 +10,7 @@ module Tracker def check_track_restrictions!(entity, old_tile, new_tile) return if @game.loading || !entity.operator? - - if @game.class::GREEN_CITY_TILES.include?(old_tile.name) - graph = @game.graph_for_entity(entity) - graph.clear - new_tile.paths.each do |path| - next unless graph.connected_paths(entity)[path] - - return true - end - - raise GameError, 'Corporation cannot upgrade a green city it doesn\'t have access to' - end + return if @game.class::BROWN_CITY_TILES.include?(new_tile.name) super end From 5a8da10865fd4d17238fb7327c3a81dad170ff62 Mon Sep 17 00:00:00 2001 From: Galatolol Date: Fri, 20 Dec 2024 12:28:45 +0100 Subject: [PATCH 3/4] [1894] Fix the brown city issue in another way --- lib/engine/game/g_1894/step/track.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/engine/game/g_1894/step/track.rb b/lib/engine/game/g_1894/step/track.rb index 9f2052ff2a..c5a7b575b0 100644 --- a/lib/engine/game/g_1894/step/track.rb +++ b/lib/engine/game/g_1894/step/track.rb @@ -15,7 +15,12 @@ def actions(entity) super end - def legal_tile_rotation?(_entity, hex, tile) + def legal_tile_rotation?(entity, hex, tile) + if @game.class::GREEN_CITY_TILES.include?(hex.tile.name) + entity_reaches_a_new_exit = !(tile.exits & hex_neighbors(entity, hex)).empty? + return false unless entity_reaches_a_new_exit + end + return super if hex.id != @game.class::PARIS_HEX || hex.tile.color != :green plm_in_city_0 = true if hex.tile.cities[0].reserved_by?(@game.plm) || hex.tile.cities[0].tokened_by?(@game.plm) From 664914beb7707e25a2a287cdb037181dbf894e3b Mon Sep 17 00:00:00 2001 From: Galatolol Date: Fri, 20 Dec 2024 15:26:51 +0100 Subject: [PATCH 4/4] [1894] Use array.intersect? --- lib/engine/game/g_1894/step/track.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/engine/game/g_1894/step/track.rb b/lib/engine/game/g_1894/step/track.rb index c5a7b575b0..79f7bafd74 100644 --- a/lib/engine/game/g_1894/step/track.rb +++ b/lib/engine/game/g_1894/step/track.rb @@ -16,10 +16,8 @@ def actions(entity) end def legal_tile_rotation?(entity, hex, tile) - if @game.class::GREEN_CITY_TILES.include?(hex.tile.name) - entity_reaches_a_new_exit = !(tile.exits & hex_neighbors(entity, hex)).empty? - return false unless entity_reaches_a_new_exit - end + return false if @game.class::GREEN_CITY_TILES.include?(hex.tile.name) && + !tile.exits.intersect?(hex_neighbors(entity, hex)) return super if hex.id != @game.class::PARIS_HEX || hex.tile.color != :green