Skip to content

Commit

Permalink
Merge pull request #11498 from tobymao/1837-ug-force-nationalization
Browse files Browse the repository at this point in the history
[1837] Both of UG1 and UG3's shares need to be exchanged
  • Loading branch information
crericha authored Jan 30, 2025
2 parents 358b2e5 + b3fcbb5 commit 7653219
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/engine/game/g_1837/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,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?
Expand Down

0 comments on commit 7653219

Please sign in to comment.