Handle turtle rock big key chest key-for-a-key

This commit is contained in:
Kevin Cathcart 2018-01-05 02:02:58 -05:00
parent 596ba13781
commit ee61f7b3ac
1 changed files with 15 additions and 12 deletions

View File

@ -506,18 +506,21 @@ def set_trock_key_rules(world):
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'), lambda state: state.has('Small Key (Turtle Rock)', 3)) set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'), lambda state: state.has('Small Key (Turtle Rock)', 3))
# the most complicated one # the most complicated one
# if we have back entrance access, we could waste all keys before touching this def tr_big_key_chest_keys_needed(state):
# if we don't, we have access to all chests by the time we can waste a key on trinexx door item = item_name(state.world.get_location('Turtle Rock - Big Key Chest'))
# in that case, if it contains the big key, we can also not waste a key on the roller switch door # handle key for a key situation in the usual way (by letting us logically open the door using the key locked inside it)
# however in keysanity being able to reach all other chests while only having three keys does not imply this contains if item in ['Small Key (Turtle Rock)']:
# a key, so we again need all four keys unless it contains the big key return 3
if can_reach_back: # if we lack backdoor access and cannot reach the back before opening this chest because it contains the big key
set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has('Small Key (Turtle Rock)', 4) or (item_name(state.world.get_location('Turtle Rock - Big Key Chest')) in ['Small Key (Turtle Rock)'])) # then that means there are two doors left that we cannot have spent a key on, (crystalroller and trinexx) so we only need
elif world.keysanity: # two keys
set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has('Small Key (Turtle Rock)', 2) if (item_name(state.world.get_location('Turtle Rock - Big Key Chest')) in ['Big Key (Turtle Rock)']) else state.has('Small Key (Turtle Rock)', 4) or (item_name(state.world.get_location('Turtle Rock - Big Key Chest')) in ['Small Key (Turtle Rock)'])) if item in ['Big Key (Turtle Rock)'] and not can_reach_back:
else: return 2
set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has('Small Key (Turtle Rock)', 2) if (item_name(state.world.get_location('Turtle Rock - Big Key Chest')) in ['Big Key (Turtle Rock)']) else state.has('Small Key (Turtle Rock)', 3) or (item_name(state.world.get_location('Turtle Rock - Big Key Chest')) in ['Small Key (Turtle Rock)'])) # otherwise we could potentially have opened every other door already, so we need all 4 keys.
# TODO add key-for-key logic to the above mess via always_allow rules. Ugh! return 4
set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has('Small Key (Turtle Rock)', tr_big_key_chest_keys_needed(state)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)' and state.has('Small Key (Turtle Rock)', 3))
# set big key restrictions # set big key restrictions
non_big_key_locations = ['Turtle Rock - Big Chest', 'Turtle Rock - Trinexx'] non_big_key_locations = ['Turtle Rock - Big Chest', 'Turtle Rock - Trinexx']