Skip to content

Commit

Permalink
Merge pull request #11214 from patrikolesen/18_uruguay_dest_bonus
Browse files Browse the repository at this point in the history
[18Uruguay] Company shall only retreive destination_bonus in their own turn
  • Loading branch information
ollybh authored Oct 7, 2024
2 parents 3f9b8ab + 6a61a6e commit e8e83dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/engine/game/g_18_uruguay/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def after_buy_company(player, company, _price)

def operating_round(round_num)
Round::Operating.new(self, [
G18Uruguay::Step::DestinationBonus,
Engine::Step::Bankrupt,
Engine::Step::Exchange,
G18Uruguay::Step::Farm,
Expand Down
16 changes: 9 additions & 7 deletions lib/engine/game/g_18_uruguay/step/destination_bonus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,34 @@ def description
end

def log_skip(entity)
return if entity.minor?
return unless entity.corporation?
return if entity == @game.rptla
return unless destination_node_check?(entity)

super
end

def actions(entity)
return [] if entity.minor?
return [] if entity == @game.rptla
return [] if @game.abilities(entity, :destination_bonus).nil?

self.class::ACTIONS
end

def auto_actions(entity)
corporations = @round.entities.select { |c| destination_node_check?(c) }
return [Engine::Action::Pass.new(entity)] if corporations.empty?
return [] unless entity.corporation?
return [Engine::Action::Pass.new(entity)] unless destination_node_check?(entity)

[Engine::Action::DestinationConnection.new(entity, corporations: corporations)]
[Engine::Action::DestinationConnection.new(entity, corporations: [entity])]
end

def destination_node_check?(corporation)
return if corporation.closed?
return if corporation.destination_coordinates.nil?
return false if corporation.closed?
return false if corporation.destination_coordinates.nil?

ability = @game.abilities(corporation, :destination_bonus)
return if ability.nil?
return false if ability.nil?

destination_hex = @game.hex_by_id(corporation.destination_coordinates)
home_node = corporation.tokens.first.city
Expand Down

0 comments on commit e8e83dd

Please sign in to comment.