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

System18: Remove discarded trains from the game #11275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions lib/engine/game/g_system18/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def operating_steps
GSystem18::Step::Token,
Engine::Step::Route,
GSystem18::Step::Dividend,
Engine::Step::DiscardTrain,
GSystem18::Step::DiscardTrain,
GSystem18::Step::BuyTrain,
]
else
Expand All @@ -475,7 +475,7 @@ def operating_steps
GSystem18::Step::Token,
Engine::Step::Route,
GSystem18::Step::Dividend,
Engine::Step::DiscardTrain,
GSystem18::Step::DiscardTrain,
GSystem18::Step::BuyTrain,
[Engine::Step::BuyCompany, { blocks: true }],
]
Expand Down Expand Up @@ -692,6 +692,12 @@ def place_home_token(corporation)

send("map_#{map_name}_place_home_token", corporation)
end

def remove_discarded_train?(train)
return true unless respond_to?("map_#{map_name}_remove_discarded_train?")

send("map_#{map_name}_remove_discarded_train?", train)
end
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions lib/engine/game/g_system18/step/discard_train.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require_relative '../../../step/discard_train'

module Engine
module Game
module GSystem18
module Step
class DiscardTrain < Engine::Step::DiscardTrain
def process_discard_train(action)
train = action.train

return super unless @game.remove_discarded_train?(train)

@game.remove_train(train)
@log << "#{action.entity.name} discards #{train.name}, #{train.name} is removed from the game"
end
end
end
end
end
end
Loading