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

[1846] only show buyable trains in EMR #10186

Merged
merged 1 commit into from
Jan 25, 2024
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
7 changes: 6 additions & 1 deletion lib/engine/game/g_1846/step/buy_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ def buyable_train_variants(train, entity)
return variants if (variants.size < 2) || train.owned_by_corporation?

min, max = variants.sort_by { |v| v[:price] }
return [min] if ((min[:price] <= entity.cash) && (entity.cash < max[:price])) || entity.receivership?
pres_cash = president_may_contribute?(entity) ? entity.owner.cash : 0
if ((min[:price] <= entity.cash + pres_cash) && (entity.cash + pres_cash < max[:price])) || entity.receivership?
return [min]
end

# player is not allowed to sell shares and then buy a "weaker" train if the corp could already afford a weaker train
if (last_cash_raised = @last_share_sold_price || @last_share_issued_price)
must_spend = entity.cash - last_cash_raised + 1
must_spend += entity.owner.cash if @last_share_sold_price

variants.reject! { |v| v[:price] < must_spend }
end

Expand Down