diff --git a/lib/engine/game/g_18_esp/game.rb b/lib/engine/game/g_18_esp/game.rb index 691a1daf6b..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 @@ -904,6 +909,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 +923,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)