Skip to content

[18esp] fix mz mza cheater token #11721

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bentziaxl
Copy link
Collaborator

MZA and MZ share a single slot city in madrid (f24).
When mz is taken over, and MZA was placed as a cheater token, the closing of MZ doesn't remove the extra slot.
added minor code to fix this behaviour.

@bentziaxl bentziaxl requested a review from ollybh May 8, 2025 08:21
@ollybh ollybh added the 18ESP label May 8, 2025
Copy link
Collaborator

@ollybh ollybh left a comment

Choose a reason for hiding this comment

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

I think that this might not work in all cases.

Would it be possible to do something like this, overriding close_corporation instead of adding the fix_cheater_slot_madrid method?

def close_corporation(corporation, quiet: false)
  if corporation.type == :minor
    corporation.placed_tokens.each do |token|
      city = token.city
      remove_slot = city.tokens.any? { |t| t.cheater? }
      city.delete_token!(token, remove_slot: remove_slot)
    end
  end
  super
end

fix_cheater_slot_madrid(minor.city) if minor.id == 'MZ'
end

def fix_cheater_slot_madrid(slot)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Calling this variable slot is confusing. It is the index of a city that is being passed to this method.

But I don't think that passing the city index will be reliable. MZ has a city index of 2, which is correct when the Madrid tile is yellow or green, but could MZ close after Madrid has been upgraded to brown, and there is a single city on the tile?

Comment on lines +1152 to +1153
cities = hex_by_id('F24')&.tile&.cities
return unless cities
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to be so defensive. Something is terminally wrong if hex_by_id('F24').tile.cities doesn't return an array.

return unless city

tokens = city.tokens
tokens.compact! if tokens.size > city.normal_slots
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be possible for MZ to close when the Madrid cities have merged and there are slots with reservations? This could cause the ordering of tokens and reservations to go wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants