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

[18Uruguay] Do not ship more than ship capacity for rptla #11210

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions lib/engine/game/g_18_uruguay/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class Game < Game::Base
include Goods
include Nationalization

SHIP_CAPACITY =
{
'Ship 1' => 1,
'Ship 2' => 1,
'Ship 3' => 2,
'Ship 4' => 2,
'Ship 5' => 3,
'Ship 6' => 3,
}.freeze

EBUY_SELL_MORE_THAN_NEEDED = true
EBUY_DEPOT_TRAIN_MUST_BE_CHEAPEST = false

Expand Down Expand Up @@ -535,6 +545,13 @@ def operating_order

super.reject { |c| c == @rptla }.append(@rptla)
end

def ship_capacity(train)
val = SHIP_CAPACITY[train.name]
return 0 if val.nil?

val
end
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/engine/game/g_18_uruguay/nationalization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ def start_merge(originatior)
def nationalization_final_export!
return if number_of_goods_at_harbor.zero?

@log << "Nationalization: Final Export #{number_of_goods_at_harbor} goods for #{format_currency(50)} each"
amount_per_share = 5 * number_of_goods_at_harbor
nr_goods = [number_of_goods_at_harbor, @rptla.trains.sum { |train| ship_capacity(train) }].min
@log << "Nationalization: Final Export #{nr_goods} good for #{format_currency(50)}" if nr_goods == 1
@log << "Nationalization: Final Export #{nr_goods} goods for #{format_currency(50)} each" if nr_goods > 1
amount_per_share = 5 * nr_goods
players.each do |holder|
amount = holder.num_shares_of(@rptla) * amount_per_share
next unless amount.positive?
Expand Down
18 changes: 2 additions & 16 deletions lib/engine/game/g_18_uruguay/step/route_rptla.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ module Game
module G18Uruguay
module Step
class RouteRptla < Engine::Step::Route
SHIP_CAPACITY =
{
'Ship 1' => 1,
'Ship 2' => 1,
'Ship 3' => 2,
'Ship 4' => 2,
'Ship 5' => 3,
'Ship 6' => 3,
}.freeze

def description
'Ship to England'
end
Expand Down Expand Up @@ -55,13 +45,9 @@ def choices
choices
end

def ship_capacity(train)
SHIP_CAPACITY[train.name.partition('+')[0]]
ollybh marked this conversation as resolved.
Show resolved Hide resolved
end

def total_ship_capacity?(entity)
trains = @game.route_trains(entity)
trains.sum { |train| ship_capacity(train) }
trains.sum { |train| @game.ship_capacity(train) }
end

def process_choose(action)
Expand All @@ -74,7 +60,7 @@ def process_choose(action)
remaining = goods_to_deliver
ships.each do |ship|
ship.name = ship.name.partition('+')[0] unless ship.nil?
capacity = ship_capacity(ship)
capacity = @game.ship_capacity(ship)
goods_count = [remaining, capacity].min
remaining -= goods_count
@game.add_goods_to_ship(ship, goods_count)
Expand Down
Loading