Skip to content

Commit

Permalink
[1868WY] fix Ames double share protection
Browse files Browse the repository at this point in the history
* don't increase price past original sale price when new president buys shares
  to protect their Ames double share
* fix error when logging price change

Fixes #10028
  • Loading branch information
michaeljb committed Dec 29, 2023
1 parent 6d3f8c7 commit c0fa34e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/engine/game/g_1868_wy/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,10 @@ def after_sell_up(bundle, before)
net_sold = before[:num_shares] - num_buyable
share_price = @stock_market.find_relative_share_price(before[:share_price], bundle.corporation, [:up] * net_sold)

# if UP was ledged before being dumped, the new price after protection
# can't be higher than the pre-dump price
share_price = before[:share_price] if share_price.price > before[:share_price].price

after = {
president: president,
num_buyable: num_buyable,
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/game/g_1868_wy/step/double_share_protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def process_choose(action)
@game.swap_up_double_share_and_presidency!
@log << "#{player.name} swaps the Ames Brothers 20% share for the UP president's certificate"
else
old_price = @game.union_pacific.share_price.price
old_price = @game.union_pacific.share_price

swap = @game.up_protection_player_bundle

Expand Down

0 comments on commit c0fa34e

Please sign in to comment.