Skip to content

Commit

Permalink
[1828] EMR cross buy limited by shares sold and train value
Browse files Browse the repository at this point in the history
  • Loading branch information
crericha committed Feb 9, 2025
1 parent a3d21e7 commit cb8ffe2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/engine/game/g_1828/step/buy_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ def president_may_contribute?(entity, shell = nil)
(super || shell_empty) && ebuy_president_can_contribute?(entity)
end

def spend_minmax(entity, train)
entity_buying_power = buying_power(entity)
max_possible = entity_buying_power + entity.owner.cash
if @last_share_sold_price
min = max_possible - @last_share_sold_price + 1
max = [train.price, max_possible].min
else
min = 1
max = if entity_buying_power > train.price
entity_buying_power
else
[train.price, max_possible].min
end
end
[min, max]
end

private

def shells_with_room(entity)
Expand Down

0 comments on commit cb8ffe2

Please sign in to comment.