-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[18Uruguay] Secondary capitalization
The corporation get the rest of the capitalization when the reach there destination tile
- Loading branch information
1 parent
b3a5d61
commit 253b7ec
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../../step/tracker' | ||
require_relative '../../../step/track' | ||
|
||
module Engine | ||
module Game | ||
module G18Uruguay | ||
module Step | ||
class Track < Engine::Step::Track | ||
def actions(entity) | ||
return [] if entity == @game.rptla | ||
return [] if @game.final_operating_round? | ||
|
||
@round.loan_taken |= false | ||
actions = super.map(&:clone) | ||
actions << 'take_loan' if @game.can_take_loan?(entity) && !@round.loan_taken && !@game.nationalized? | ||
actions | ||
end | ||
|
||
def destination_node_check?(entity) | ||
return if entity.destination_coordinates.nil? | ||
|
||
destination_hex = @game.hex_by_id(entity.destination_coordinates) | ||
home_node = entity.tokens.first.city | ||
destination_hex.tile.nodes.first&.walk(corporation: entity) do |path, _, _| | ||
return true if path.nodes.include?(home_node) | ||
end | ||
false | ||
end | ||
|
||
def check_and_apply_destination_bonus | ||
corporation = current_entity.corporation | ||
apply_destination_bonus(corporation) if destination_node_check?(corporation) | ||
end | ||
|
||
def apply_destination_bonus(corporation) | ||
ability = @game.abilities(corporation, :destination_bonus) | ||
@game.second_capitalization!(corporation) unless ability.nil? | ||
ability&.use! | ||
end | ||
|
||
def lay_tile(action, extra_cost: 0, entity: nil, spender: nil) | ||
ret = super | ||
check_and_apply_destination_bonus | ||
ret | ||
end | ||
|
||
def pass! | ||
check_and_apply_destination_bonus | ||
super | ||
end | ||
|
||
def process_take_loan(action) | ||
entity = action.entity | ||
@game.take_loan(entity, action.loan) unless @round.loan_taken | ||
@round.loan_taken = true | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |