From cfdd92c96f072c7b68245a9843aff7a47523f5fa Mon Sep 17 00:00:00 2001 From: ventusignis Date: Sun, 13 Feb 2022 16:49:52 -0500 Subject: [PATCH] 18USA: PR cleanup --- lib/engine/game/g_18_usa/game.rb | 6 ++-- lib/engine/game/g_18_usa/step/acquire.rb | 31 +++---------------- lib/engine/game/g_18_usa/step/buy_pullman.rb | 4 ++- .../game/g_18_usa/step/buy_sell_par_shares.rb | 2 +- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/lib/engine/game/g_18_usa/game.rb b/lib/engine/game/g_18_usa/game.rb index 74fbc06a13..fa33052343 100644 --- a/lib/engine/game/g_18_usa/game.rb +++ b/lib/engine/game/g_18_usa/game.rb @@ -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 @@ -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! diff --git a/lib/engine/game/g_18_usa/step/acquire.rb b/lib/engine/game/g_18_usa/step/acquire.rb index 0e866d5b2d..6ec70d9f7c 100644 --- a/lib/engine/game/g_18_usa/step/acquire.rb +++ b/lib/engine/game/g_18_usa/step/acquire.rb @@ -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 diff --git a/lib/engine/game/g_18_usa/step/buy_pullman.rb b/lib/engine/game/g_18_usa/step/buy_pullman.rb index 14e8defc18..c7d730f8ca 100644 --- a/lib/engine/game/g_18_usa/step/buy_pullman.rb +++ b/lib/engine/game/g_18_usa/step/buy_pullman.rb @@ -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 diff --git a/lib/engine/game/g_18_usa/step/buy_sell_par_shares.rb b/lib/engine/game/g_18_usa/step/buy_sell_par_shares.rb index 0047fda76f..b4388cc6f2 100644 --- a/lib/engine/game/g_18_usa/step/buy_sell_par_shares.rb +++ b/lib/engine/game/g_18_usa/step/buy_sell_par_shares.rb @@ -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(_)