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
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
33 changes: 26 additions & 7 deletions lib/engine/game/g_steam_over_holland/step/buy_train.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

require_relative '../../../step/buy_train'
require_relative '../../../step/train'

module Engine
module Game
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,6 +32,12 @@ def process_pass(action)
raise GameError,
'Corporation can afford train, a train must be purchased.'
end

if [email protected] && !@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)
Expand All @@ -41,14 +47,27 @@ 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)
if action.entity == corporation
@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
else
@game.sell_shares_and_change_price(bundle)
@corporations_sold << corporation
end
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