Skip to content

Commit

Permalink
Merge pull request #9136 from benjaminxscott/benjaminxscott/issue9128
Browse files Browse the repository at this point in the history
[18NY] Change Text for Forced Salvage of Trains Over Limit on Phase Change
  • Loading branch information
michaeljb authored Apr 22, 2023
2 parents d9f696c + 9fbdce8 commit bac6d14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions assets/app/view/game/discard_trains.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def render

h('div.margined', train_props, train.name)
end

@verb = step.trains(corporation)&.any?(&:salvage) ? 'Salvage' : 'Discard'
h(:div, block_props, [
h(Corporation, corporation: corporation),
h(:div, trains),
Expand All @@ -40,7 +40,7 @@ def render
overflow << h(Map, game: @game) if @game.round.is_a?(Engine::Round::Operating)

h(:div, [
h(:h3, 'Discard Trains'),
h(:h3, "#{@verb} Trains"),
*overflow,
])
end
Expand Down
17 changes: 8 additions & 9 deletions lib/engine/game/g_18_ny/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@ def tile_lays(entity)
].freeze

TRAINS = [
{ name: '2H', num: 11, distance: 2, price: 100, rusts_on: '6H' },
{ name: '4H', num: 6, distance: 4, price: 200, rusts_on: '4DE', events: [{ 'type' => 'float_30' }] },
{ name: '6H', num: 4, distance: 6, price: 300, rusts_on: 'D', events: [{ 'type' => 'float_40' }] },
{ name: '2H', num: 11, distance: 2, price: 100, rusts_on: '6H', salvage: 25 },
{ name: '4H', num: 6, distance: 4, price: 200, rusts_on: '4DE', salvage: 50, events: [{ 'type' => 'float_30' }] },
{ name: '6H', num: 4, distance: 6, price: 300, rusts_on: 'D', salvage: 75, events: [{ 'type' => 'float_40' }] },
{
name: '12H',
num: 3,
distance: 12,
price: 600,
salvage: 150,
events: [{ 'type' => 'float_50' }, { 'type' => 'close_companies' }, { 'type' => 'nyc_formation' },
{ 'type' => 'capitalization_round', 'when' => 3 }],
},
Expand All @@ -151,13 +152,15 @@ def tile_lays(entity)
num: 2,
distance: [{ 'nodes' => %w[city offboard town], 'pay' => 4, 'visit' => 99, 'multiplier' => 2 }],
price: 800,
salvage: 200,
events: [{ 'type' => 'float_60' }],
},
{
name: 'D',
num: 20,
distance: 99,
price: 1000,
salvage: 250,
variants: [
name: '5DE',
distance: [{ 'nodes' => %w[city offboard town], 'pay' => 5, 'visit' => 99, 'multiplier' => 2 }],
Expand Down Expand Up @@ -830,14 +833,10 @@ def remove_stagecoach_token_exchange_ability(entity)
entity.remove_ability(stagecoach_token_exchange_ability)
end

def salvage_value(train)
train.price / 4
end

def salvage_train(train)
owner = train.owner
@log << "#{owner.name} salvages a #{train.name} train for #{format_currency(salvage_value(train))}"
@bank.spend(salvage_value(train), owner)
@log << "#{owner.name} salvages a #{train.name} train for #{format_currency(train.salvage)}"
@bank.spend(train.salvage, owner)
@depot.reclaim_train(train)
end

Expand Down
4 changes: 4 additions & 0 deletions lib/engine/game/g_18_ny/step/discard_train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module Game
module G18NY
module Step
class DiscardTrain < Engine::Step::DiscardTrain
def description
'Salvage Train'
end

def process_discard_train(action)
@game.salvage_train(action.train)
end
Expand Down

0 comments on commit bac6d14

Please sign in to comment.