From b3fcbb50de56f360548eea6e34ecc75ef2e4d62d Mon Sep 17 00:00:00 2001 From: Chris Rericha Date: Thu, 30 Jan 2025 02:22:00 -0500 Subject: [PATCH] [1837] Both of UG1 and UG3's shares need to be exchanged --- lib/engine/game/g_1837/game.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/engine/game/g_1837/game.rb b/lib/engine/game/g_1837/game.rb index 3c3a71c8df..6ad7aa4937 100644 --- a/lib/engine/game/g_1837/game.rb +++ b/lib/engine/game/g_1837/game.rb @@ -490,12 +490,20 @@ def merge_minor!(minor, corporation, allow_president_change: true) coal_company_exchange = minor.type == :coal @log << "#{minor.name} merges into #{corporation.name}" - @log << "#{minor.owner.name} receives 1 share of #{corporation.name}" - share = corporation.reserved_shares[0] - share.buyable = true - @share_pool.transfer_shares(ShareBundle.new(share), minor.owner, allow_president_change: allow_president_change) - if @round.respond_to?(:non_paying_shares) && operated_this_round?(minor) - @round.non_paying_shares[minor.owner][corporation] += 1 + if coal_company_exchange + { minor.owner => 1 } + else + minor.share_holders.to_h { |sh, _| [sh, sh.shares_of(minor).size] } + end.each do |sh, num_shares| + next if num_shares.zero? + + @log << "#{sh.name} receives #{num_shares} share#{num_shares > 1 ? 's' : ''} of #{corporation.name}" + shares = corporation.reserved_shares.take(num_shares) + shares.each { |s| s.buyable = true } + @share_pool.transfer_shares(ShareBundle.new(shares), sh, allow_president_change: allow_president_change) + if @round.respond_to?(:non_paying_shares) && operated_this_round?(minor) + @round.non_paying_shares[sh][corporation] += num_shares + end end if minor.cash.positive?