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

Merged
merged 3 commits into from
Jan 15, 2025
Merged
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
24 changes: 20 additions & 4 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
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
bentziaxl marked this conversation as resolved.
Show resolved Hide resolved
end
end

def luxury_ability(entity)
entity.abilities.find { |a| a.description == 'Tender' }
end
Expand Down Expand Up @@ -1216,7 +1232,7 @@ def delete_token_mz(minor)
if !yellow_green
delete_slot = city.slots > 4 ? city.slots : false
city.delete_token!(token, remove_slot: delete_slot)
# add mza reservation if mza not tokened in madrid yet
# add MZA reservation if MZA not tokened in madrid yet
mza_token = city.tokens.compact.find { |t| t.corporation == mza }
city.add_reservation!(mza) unless mza_token
token.destroy!
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?
bentziaxl marked this conversation as resolved.
Show resolved Hide resolved
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