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

[Steam Over Holland] fixes EMR bug #11607

Open
wants to merge 3 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
4 changes: 4 additions & 0 deletions lib/engine/game/g_steam_over_holland/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ def sell_shares_and_change_price(bundle, allow_president_change: true, swap: nil
corporation = bundle.corporation
old_price = corporation.share_price

# when issuing shares, price drops one space fewer than the number of shares issued
price_drop -= 1 if corporation == bundle.owner
@round.issued_shares[bundle.corporation] = true if corporation == bundle.owner

# This section below allows for the ledges that prevent price drops unless the president is selling
unless corporation.president?(bundle.owner)
case corporation.share_price.type
Expand Down
24 changes: 11 additions & 13 deletions lib/engine/game/g_steam_over_holland/step/buy_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ module GSteamOverHolland
module Step
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 [] if entity != current_entity
return %w[sell_shares buy_train pass] if president_may_contribute?(entity)
return %w[buy_train pass] if can_buy_train?(entity)

Expand All @@ -32,23 +31,22 @@ def process_pass(action)
raise GameError,
'Corporation can afford train, a train must be purchased.'
end

unless @corporations_sold.empty?
raise GameError,
'Player sold shares, a train must be purchased.'
end

return super unless can_close_corp?(entity)

@game.close_corporation(entity)
end

def process_sell_shares(action)
bundle = action.bundle
corporation = bundle.corporation
old_price = corporation.share_price
@game.share_pool.sell_shares(bundle)

(bundle.num_shares - 1).times do
@game.stock_market.move_left(corporation)
end
def can_sell?(entity, bundle)
return false if @game.class::MUST_SELL_IN_BLOCKS && @corporations_sold.include?(bundle.corporation)
return false if current_entity != entity && must_issue_before_ebuy?(current_entity)

@game.log_share_price(corporation, old_price)
@round.issued_shares[corporation] = true
super
end

def must_sell_shares?(corporation)
Expand Down
12 changes: 1 addition & 11 deletions lib/engine/game/g_steam_over_holland/step/issue_shares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@ module GSteamOverHolland
module Step
class IssueShares < Engine::Step::IssueShares
def process_sell_shares(action)
bundle = action.bundle
corporation = bundle.corporation
old_price = corporation.share_price
@game.share_pool.sell_shares(bundle)

(bundle.num_shares - 1).times do
@game.stock_market.move_left(corporation)
end

@game.log_share_price(corporation, old_price)
@round.issued_shares[corporation] = true
@game.sell_shares_and_change_price(action.bundle)
end

def blocks?
Expand Down
Loading