Skip to content

Commit

Permalink
18USA: PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ventusignis committed Feb 13, 2022
1 parent 518f003 commit cfdd92c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 32 deletions.
6 changes: 2 additions & 4 deletions lib/engine/game/g_18_usa/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,7 @@ def use_1840_style_merger_round_scrap_trains?
end

def crowded_corps
@crowded_corps ||= corporations.select do |c|
trains = self.class::OBSOLETE_TRAINS_COUNT_FOR_LIMIT ? c.trains.size : c.trains.count { |t| !t.obsolete }
trains > train_limit(c) || c.trains.count { |t| pullman_train?(t) } > 1
end
@crowded_corps ||= super & corporations.select { |c| c.trains.count { |t| pullman_train?(t) } > 1 }
end

# owner is the alleged corporation scrapping a pullman
Expand Down Expand Up @@ -700,6 +697,7 @@ def scrap_train(train)
@bank.spend(pullman_scrap_value, train.owner)
@log << "#{train.owner.name} scraps a pullman for #{format_currency(pullman_scrap_value)}"
@depot.reclaim_train(train)
@crowded_corps = nil
end

def next_round!
Expand Down
31 changes: 5 additions & 26 deletions lib/engine/game/g_18_usa/step/acquire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,18 @@ def actions(entity)
end

def pass_description
if @offer
'Pass (Offer for Sale)'
elsif @auctioning
'Pass (Bid)'
elsif @buyer && can_take_loan?(@buyer)
'Pass (Take Loan)'
elsif @buyer && can_payoff?(@buyer)
'Pass (On payoff Loan)'
elsif @buyer
'Pass (Scrap Train)'
end
return 'Pass (Scrap Train)' if @buyer && !can_take_loan?(@buyer) && !can_payoff?(@buyer)

super
end

def process_pass(action)
if @offer
@game.log << "#{@offer.owner.name} declines to put #{@offer.name} up for sale"
@round.offering.delete(@offer)
@offer = nil
setup_auction
elsif @buyer && can_take_loan?(@buyer)
@passed_take_loans = true
@game.log << "#{@buyer.name} passes taking additional loans"
acquire_post_loan
elsif @buyer && can_payoff?(@buyer)
@passed_payoff_loans = true
@game.log << "#{@buyer.name} passes paying off additional loans"
acquire_post_loan
elsif @buyer
if @buyer && !can_take_loan(@buyer) && !can_payoff?(@buyer)
@passed_scrap_trains = true
@game.log << "#{@buyer.name} passes scrapping trains"
acquire_post_loan
else
pass_auction(action.entity)
super
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/engine/game/g_18_usa/step/buy_pullman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class BuyPullman < Engine::Step::Base
def actions(entity)
return [] if entity != current_entity

if @game.depot.upcoming.any? { |t| t.name == 'P' } && can_buy_train?(entity) && @game.pullmans_available? && \
if @game.depot.upcoming.any? do |t|
@game.pullman_train?(t)
end && can_buy_train?(entity) && @game.pullmans_available? && \
entity.runnable_trains.none? { |t| @game.pullman_train?(t) }
return %w[buy_train pass]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/game/g_18_usa/step/buy_sell_par_shares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def can_scrap_train?(entity)
end

def scrappable_trains(entity)
entity.trains.select { |t| t.name == 'P' }
entity.trains.select { |t| @game.pullman_train?(t) }
end

def scrap_info(_)
Expand Down

0 comments on commit cfdd92c

Please sign in to comment.