From 5393a53f4a371da0391f27082e4531b771ba5ada Mon Sep 17 00:00:00 2001 From: "R. Ryan Driskel" Date: Wed, 28 Oct 2020 16:21:20 -0600 Subject: [PATCH] Combine the best updates from the last day --- lib/engine/game/g_18_co.rb | 40 +++++++++++++++++++---------- lib/engine/step/g_18_co/dividend.rb | 16 +++++------- lib/engine/step/g_18_co/track.rb | 4 +-- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/lib/engine/game/g_18_co.rb b/lib/engine/game/g_18_co.rb index 1610aed8e2..4e2a19d14d 100644 --- a/lib/engine/game/g_18_co.rb +++ b/lib/engine/game/g_18_co.rb @@ -82,18 +82,9 @@ def imc def setup setup_company_price_50_to_150_percent - setup_companies setup_corporations end - def setup_companies - imc.add_ability(Engine::Ability::Base.new( - type: :mine_multiplier, - description: 'Mine values are doubled', - count_per_or: 2 - )) - end - def setup_corporations # The DSNG comes with a 2P train train = @depot.upcoming[0] @@ -114,11 +105,15 @@ def mines_count(entity) end def mine_multiplier(entity) - entity.abilities(:mine_multiplier).map(&:count_per_or).reject(&:zero?).reduce(1, :*) + imc.owner == entity ? 2 : 1 + end + + def mine_value(entity) + BASE_MINE_VALUE * mine_multiplier(entity) end def mines_total(entity) - BASE_MINE_VALUE * mines_count(entity) * mine_multiplier(entity) + mine_value(entity) * mine_multiplier(entity) end def mines_remove(entity) @@ -128,12 +123,20 @@ def mines_remove(entity) end def mine_add(entity) - mine_count = mines_count(entity) + 1 + mine_create(entity, mines_count(entity) + 1) + end + + def mine_update_text(entity) + mine_create(entity, mines_count(entity)) + end + + def mine_create(entity, count) mines_remove(entity) + total = count * mine_value(entity) entity.add_ability(Engine::Ability::Base.new( type: :mine_income, - description: "Corporation owns #{mine_count} mines", - count_per_or: mine_count, + description: "#{count} mines x #{format_currency(mine_value(entity))} = #{format_currency(total)} to treasury", + count_per_or: count, remove: '6' )) end @@ -167,6 +170,15 @@ def new_auction_round ]) end + def action_processed(action) + super + + case action + when Action::BuyCompany + mine_update_text(action.entity) if action.company == imc && action.entity.corporation? + end + end + def revenue_for(route, stops) revenue = super diff --git a/lib/engine/step/g_18_co/dividend.rb b/lib/engine/step/g_18_co/dividend.rb index 53ac75e39f..5a6be2c9da 100644 --- a/lib/engine/step/g_18_co/dividend.rb +++ b/lib/engine/step/g_18_co/dividend.rb @@ -14,17 +14,15 @@ def share_price_change(entity, revenue = 0) { share_direction: %i[right up], share_times: [1, 1] } end - def change_share_price(entity, payout) - tfm = @game.mines_total(entity) - - # Only pay mines if a train produce revenue regardless of withhold or pay - if tfm.positive? && (payout[:corporation].positive? || payout[:per_share].positive?) - @game.bank.spend(tfm, entity) + def process_dividend(action) + super - @log << "#{entity.name} collects #{@game.format_currency(tfm)} from mines" - end + entity = action.entity + return unless (mine_revenue = @game.mines_total(entity)).positive? + return unless (entity.operating_history[[@game.turn, @round.round_num]].revenue).positive? - super + @game.bank.spend(mine_revenue, entity) + @log << "#{entity.name} collects #{@game.format_currency(mine_revenue)} from mines" end end end diff --git a/lib/engine/step/g_18_co/track.rb b/lib/engine/step/g_18_co/track.rb index ab7d3d1d1f..68a8e844b0 100644 --- a/lib/engine/step/g_18_co/track.rb +++ b/lib/engine/step/g_18_co/track.rb @@ -17,9 +17,7 @@ def process_lay_tile(action) # Add mine to corporation data @game.mine_add(action.entity) - @log << "#{action.entity.name} collects a mine token from - #{action.hex.name} for a total of - #{@game.format_currency(@game.mines_total(action.entity))} from mines" + @log << "#{action.entity.name} collects a mine token from #{action.hex.name}" end pass! unless can_lay_tile?(action.entity)