From 7e795e31202e95d9d91cde76944b3b69e54350f0 Mon Sep 17 00:00:00 2001 From: BenA Date: Mon, 2 Dec 2024 10:27:35 +0200 Subject: [PATCH 1/2] fix a few minor bugs --- lib/engine/game/g_18_esp/game.rb | 11 +++++++++++ lib/engine/game/g_18_esp/step/acquire.rb | 6 +++++- .../game/g_18_esp/step/buy_carriage_or_company.rb | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/engine/game/g_18_esp/game.rb b/lib/engine/game/g_18_esp/game.rb index 691a1daf6b..6618c13187 100644 --- a/lib/engine/game/g_18_esp/game.rb +++ b/lib/engine/game/g_18_esp/game.rb @@ -904,6 +904,7 @@ def company_bought(company, entity) end def transfer_luxury_ability(company, entity) + transfer_tenders_to_bank luxury_ability = company.all_abilities.first if luxury_ability(entity) # entity already has tender. Do not add, but increase carriage count @@ -917,6 +918,16 @@ def transfer_luxury_ability(company, entity) company.close! end + def transfer_tenders_to_bank + @luxury_carriages.dup.each do |owner, amount| + next if owner == 'bank' + + transfer_amount = amount - 1 + @luxury_carriages['bank'] += transfer_amount + @luxury_carriages[owner] = 1 + end + end + def luxury_ability(entity) entity.abilities.find { |a| a.description == 'Tender' } end diff --git a/lib/engine/game/g_18_esp/step/acquire.rb b/lib/engine/game/g_18_esp/step/acquire.rb index 1ee1782d13..65daab0f2a 100644 --- a/lib/engine/game/g_18_esp/step/acquire.rb +++ b/lib/engine/game/g_18_esp/step/acquire.rb @@ -90,10 +90,14 @@ def choices end def can_swap? - return true unless mz?(@merging.last) + return merged_token_in_shared_city? unless mz?(@merging.last) @merging.last.tokens.first&.used && !mz?(@merging.last) && + merged_token_in_shared_city? + end + + def merged_token_in_shared_city? @merging.first.tokens.none? { |token| token.hex == @merging.last.tokens.first.hex } end diff --git a/lib/engine/game/g_18_esp/step/buy_carriage_or_company.rb b/lib/engine/game/g_18_esp/step/buy_carriage_or_company.rb index eecacb5476..8126264ad6 100644 --- a/lib/engine/game/g_18_esp/step/buy_carriage_or_company.rb +++ b/lib/engine/game/g_18_esp/step/buy_carriage_or_company.rb @@ -34,6 +34,7 @@ def buyable_items(_entity) items = [] @game.luxury_carriages.each do |owner, amount| next unless amount.positive? + next if owner != 'bank' && @game.company_by_id(owner).closed? owner_str = owner == 'bank' ? owner : @game.company_by_id(owner).owner.name items << Item.new(description: "Tender from #{owner_str}", cost: @game.class::CARRIAGE_COST) From c6a2c5b3d2ccd0d7631e97fa6c3b80c377f3de77 Mon Sep 17 00:00:00 2001 From: BenA Date: Tue, 10 Dec 2024 23:14:36 +0200 Subject: [PATCH 2/2] add mza scenario without mz --- lib/engine/game/g_18_esp/game.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/engine/game/g_18_esp/game.rb b/lib/engine/game/g_18_esp/game.rb index 6618c13187..5c53318f40 100644 --- a/lib/engine/game/g_18_esp/game.rb +++ b/lib/engine/game/g_18_esp/game.rb @@ -876,11 +876,16 @@ def num_corp_trains(entity) end def place_home_token(corporation) - if corporation == mza && corporation_by_id('MZ')&.ipoed && !corporation.tokens.first.used - # mza special case if mz already exists on the map + if corporation == mza && !corporation.tokens.first.used token = corporation.tokens.first hex = hex_by_id(corporation.coordinates) - city = hex.tile.cities.size > 1 ? city_by_id("#{hex.tile.id}-#{corporation.city}") : hex.tile.cities.first + city = if corporation_by_id('MZ')&.ipoed + # mza special case if mz already exists on the map + hex.tile.cities.size > 1 ? city_by_id("#{hex.tile.id}-#{corporation.city}") : hex.tile.cities.first + else + # mza exists, but no mz. Place on original location + city_by_id("#{hex.tile.id}-#{corporation.city}") + end @log << "#{corporation.name} places a token on #{hex.id}" city.place_token(corporation, token, cheater: true, check_tokenable: false) else