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

[18ESP] fix a few minor bugs #11393

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions lib/engine/game/g_18_esp/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,16 @@ def num_corp_trains(entity)
end

def place_home_token(corporation)
if corporation == mza && corporation_by_id('MZ')&.ipoed && !corporation.tokens.first.used
# mza special case if mz already exists on the map
if corporation == mza && !corporation.tokens.first.used
token = corporation.tokens.first
hex = hex_by_id(corporation.coordinates)
city = hex.tile.cities.size > 1 ? city_by_id("#{hex.tile.id}-#{corporation.city}") : hex.tile.cities.first
city = if corporation_by_id('MZ')&.ipoed
# mza special case if mz already exists on the map
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general I think the corporation abbreviations in texts and comments should use upper case, so MZA and MZ in this case. Same comment for line 886.

hex.tile.cities.size > 1 ? city_by_id("#{hex.tile.id}-#{corporation.city}") : hex.tile.cities.first
else
# mza exists, but no mz. Place on original location
city_by_id("#{hex.tile.id}-#{corporation.city}")
end
@log << "#{corporation.name} places a token on #{hex.id}"
city.place_token(corporation, token, cheater: true, check_tokenable: false)
else
Expand All @@ -904,6 +909,7 @@ def company_bought(company, entity)
end

def transfer_luxury_ability(company, entity)
transfer_tenders_to_bank
luxury_ability = company.all_abilities.first
if luxury_ability(entity)
# entity already has tender. Do not add, but increase carriage count
Expand All @@ -917,6 +923,16 @@ def transfer_luxury_ability(company, entity)
company.close!
end

def transfer_tenders_to_bank
@luxury_carriages.dup.each do |owner, amount|
next if owner == 'bank'

transfer_amount = amount - 1
@luxury_carriages['bank'] += transfer_amount
@luxury_carriages[owner] = 1
end
end

def luxury_ability(entity)
entity.abilities.find { |a| a.description == 'Tender' }
end
Expand Down
6 changes: 5 additions & 1 deletion lib/engine/game/g_18_esp/step/acquire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ def choices
end

def can_swap?
return true unless mz?(@merging.last)
return merged_token_in_shared_city? unless mz?(@merging.last)

@merging.last.tokens.first&.used &&
!mz?(@merging.last) &&
merged_token_in_shared_city?
end

def merged_token_in_shared_city?
@merging.first.tokens.none? { |token| token.hex == @merging.last.tokens.first.hex }
end

Expand Down
1 change: 1 addition & 0 deletions lib/engine/game/g_18_esp/step/buy_carriage_or_company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def buyable_items(_entity)
items = []
@game.luxury_carriages.each do |owner, amount|
next unless amount.positive?
next if owner != 'bank' && @game.company_by_id(owner).closed?

owner_str = owner == 'bank' ? owner : @game.company_by_id(owner).owner.name
items << Item.new(description: "Tender from #{owner_str}", cost: @game.class::CARRIAGE_COST)
Expand Down
Loading