Skip to content

Commit

Permalink
Merge pull request tobymao#10128 from andrewzwicky/8053
Browse files Browse the repository at this point in the history
[18EU] Properly restrict stock exchange to match rules
  • Loading branch information
michaeljb authored Jan 16, 2024
2 parents 0c0f37a + 4266b2a commit bf86681
Show file tree
Hide file tree
Showing 4 changed files with 22,036 additions and 5 deletions.
7 changes: 6 additions & 1 deletion lib/engine/game/g_18_eu/step/final_exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ def can_discard?(minor)
def can_gain?(_entity, bundle, exchange: false)
return false unless exchange

bundle.corporation.ipoed
return false unless bundle.corporation.ipoed

# must take treasury shares if they exist.
return false if (bundle.owner == @game.share_pool) && bundle.corporation.num_ipo_shares.positive?

true
end

def buy_shares(entity, shares, exchange: nil, swap: nil, allow_president_change: true, borrow_from: nil)
Expand Down
9 changes: 7 additions & 2 deletions lib/engine/game/g_18_eu/step/minor_exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def exchange?(corporation)
end

def merge_minor!(minor, corporation, source)
maybe_remove_token(minor, corporation)
maybe_remove_token(minor, corporation, source)

if source == corporation
transfer_treasury(minor, corporation)
Expand All @@ -32,10 +32,15 @@ def merge_minor!(minor, corporation, source)
minor.close! unless @round.pending_acquisition
end

def maybe_remove_token(minor, corporation)
def maybe_remove_token(minor, corporation, source)
return unless corporation
return minor.tokens.first.remove! if corporation.placed_tokens.empty?

# if this merge share is coming from somewhere other than a corporation
# i.e. the share pool, don't make a pending acquisition, because
# a share pool exchange does not allow for token replacement.
return if source != corporation

@round.pending_acquisition = { minor: minor, corporation: corporation }
end

Expand Down
14,488 changes: 14,487 additions & 1 deletion public/fixtures/18EU/74045.json

Large diffs are not rendered by default.

7,537 changes: 7,536 additions & 1 deletion public/fixtures/18EU/auto_pass_already_tokened.json

Large diffs are not rendered by default.

0 comments on commit bf86681

Please sign in to comment.