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 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
2 changes: 2 additions & 0 deletions lib/engine/game/g_steam_over_holland/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ module Entities
type: 'train_discount',
discount: 0.1,
trains: %w[3 4 5],
when: 'buying_train',
owner_type: 'corporation',
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/game/g_steam_over_holland/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def redeemable_shares(entity)
end

def emergency_issuable_bundles(entity)
return [] if @round.issued_shares[entity] || entity.cash >= @depot.min_depot_price
return [] if @round.issued_shares[entity]

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

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