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

[SteamOverHolland] fixes train discount bug #11169

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion lib/engine/game/g_steam_over_holland/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@ def redeemable_shares(entity)

def emergency_issuable_bundles(entity)
return [] if @round.issued_shares[entity]
return [] if entity.all_abilities.find { |a| a.type == :train_discount } && entity.cash >= @depot.min_depot_price * 0.9
philcampeau marked this conversation as resolved.
Show resolved Hide resolved

super
num_shares = [entity.num_player_shares, 5 - entity.num_market_shares].min

bundles_for_corporation(entity, entity).reject { |bundle| bundle.num_shares > num_shares }
end

def upgrades_to_correct_city_town?(from, to)
Expand Down
11 changes: 6 additions & 5 deletions lib/engine/game/g_steam_over_holland/step/buy_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class BuyTrain < Engine::Step::BuyTrain
def actions(entity)
return [] if entity != current_entity

return ['sell_shares'] if entity == current_entity&.owner && can_ebuy_sell_shares?(current_entity)
return %w[sell_shares buy_train pass] if president_may_contribute?(entity)
return %w[buy_train pass] if can_buy_train?(entity)
return %w[sell_shares buy_train] if must_sell_shares?(entity)
return ['buy_train'] if can_afford_needed_train?(entity)
return %w[buy_train pass] if can_close_corp?(entity) || can_buy_train?(entity)

[]
end
Expand Down Expand Up @@ -54,14 +54,15 @@ def process_sell_shares(action)
def must_sell_shares?(corporation)
return false if corporation.cash >= @game.depot.min_depot_price || !corporation.trains.empty?

can_issue?(corporation)
can_issue?(corporation) &&
corporation.trains.empty?
end

def can_issue?(corporation)
return false unless corporation.corporation?
return false if @round.issued_shares[corporation]

!@game.issuable_shares(corporation).empty?
!@game.emergency_issuable_bundles(corporation).empty?
end

def should_buy_train?(entity)
Expand Down
Loading
Loading