Skip to content

Commit

Permalink
[18Ardennes] Allow the GL to be sold when in EMR
Browse files Browse the repository at this point in the history
Fixes #137.
  • Loading branch information
ollybh committed Jul 1, 2024
1 parent 4fb7e8a commit fd88460
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/engine/game/g_18_ardennes/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ def buyable_bank_owned_companies
@round.operating? ? [] : super
end

def company_sale_price(company)
company.value
end

# Has the player won any auctions for public companies in the
# preceding auction round? If they have then they must start these
# majors before they can buy any other shares or pass.
Expand Down
26 changes: 26 additions & 0 deletions lib/engine/game/g_18_ardennes/step/buy_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,37 @@ module Game
module G18Ardennes
module Step
class BuyTrain < Engine::Step::BuyTrain
def actions(entity)
actions = super
actions << 'sell_company' if actions.include?('sell_shares') &&
can_sell_any_companies?(entity)
actions
end

def train_variant_helper(train, entity)
return super if @game.can_buy_4d?(entity)

super.reject { |v| v[:name] == '4D' }
end

def process_sell_company(action)
player = action.entity
company = action.company
price = company.value
company.owner = @game.bank
player.companies.delete(company)
@game.bank.spend(price, player)
@log << "#{player.name} sells #{company.name} to bank for #{@game.format_currency(price)}"
end

private

def can_sell_any_companies?(entity)
player = entity.owner
return false unless player&.player?

!player.companies.select { |c| c.type == :minor }.empty?
end
end
end
end
Expand Down

0 comments on commit fd88460

Please sign in to comment.