From db1a37b374b22a5da968270eabe357deadbd2fb6 Mon Sep 17 00:00:00 2001 From: compiling <8335770+compiling@users.noreply.github.com> Date: Tue, 27 Apr 2021 18:12:24 +1000 Subject: [PATCH] Create glitch connections in advance for dungeon generation. Add overworld glitches to the gui. --- Main.py | 5 ++++ OverworldGlitchRules.py | 26 ++++++++----------- Rules.py | 5 ++-- resources/app/gui/lang/en.json | 1 + resources/app/gui/randomize/item/widgets.json | 1 + 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Main.py b/Main.py index 4ec7882a..02c70944 100644 --- a/Main.py +++ b/Main.py @@ -11,6 +11,7 @@ import zlib from BaseClasses import World, CollectionState, Item, Region, Location, Shop, Entrance, Settings from Items import ItemFactory from KeyDoorShuffle import validate_key_placement +from OverworldGlitchRules import create_owg_connections from PotShuffle import shuffle_pots from Regions import create_regions, create_shops, mark_light_world_regions, create_dungeon_regions, adjust_locations from InvertedRegions import create_inverted_regions, mark_dark_world_regions @@ -123,6 +124,8 @@ def main(args, seed=None, fish=None): create_regions(world, player) else: create_inverted_regions(world, player) + if world.logic[player] in ('owglitches', 'nologic'): + create_owg_connections(world, player) create_dungeon_regions(world, player) create_shops(world, player) create_doors(world, player) @@ -419,6 +422,8 @@ def copy_world(world): create_shops(ret, player) create_rooms(ret, player) create_dungeons(ret, player) + if world.logic[player] in ('owglitches', 'nologic'): + create_owg_connections(ret, player) copy_dynamic_regions_and_locations(world, ret) for player in range(1, world.players + 1): diff --git a/OverworldGlitchRules.py b/OverworldGlitchRules.py index fa72d819..b038d74e 100644 --- a/OverworldGlitchRules.py +++ b/OverworldGlitchRules.py @@ -212,9 +212,9 @@ def get_mirror_offset_spots_lw(player): yield ('Death Mountain Offset Mirror (Houlihan Exit)', 'Death Mountain', 'Hyrule Castle Ledge', lambda state: state.has_Mirror(player) and state.can_boots_clip_dw(player) and state.has_Pearl(player)) -def no_logic_rules(world, player): +def create_owg_connections(world, player): """ - Add OWG transitions to no logic player's world + Add OWG transitions to player's world without logic """ create_no_logic_connections(player, world, get_boots_clip_exits_lw(world.mode == 'inverted')) create_no_logic_connections(player, world, get_boots_clip_exits_dw(world.mode == 'inverted')) @@ -231,23 +231,22 @@ def no_logic_rules(world, player): def overworld_glitches_rules(world, player): - # Boots-accessible locations. - create_owg_connections(player, world, get_boots_clip_exits_lw(world.mode == 'inverted'), lambda state: state.can_boots_clip_lw(player)) - create_owg_connections(player, world, get_boots_clip_exits_dw(world.mode == 'inverted'), lambda state: state.can_boots_clip_dw(player)) + set_owg_rules(player, world, get_boots_clip_exits_lw(world.mode == 'inverted'), lambda state: state.can_boots_clip_lw(player)) + set_owg_rules(player, world, get_boots_clip_exits_dw(world.mode == 'inverted'), lambda state: state.can_boots_clip_dw(player)) # Glitched speed drops. - create_owg_connections(player, world, get_glitched_speed_drops_dw(world.mode == 'inverted'), lambda state: state.can_get_glitched_speed_dw(player)) + set_owg_rules(player, world, get_glitched_speed_drops_dw(world.mode == 'inverted'), lambda state: state.can_get_glitched_speed_dw(player)) # Dark Death Mountain Ledge Clip Spot also accessible with mirror. if world.mode != 'inverted': add_alternate_rule(world.get_entrance('Dark Death Mountain Ledge Clip Spot', player), lambda state: state.has_Mirror(player)) # Mirror clip spots. if world.mode != 'inverted': - create_owg_connections(player, world, get_mirror_clip_spots_dw(), lambda state: state.has_Mirror(player)) - create_owg_connections(player, world, get_mirror_offset_spots_dw(), lambda state: state.has_Mirror(player) and state.can_boots_clip_lw(player)) + set_owg_rules(player, world, get_mirror_clip_spots_dw(), lambda state: state.has_Mirror(player)) + set_owg_rules(player, world, get_mirror_offset_spots_dw(), lambda state: state.has_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_Mirror(player) and state.can_boots_clip_dw(player)) + set_owg_rules(player, world, get_mirror_offset_spots_lw(player), lambda state: state.has_Mirror(player) and state.can_boots_clip_dw(player)) # Regions that require the boots and some other stuff. if world.mode != 'inverted': @@ -277,12 +276,9 @@ 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 set_owg_rules(player, world, connections, default_rule): 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) + 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/Rules.py b/Rules.py index 1a906083..d2886ea1 100644 --- a/Rules.py +++ b/Rules.py @@ -5,14 +5,13 @@ from collections import deque import OverworldGlitchRules from BaseClasses import CollectionState, RegionType, DoorType, Entrance, CrystalBarrier from RoomData import DoorKind -from OverworldGlitchRules import overworld_glitches_rules, no_logic_rules +from OverworldGlitchRules import overworld_glitches_rules def set_rules(world, player): if world.logic[player] == 'nologic': logging.getLogger('').info('WARNING! Seeds generated under this logic often require major glitches and may be impossible!') - no_logic_rules(world, player) world.get_region('Menu', player).can_reach_private = lambda state: True for exit in world.get_region('Menu', player).exits: exit.hide_path = True @@ -36,6 +35,8 @@ def set_rules(world, player): no_glitches_rules(world, player) elif world.logic[player] == 'minorglitches': logging.getLogger('').info('Minor Glitches may be buggy still. No guarantee for proper logic checks.') + no_glitches_rules(world, player) + fake_flipper_rules(world, player) elif world.logic[player] == 'owglitches': logging.getLogger('').info('There is a chance OWG has bugged edge case rulesets, especially in inverted. Definitely file a report on GitHub if you see anything strange.') # Initially setting no_glitches_rules to set the baseline rules for some diff --git a/resources/app/gui/lang/en.json b/resources/app/gui/lang/en.json index 40ec0b03..a5f3fec6 100644 --- a/resources/app/gui/lang/en.json +++ b/resources/app/gui/lang/en.json @@ -195,6 +195,7 @@ "randomizer.item.logiclevel": "Logic Level", "randomizer.item.logiclevel.noglitches": "No Glitches", "randomizer.item.logiclevel.minorglitches": "Minor Glitches", + "randomizer.item.logiclevel.owglitches": "Overworld Glitches", "randomizer.item.logiclevel.nologic": "No Logic", "randomizer.item.goal": "Goal", diff --git a/resources/app/gui/randomize/item/widgets.json b/resources/app/gui/randomize/item/widgets.json index fa8681d3..058d03ba 100644 --- a/resources/app/gui/randomize/item/widgets.json +++ b/resources/app/gui/randomize/item/widgets.json @@ -19,6 +19,7 @@ "options": [ "noglitches", "minorglitches", + "owglitches", "nologic" ] },