Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1837] Both of UG1 and UG3's shares need to be exchanged #11498

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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?
Expand Down