-
Notifications
You must be signed in to change notification settings - Fork 194
[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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
cities = hex_by_id('F24')&.tile&.cities | ||
return unless cities |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.