From 7972aa6320e45c122160245d433e7b2c1844f23c Mon Sep 17 00:00:00 2001 From: espeon65536 Date: Tue, 31 Aug 2021 14:47:57 -0500 Subject: [PATCH] split building owg connections and setting the rules for those connections --- worlds/alttp/EntranceShuffle.py | 9 ++++--- worlds/alttp/OverworldGlitchRules.py | 35 ++++++++++++++++++++++------ worlds/alttp/Rules.py | 4 ++-- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/worlds/alttp/EntranceShuffle.py b/worlds/alttp/EntranceShuffle.py index 2a4514bc..6871f99b 100644 --- a/worlds/alttp/EntranceShuffle.py +++ b/worlds/alttp/EntranceShuffle.py @@ -1,5 +1,6 @@ # ToDo: With shuffle_ganon option, prevent gtower from linking to an exit only location through a 2 entrance cave. from collections import defaultdict +from worlds.alttp.OverworldGlitchRules import overworld_glitch_connections from worlds.alttp.UnderworldGlitchRules import underworld_glitch_connections def link_entrances(world, player): @@ -1066,9 +1067,11 @@ def link_entrances(world, player): raise NotImplementedError( f'{world.shuffle[player]} Shuffling not supported yet. Player {world.get_player_name(player)}') - # mandatory hybrid major glitches connections - if world.logic[player] in ['hybridglitches', 'nologic']: - underworld_glitch_connections(world, player) + if world.logic[player] in ['owglitches', 'hybridglitches', 'nologic']: + overworld_glitch_connections(world, player) + # mandatory hybrid major glitches connections + if world.logic[player] in ['hybridglitches', 'nologic']: + underworld_glitch_connections(world, player) # check for swamp palace fix if world.get_entrance('Dam', player).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', player).connected_region.name != 'Swamp Palace (Entrance)': diff --git a/worlds/alttp/OverworldGlitchRules.py b/worlds/alttp/OverworldGlitchRules.py index 593a5407..705db7e7 100644 --- a/worlds/alttp/OverworldGlitchRules.py +++ b/worlds/alttp/OverworldGlitchRules.py @@ -235,24 +235,41 @@ def no_logic_rules(world, player): create_no_logic_connections(player, world, get_mirror_offset_spots_lw(player)) +def overworld_glitch_connections(world, player): + + # Boots-accessible locations. + create_owg_connections(player, world, get_boots_clip_exits_lw(world.mode[player] == 'inverted')) + create_owg_connections(player, world, get_boots_clip_exits_dw(world.mode[player] == 'inverted', player)) + + # Glitched speed drops. + create_owg_connections(player, world, get_glitched_speed_drops_dw(world.mode[player] == 'inverted')) + + # Mirror clip spots. + if world.mode[player] != 'inverted': + create_owg_connections(player, world, get_mirror_clip_spots_dw()) + create_owg_connections(player, world, get_mirror_offset_spots_dw()) + else: + create_owg_connections(player, world, get_mirror_offset_spots_lw(player)) + + def overworld_glitches_rules(world, player): # Boots-accessible locations. - create_owg_connections(player, world, get_boots_clip_exits_lw(world.mode[player] == 'inverted'), lambda state: state.can_boots_clip_lw(player)) - create_owg_connections(player, world, get_boots_clip_exits_dw(world.mode[player] == 'inverted', player), lambda state: state.can_boots_clip_dw(player)) + set_owg_connection_rules(player, world, get_boots_clip_exits_lw(world.mode[player] == 'inverted'), lambda state: state.can_boots_clip_lw(player)) + set_owg_connection_rules(player, world, get_boots_clip_exits_dw(world.mode[player] == 'inverted', player), lambda state: state.can_boots_clip_dw(player)) # Glitched speed drops. - create_owg_connections(player, world, get_glitched_speed_drops_dw(world.mode[player] == 'inverted'), lambda state: state.can_get_glitched_speed_dw(player)) + set_owg_connection_rules(player, world, get_glitched_speed_drops_dw(world.mode[player] == 'inverted'), lambda state: state.can_get_glitched_speed_dw(player)) # Dark Death Mountain Ledge Clip Spot also accessible with mirror. if world.mode[player] != 'inverted': add_alternate_rule(world.get_entrance('Dark Death Mountain Ledge Clip Spot', player), lambda state: state.has('Magic Mirror', player)) # Mirror clip spots. if world.mode[player] != 'inverted': - create_owg_connections(player, world, get_mirror_clip_spots_dw(), lambda state: state.has('Magic Mirror', player)) - create_owg_connections(player, world, get_mirror_offset_spots_dw(), lambda state: state.has('Magic Mirror', player) and state.can_boots_clip_lw(player)) + set_owg_connection_rules(player, world, get_mirror_clip_spots_dw(), lambda state: state.has('Magic Mirror', player)) + set_owg_connection_rules(player, world, get_mirror_offset_spots_dw(), lambda state: state.has('Magic Mirror', player) and state.can_boots_clip_lw(player)) else: - create_owg_connections(player, world, get_mirror_offset_spots_lw(player), lambda state: state.has('Magic Mirror', player) and state.can_boots_clip_dw(player)) + set_owg_connection_rules(player, world, get_mirror_offset_spots_lw(player), lambda state: state.has('Magic Mirror', player) and state.can_boots_clip_dw(player)) # Regions that require the boots and some other stuff. if world.mode[player] != 'inverted': @@ -282,12 +299,16 @@ def create_no_logic_connections(player, world, connections): parent.exits.append(connection) connection.connect(target) -def create_owg_connections(player, world, connections, default_rule): +def create_owg_connections(player, world, connections): for entrance, parent_region, target_region, *rule_override in connections: parent = world.get_region(parent_region, player) target = world.get_region(target_region, player) connection = Entrance(player, entrance, parent) parent.exits.append(connection) connection.connect(target) + +def set_owg_connection_rules(player, world, connections, default_rule): + for entrance, _, _, *rule_override in connections: + connection = world.get_entrance(entrance, player) rule = rule_override[0] if len(rule_override) > 0 else default_rule connection.access_rule = rule diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 28b4acb8..97fe40ff 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -56,11 +56,11 @@ def set_rules(world): # entrances. The overworld_glitches_rules set is primarily additive. no_glitches_rules(world, player) fake_flipper_rules(world, player) - overworld_glitches_rules(world, player) + # overworld_glitches_rules(world, player) elif world.logic[player] in ['hybridglitches', 'nologic']: no_glitches_rules(world, player) fake_flipper_rules(world, player) - overworld_glitches_rules(world, player) + # overworld_glitches_rules(world, player) underworld_glitches_rules(world, player) elif world.logic[player] == 'minorglitches': no_glitches_rules(world, player)