-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7099 from ventusignis/18usa-pullman-scrapping
18usa pullman scrapping
- Loading branch information
Showing
17 changed files
with
306 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../g_1817/step/acquire' | ||
require_relative 'scrap_train_module' | ||
module Engine | ||
module Game | ||
module G18USA | ||
module Step | ||
class Acquire < G1817::Step::Acquire | ||
include ScrapTrainModule | ||
def actions(entity) | ||
actions = super | ||
if entity == @buyer && can_scrap_train?(entity) | ||
actions = %w[pass] if actions.empty? | ||
actions << 'scrap_train' | ||
end | ||
actions | ||
end | ||
|
||
def pass_description | ||
return 'Pass (Scrap Train)' if @buyer && !can_take_loan?(@buyer) && !can_payoff?(@buyer) | ||
|
||
super | ||
end | ||
|
||
def process_pass(action) | ||
if @buyer && !can_take_loan?(@buyer) && !can_payoff?(@buyer) | ||
@passed_scrap_trains = true | ||
@game.log << "#{@buyer.name} passes scrapping trains" | ||
acquire_post_loan | ||
else | ||
super | ||
end | ||
end | ||
|
||
def acquire_post_loan | ||
return if can_scrap_train?(@buyer) | ||
|
||
super | ||
end | ||
|
||
# This version is needed to reference @passed_scrap_trains | ||
def can_scrap_train?(entity) | ||
return true if entity.corporation? && !@passed_scrap_trains && entity.trains.find { |t| @game.pullman_train?(t) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../../step/buy_train' | ||
module Engine | ||
module Game | ||
module G18USA | ||
module Step | ||
class BuyPullman < Engine::Step::BuyTrain | ||
def description | ||
'Buy Pullman' | ||
end | ||
|
||
def pass_description | ||
'Skip (Pullman)' | ||
end | ||
|
||
def must_buy_train?(_) | ||
false | ||
end | ||
|
||
def president_may_contribute?(_) | ||
false | ||
end | ||
|
||
def can_buy_train?(entity, _shell = nil) | ||
@game.pullmans_available? && entity.runnable_trains.none? { |t| @game.pullman_train?(t) } | ||
end | ||
|
||
def buyable_trains(entity) | ||
# Can't buy a second pullman and can't buy a pullman if it's not legal to well, buy pullmans. | ||
return [] unless can_buy_train?(entity) | ||
|
||
# Cannot buy a pullman if you have a pullman | ||
(@depot.depot_trains & super).select { |t| @game.pullman_train?(t) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../g_1817/step/conversion' | ||
require_relative 'scrap_train_module' | ||
module Engine | ||
module Game | ||
module G18USA | ||
module Step | ||
class Conversion < G1817::Step::Conversion | ||
include ScrapTrainModule | ||
def actions(entity) | ||
actions = super | ||
actions << 'scrap_train' if can_scrap_train?(entity) | ||
actions | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../../step/discard_train' | ||
require_relative 'scrap_train_module' | ||
module Engine | ||
module Game | ||
module G18USA | ||
module Step | ||
class DiscardTrain < Engine::Step::DiscardTrain | ||
include ScrapTrainModule | ||
def actions(entity) | ||
actions = super | ||
actions << 'scrap_train' if can_scrap_train?(entity) | ||
actions | ||
end | ||
|
||
def trains(corporation) | ||
return super unless corporation.trains.count { |t| @game.pullman_train?(t) } > 1 | ||
|
||
corporation.trains.select { |t| @game.pullman_train?(t) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.