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

[18Norway] Only ships are allowed to use harbors #11427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions lib/engine/game/g_18_norway/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,19 @@ def for_graph_city_tokened_by?(city, entity, graph)
harbor_token?(city, entity)
end

def connected?(a, b, corporation)
def connected?(a, b, corporation, train)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"train" might not be a good name of this parameter, as it can be a ship.
How about train_or_ship? Or some other name that includes both? (moveable?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that naming is fine. The ships are being implemented as Train objects, so it will be a train that is passed as a parameter.

return true if a.connects_to?(b, corporation)

[a.a, a.b].each do |part|
next unless b.nodes.include?(part)
next unless part.city?

return harbor_token?(part, corporation)
return harbor_token?(part, corporation) if ship?(train)
end
false
end

def check_connected(route, corporation)
return if route.ordered_paths.each_cons(2).all? { |a, b| connected?(a, b, corporation) }
return if route.ordered_paths.each_cons(2).all? { |a, b| connected?(a, b, corporation, route.train) }

return super unless @round.train_upgrade_assignments[route.train]

Expand Down
Loading