Skip to content

Commit

Permalink
Merge pull request #10198 from roseundy/41_negative_shares
Browse files Browse the repository at this point in the history
1841: add and use new parameter for SharePool.transfer_shares
  • Loading branch information
michaeljb authored Jan 27, 2024
2 parents 8bb7e70 + 3baa886 commit a5f033b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/engine/game/g_1841/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2085,10 +2085,10 @@ def secession_move_treasury_shares(old, newa, newb)
tshares.each_with_index do |share, i|
if i.even?
@log << "Moving #{share.percent}% share of #{share.corporation.name} from #{old.name} to #{newa.name} treasury"
@share_pool.transfer_shares(share.to_bundle, newa, allow_president_change: true)
@share_pool.transfer_shares(share.to_bundle, newa, allow_president_change: true, corporate_transfer: true)
else
@log << "Moving #{share.percent}% share of #{share.corporation.name} from #{old.name} to #{newb.name} treasury"
@share_pool.transfer_shares(share.to_bundle, newb, allow_president_change: true)
@share_pool.transfer_shares(share.to_bundle, newb, allow_president_change: true, corporate_transfer: true)
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/engine/share_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def transfer_shares(bundle, to_entity,
allow_president_change: true,
swap: nil,
borrow_from: nil,
swap_to_entity: nil)
swap_to_entity: nil,
corporate_transfer: nil)
corporation = bundle.corporation
owner = bundle.owner
previous_president = bundle.president
Expand Down Expand Up @@ -287,7 +288,7 @@ def transfer_shares(bundle, to_entity,
# previous president if they haven't sold the president's share
# give the president the president's share
# if the owner only sold half of their president's share, take one away
if owner.player? && to_entity.player? && bundle.presidents_share
if ((owner.player? && to_entity.player?) || corporate_transfer) && bundle.presidents_share
# special case when doing a player-to-player purchase of the president's share
transfer_to = to_entity
swap_to = to_entity
Expand Down

0 comments on commit a5f033b

Please sign in to comment.