From 84402a1b55fa516850631ea066851661bb9f59b2 Mon Sep 17 00:00:00 2001 From: lordlou <87331798+lordlou@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:52:34 -0400 Subject: [PATCH] SM and SMZ3 apworld support (#1677) --- setup.py | 2 + worlds/sm/Client.py | 6 +- worlds/sm/Regions.py | 4 +- worlds/sm/Rom.py | 3 +- worlds/sm/Rules.py | 6 +- worlds/sm/__init__.py | 43 ++++----- worlds/sm/variaRandomizer/graph/graph.py | 8 +- .../sm/variaRandomizer/graph/graph_utils.py | 10 +-- worlds/sm/variaRandomizer/graph/location.py | 2 +- .../graph/vanilla/graph_access.py | 12 +-- .../graph/vanilla/graph_helpers.py | 12 +-- .../graph/vanilla/graph_locations.py | 10 +-- worlds/sm/variaRandomizer/logic/helpers.py | 10 +-- worlds/sm/variaRandomizer/logic/logic.py | 16 ++-- .../sm/variaRandomizer/logic/smboolmanager.py | 12 +-- .../sm/variaRandomizer/patches/patchaccess.py | 21 ++--- worlds/sm/variaRandomizer/rando/Choice.py | 6 +- worlds/sm/variaRandomizer/rando/Filler.py | 18 ++-- .../sm/variaRandomizer/rando/GraphBuilder.py | 8 +- .../variaRandomizer/rando/ItemLocContainer.py | 6 +- worlds/sm/variaRandomizer/rando/Items.py | 4 +- worlds/sm/variaRandomizer/rando/RandoExec.py | 22 ++--- .../sm/variaRandomizer/rando/RandoServices.py | 8 +- .../sm/variaRandomizer/rando/RandoSettings.py | 6 +- worlds/sm/variaRandomizer/rando/RandoSetup.py | 20 ++--- .../sm/variaRandomizer/rando/Restrictions.py | 6 +- worlds/sm/variaRandomizer/randomizer.py | 30 +++---- worlds/sm/variaRandomizer/rom/ips.py | 4 +- worlds/sm/variaRandomizer/rom/rom.py | 2 +- worlds/sm/variaRandomizer/rom/rom_patches.py | 2 +- worlds/sm/variaRandomizer/rom/rompatcher.py | 18 ++-- .../sm/variaRandomizer/utils/doorsmanager.py | 6 +- worlds/sm/variaRandomizer/utils/parameters.py | 4 +- worlds/sm/variaRandomizer/utils/utils.py | 61 +++++++++++-- worlds/smz3/Client.py | 6 +- worlds/smz3/TotalSMZ3/Item.py | 8 +- worlds/smz3/TotalSMZ3/Location.py | 6 +- worlds/smz3/TotalSMZ3/Patch.py | 48 +++++----- worlds/smz3/TotalSMZ3/Region.py | 5 +- .../Regions/SuperMetroid/Brinstar/Blue.py | 6 +- .../Regions/SuperMetroid/Brinstar/Green.py | 8 +- .../Regions/SuperMetroid/Brinstar/Kraid.py | 8 +- .../Regions/SuperMetroid/Brinstar/Pink.py | 8 +- .../Regions/SuperMetroid/Brinstar/Red.py | 8 +- .../Regions/SuperMetroid/Crateria/Central.py | 6 +- .../Regions/SuperMetroid/Crateria/East.py | 8 +- .../Regions/SuperMetroid/Crateria/West.py | 8 +- .../Regions/SuperMetroid/Maridia/Inner.py | 8 +- .../Regions/SuperMetroid/Maridia/Outer.py | 8 +- .../Regions/SuperMetroid/NorfairLower/East.py | 8 +- .../Regions/SuperMetroid/NorfairLower/West.py | 8 +- .../SuperMetroid/NorfairUpper/Crocomire.py | 8 +- .../Regions/SuperMetroid/NorfairUpper/East.py | 8 +- .../Regions/SuperMetroid/NorfairUpper/West.py | 8 +- .../Regions/SuperMetroid/WreckedShip.py | 8 +- .../TotalSMZ3/Regions/Zelda/CastleTower.py | 8 +- .../Zelda/DarkWorld/DeathMountain/East.py | 8 +- .../Zelda/DarkWorld/DeathMountain/West.py | 6 +- .../TotalSMZ3/Regions/Zelda/DarkWorld/Mire.py | 8 +- .../Regions/Zelda/DarkWorld/NorthEast.py | 8 +- .../Regions/Zelda/DarkWorld/NorthWest.py | 8 +- .../Regions/Zelda/DarkWorld/South.py | 8 +- .../TotalSMZ3/Regions/Zelda/DesertPalace.py | 8 +- .../TotalSMZ3/Regions/Zelda/EasternPalace.py | 8 +- .../TotalSMZ3/Regions/Zelda/GanonsTower.py | 8 +- .../TotalSMZ3/Regions/Zelda/HyruleCastle.py | 8 +- .../smz3/TotalSMZ3/Regions/Zelda/IcePalace.py | 8 +- .../Zelda/LightWorld/DeathMountain/East.py | 8 +- .../Zelda/LightWorld/DeathMountain/West.py | 8 +- .../Regions/Zelda/LightWorld/NorthEast.py | 6 +- .../Regions/Zelda/LightWorld/NorthWest.py | 6 +- .../Regions/Zelda/LightWorld/South.py | 6 +- .../TotalSMZ3/Regions/Zelda/MiseryMire.py | 10 +-- .../Regions/Zelda/PalaceOfDarkness.py | 8 +- .../TotalSMZ3/Regions/Zelda/SkullWoods.py | 8 +- .../TotalSMZ3/Regions/Zelda/SwampPalace.py | 8 +- .../TotalSMZ3/Regions/Zelda/ThievesTown.py | 8 +- .../TotalSMZ3/Regions/Zelda/TowerOfHera.py | 8 +- .../TotalSMZ3/Regions/Zelda/TurtleRock.py | 10 +-- worlds/smz3/TotalSMZ3/Text/Dialog.py | 2 +- worlds/smz3/TotalSMZ3/Text/StringTable.py | 8 +- worlds/smz3/TotalSMZ3/Text/Texts.py | 43 ++++++--- worlds/smz3/TotalSMZ3/World.py | 88 +++++++++---------- worlds/smz3/TotalSMZ3/WorldState.py | 6 +- worlds/smz3/__init__.py | 23 ++--- worlds/smz3/ips.py | 4 +- 86 files changed, 522 insertions(+), 445 deletions(-) diff --git a/setup.py b/setup.py index 5447ed8b..4b0c3954 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,8 @@ apworlds: set = { "Minecraft", "The Messenger", "Links Awakening DX", + "Super Metroid", + "SMZ3", } diff --git a/worlds/sm/Client.py b/worlds/sm/Client.py index 16aea935..df73ae47 100644 --- a/worlds/sm/Client.py +++ b/worlds/sm/Client.py @@ -118,7 +118,7 @@ class SMSNIClient(SNIClient): snes_buffered_write(ctx, SM_SEND_QUEUE_RCOUNT, bytes([recv_index & 0xFF, (recv_index >> 8) & 0xFF])) - from worlds.sm import locations_start_id + from . import locations_start_id location_id = locations_start_id + item_index ctx.locations_checked.add(location_id) @@ -133,8 +133,8 @@ class SMSNIClient(SNIClient): item_out_ptr = data[0] | (data[1] << 8) - from worlds.sm import items_start_id - from worlds.sm import locations_start_id + from . import items_start_id + from . import locations_start_id if item_out_ptr < len(ctx.items_received): item = ctx.items_received[item_out_ptr] item_id = item.item - items_start_id diff --git a/worlds/sm/Regions.py b/worlds/sm/Regions.py index f8ef9088..ee6af408 100644 --- a/worlds/sm/Regions.py +++ b/worlds/sm/Regions.py @@ -1,8 +1,8 @@ def create_regions(self, world, player: int): from . import create_region from BaseClasses import Entrance - from worlds.sm.variaRandomizer.logic.logic import Logic - from worlds.sm.variaRandomizer.graph.vanilla.graph_locations import locationsDict + from .variaRandomizer.logic.logic import Logic + from .variaRandomizer.graph.vanilla.graph_locations import locationsDict regions = [] for accessPoint in Logic.accessPoints: diff --git a/worlds/sm/Rom.py b/worlds/sm/Rom.py index 67c0780d..ac516ae4 100644 --- a/worlds/sm/Rom.py +++ b/worlds/sm/Rom.py @@ -5,6 +5,7 @@ import json import Utils from Utils import read_snes_rom from worlds.Files import APDeltaPatch +from .variaRandomizer.utils.utils import openFile SMJUHASH = '21f3e98df4780ee1c667b84e57d88675' SM_ROM_MAX_PLAYERID = 65535 @@ -43,7 +44,7 @@ def get_base_rom_path(file_name: str = "") -> str: return file_name def get_sm_symbols(sym_json_path) -> dict: - with open(sym_json_path, "r") as stream: + with openFile(sym_json_path, "r") as stream: symbols = json.load(stream) symboltable = {} for name, sixdigitaddr in symbols.items(): diff --git a/worlds/sm/Rules.py b/worlds/sm/Rules.py index bce92473..15706987 100644 --- a/worlds/sm/Rules.py +++ b/worlds/sm/Rules.py @@ -1,7 +1,7 @@ -from ..generic.Rules import set_rule, add_rule +from worlds.generic.Rules import set_rule, add_rule -from worlds.sm.variaRandomizer.graph.vanilla.graph_locations import locationsDict -from worlds.sm.variaRandomizer.logic.logic import Logic +from .variaRandomizer.graph.vanilla.graph_locations import locationsDict +from .variaRandomizer.logic.logic import Logic def evalSMBool(smbool, maxDiff): return smbool.bool == True and smbool.difficulty <= maxDiff diff --git a/worlds/sm/__init__.py b/worlds/sm/__init__.py index 255551c2..e8e4c56a 100644 --- a/worlds/sm/__init__.py +++ b/worlds/sm/__init__.py @@ -7,6 +7,9 @@ import threading import base64 from typing import Any, Dict, Iterable, List, Set, TextIO, TypedDict +from BaseClasses import Region, Entrance, Location, MultiWorld, Item, ItemClassification, CollectionState, Tutorial +from worlds.AutoWorld import World, AutoLogicRegister, WebWorld + logger = logging.getLogger("Super Metroid") from .Regions import create_regions @@ -16,20 +19,18 @@ from .Client import SMSNIClient from .Rom import get_base_rom_path, SM_ROM_MAX_PLAYERID, SM_ROM_PLAYERDATA_COUNT, SMDeltaPatch, get_sm_symbols import Utils -from BaseClasses import Region, Entrance, Location, MultiWorld, Item, ItemClassification, CollectionState, Tutorial -from ..AutoWorld import World, AutoLogicRegister, WebWorld - -from worlds.sm.variaRandomizer.logic.smboolmanager import SMBoolManager -from worlds.sm.variaRandomizer.graph.vanilla.graph_locations import locationsDict -from worlds.sm.variaRandomizer.graph.graph_utils import getAccessPoint -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocation -from worlds.sm.variaRandomizer.rando.Items import ItemManager -from worlds.sm.variaRandomizer.utils.parameters import * -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.randomizer import VariaRandomizer -from worlds.sm.variaRandomizer.utils.doorsmanager import DoorsManager -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils +from .variaRandomizer.logic.smboolmanager import SMBoolManager +from .variaRandomizer.graph.vanilla.graph_locations import locationsDict +from .variaRandomizer.graph.graph_utils import getAccessPoint +from .variaRandomizer.rando.ItemLocContainer import ItemLocation +from .variaRandomizer.rando.Items import ItemManager +from .variaRandomizer.utils.parameters import * +from .variaRandomizer.utils.utils import openFile +from .variaRandomizer.logic.logic import Logic +from .variaRandomizer.randomizer import VariaRandomizer +from .variaRandomizer.utils.doorsmanager import DoorsManager +from .variaRandomizer.rom.rom_patches import RomPatches +from .variaRandomizer.graph.graph_utils import GraphUtils class SMCollectionState(metaclass=AutoLogicRegister): @@ -279,14 +280,14 @@ class SMWorld(World): # first apply the sm multiworld code patch named 'basepatch' (also has empty tables that we'll overwrite), # + apply some patches from varia that we want to be always-on. # basepatch and variapatches are both generated from https://github.com/lordlou/SMBasepatch - romPatcher.applyIPSPatch(os.path.join(os.path.dirname(__file__), - "data", "SMBasepatch_prebuilt", "multiworld-basepatch.ips")) - romPatcher.applyIPSPatch(os.path.join(os.path.dirname(__file__), - "data", "SMBasepatch_prebuilt", "variapatches.ips")) + romPatcher.applyIPSPatch("/".join((os.path.dirname(self.__file__), + "data", "SMBasepatch_prebuilt", "multiworld-basepatch.ips"))) + romPatcher.applyIPSPatch("/".join((os.path.dirname(self.__file__), + "data", "SMBasepatch_prebuilt", "variapatches.ips"))) def APPostPatchRom(self, romPatcher): - symbols = get_sm_symbols(os.path.join(os.path.dirname(__file__), - "data", "SMBasepatch_prebuilt", "sm-basepatch-symbols.json")) + symbols = get_sm_symbols("/".join((os.path.dirname(self.__file__), + "data", "SMBasepatch_prebuilt", "sm-basepatch-symbols.json"))) # gather all player ids and names relevant to this rom, then write player name and player id data tables playerIdSet: Set[int] = {0} # 0 is for "Archipelago" server @@ -376,7 +377,7 @@ class SMWorld(World): idx = 0 offworldSprites: List[ByteEdit] = [] for itemSprite in itemSprites: - with open(os.path.join(os.path.dirname(__file__), "data", "custom_sprite", itemSprite["fileName"]), 'rb') as stream: + with openFile("/".join((os.path.dirname(self.__file__), "data", "custom_sprite", itemSprite["fileName"])), 'rb') as stream: buffer = bytearray(stream.read()) offworldSprites.append({"sym": symbols[itemSprite["paletteSymbolName"]], "offset": 0, diff --git a/worlds/sm/variaRandomizer/graph/graph.py b/worlds/sm/variaRandomizer/graph/graph.py index bf9af48d..3e296500 100644 --- a/worlds/sm/variaRandomizer/graph/graph.py +++ b/worlds/sm/variaRandomizer/graph/graph.py @@ -1,9 +1,9 @@ import copy, logging from operator import attrgetter -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.logic.smbool import SMBool, smboolFalse -from worlds.sm.variaRandomizer.utils.parameters import infinity -from worlds.sm.variaRandomizer.logic.helpers import Bosses +from ..utils import log +from ..logic.smbool import SMBool, smboolFalse +from ..utils.parameters import infinity +from ..logic.helpers import Bosses class Path(object): __slots__ = ( 'path', 'pdiff', 'distance' ) diff --git a/worlds/sm/variaRandomizer/graph/graph_utils.py b/worlds/sm/variaRandomizer/graph/graph_utils.py index e147da5e..ccff42a4 100644 --- a/worlds/sm/variaRandomizer/graph/graph_utils.py +++ b/worlds/sm/variaRandomizer/graph/graph_utils.py @@ -1,10 +1,10 @@ import copy import random -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.utils.parameters import Knows -from worlds.sm.variaRandomizer.graph.location import locationsDict -from worlds.sm.variaRandomizer.rom.rom import snes_to_pc -from worlds.sm.variaRandomizer.utils import log +from ..logic.logic import Logic +from ..utils.parameters import Knows +from ..graph.location import locationsDict +from ..rom.rom import snes_to_pc +from ..utils import log # order expected by ROM patches graphAreas = [ diff --git a/worlds/sm/variaRandomizer/graph/location.py b/worlds/sm/variaRandomizer/graph/location.py index 92eb1ccb..fb205853 100644 --- a/worlds/sm/variaRandomizer/graph/location.py +++ b/worlds/sm/variaRandomizer/graph/location.py @@ -1,4 +1,4 @@ -from worlds.sm.variaRandomizer.utils.parameters import infinity +from ..utils.parameters import infinity import copy class Location: diff --git a/worlds/sm/variaRandomizer/graph/vanilla/graph_access.py b/worlds/sm/variaRandomizer/graph/vanilla/graph_access.py index 279f249e..501dab8f 100644 --- a/worlds/sm/variaRandomizer/graph/vanilla/graph_access.py +++ b/worlds/sm/variaRandomizer/graph/vanilla/graph_access.py @@ -1,9 +1,9 @@ -from worlds.sm.variaRandomizer.graph.graph import AccessPoint -from worlds.sm.variaRandomizer.utils.parameters import Settings -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.logic.smbool import SMBool -from worlds.sm.variaRandomizer.logic.helpers import Bosses -from worlds.sm.variaRandomizer.logic.cache import Cache +from ...graph.graph import AccessPoint +from ...utils.parameters import Settings +from ...rom.rom_patches import RomPatches +from ...logic.smbool import SMBool +from ...logic.helpers import Bosses +from ...logic.cache import Cache # all access points and traverse functions accessPoints = [ diff --git a/worlds/sm/variaRandomizer/graph/vanilla/graph_helpers.py b/worlds/sm/variaRandomizer/graph/vanilla/graph_helpers.py index 41ffe511..de18ab86 100644 --- a/worlds/sm/variaRandomizer/graph/vanilla/graph_helpers.py +++ b/worlds/sm/variaRandomizer/graph/vanilla/graph_helpers.py @@ -1,11 +1,11 @@ from math import ceil -from worlds.sm.variaRandomizer.logic.smbool import SMBool -from worlds.sm.variaRandomizer.logic.helpers import Helpers, Bosses -from worlds.sm.variaRandomizer.logic.cache import Cache -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.graph.graph_utils import getAccessPoint -from worlds.sm.variaRandomizer.utils.parameters import Settings +from ...logic.smbool import SMBool +from ...logic.helpers import Helpers, Bosses +from ...logic.cache import Cache +from ...rom.rom_patches import RomPatches +from ...graph.graph_utils import getAccessPoint +from ...utils.parameters import Settings class HelpersGraph(Helpers): def __init__(self, smbm): diff --git a/worlds/sm/variaRandomizer/graph/vanilla/graph_locations.py b/worlds/sm/variaRandomizer/graph/vanilla/graph_locations.py index 62eaf3c0..5bf3c0e6 100644 --- a/worlds/sm/variaRandomizer/graph/vanilla/graph_locations.py +++ b/worlds/sm/variaRandomizer/graph/vanilla/graph_locations.py @@ -1,8 +1,8 @@ -from worlds.sm.variaRandomizer.logic.helpers import Bosses -from worlds.sm.variaRandomizer.utils.parameters import Settings -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.logic.smbool import SMBool -from worlds.sm.variaRandomizer.graph.location import locationsDict +from ...logic.helpers import Bosses +from ...utils.parameters import Settings +from ...rom.rom_patches import RomPatches +from ...logic.smbool import SMBool +from ...graph.location import locationsDict locationsDict["Energy Tank, Gauntlet"].AccessFrom = { 'Landing Site': lambda sm: SMBool(True) diff --git a/worlds/sm/variaRandomizer/logic/helpers.py b/worlds/sm/variaRandomizer/logic/helpers.py index 3f8720d8..717561e7 100644 --- a/worlds/sm/variaRandomizer/logic/helpers.py +++ b/worlds/sm/variaRandomizer/logic/helpers.py @@ -1,11 +1,11 @@ import math -from worlds.sm.variaRandomizer.logic.cache import Cache -from worlds.sm.variaRandomizer.logic.smbool import SMBool, smboolFalse -from worlds.sm.variaRandomizer.utils.parameters import Settings, easy, medium, diff2text -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.utils.utils import normalizeRounding +from ..logic.cache import Cache +from ..logic.smbool import SMBool, smboolFalse +from ..utils.parameters import Settings, easy, medium, diff2text +from ..rom.rom_patches import RomPatches +from ..utils.utils import normalizeRounding class Helpers(object): diff --git a/worlds/sm/variaRandomizer/logic/logic.py b/worlds/sm/variaRandomizer/logic/logic.py index 6ce20406..d58d0980 100644 --- a/worlds/sm/variaRandomizer/logic/logic.py +++ b/worlds/sm/variaRandomizer/logic/logic.py @@ -4,20 +4,20 @@ class Logic(object): @staticmethod def factory(implementation): if implementation == 'vanilla': - from worlds.sm.variaRandomizer.graph.vanilla.graph_helpers import HelpersGraph - from worlds.sm.variaRandomizer.graph.vanilla.graph_access import accessPoints - from worlds.sm.variaRandomizer.graph.vanilla.graph_locations import locations - from worlds.sm.variaRandomizer.graph.vanilla.graph_locations import LocationsHelper + from ..graph.vanilla.graph_helpers import HelpersGraph + from ..graph.vanilla.graph_access import accessPoints + from ..graph.vanilla.graph_locations import locations + from ..graph.vanilla.graph_locations import LocationsHelper Logic.locations = locations Logic.accessPoints = accessPoints Logic.HelpersGraph = HelpersGraph Logic.patches = implementation Logic.LocationsHelper = LocationsHelper elif implementation == 'rotation': - from worlds.sm.variaRandomizer.graph.rotation.graph_helpers import HelpersGraph - from worlds.sm.variaRandomizer.graph.rotation.graph_access import accessPoints - from worlds.sm.variaRandomizer.graph.rotation.graph_locations import locations - from worlds.sm.variaRandomizer.graph.rotation.graph_locations import LocationsHelper + from ..graph.rotation.graph_helpers import HelpersGraph + from ..graph.rotation.graph_access import accessPoints + from ..graph.rotation.graph_locations import locations + from ..graph.rotation.graph_locations import LocationsHelper Logic.locations = locations Logic.accessPoints = accessPoints Logic.HelpersGraph = HelpersGraph diff --git a/worlds/sm/variaRandomizer/logic/smboolmanager.py b/worlds/sm/variaRandomizer/logic/smboolmanager.py index a351e163..d4de6dae 100644 --- a/worlds/sm/variaRandomizer/logic/smboolmanager.py +++ b/worlds/sm/variaRandomizer/logic/smboolmanager.py @@ -1,11 +1,11 @@ # object to handle the smbools and optimize them -from worlds.sm.variaRandomizer.logic.cache import Cache -from worlds.sm.variaRandomizer.logic.smbool import SMBool, smboolFalse -from worlds.sm.variaRandomizer.logic.helpers import Bosses -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.utils.doorsmanager import DoorsManager -from worlds.sm.variaRandomizer.utils.parameters import Knows, isKnows +from ..logic.cache import Cache +from ..logic.smbool import SMBool, smboolFalse +from ..logic.helpers import Bosses +from ..logic.logic import Logic +from ..utils.doorsmanager import DoorsManager +from ..utils.parameters import Knows, isKnows import logging import sys diff --git a/worlds/sm/variaRandomizer/patches/patchaccess.py b/worlds/sm/variaRandomizer/patches/patchaccess.py index 9ed83172..f7f8060a 100644 --- a/worlds/sm/variaRandomizer/patches/patchaccess.py +++ b/worlds/sm/variaRandomizer/patches/patchaccess.py @@ -1,17 +1,18 @@ -import os, importlib -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.patches.common.patches import patches, additional_PLMs -from worlds.sm.variaRandomizer.utils.parameters import appDir +import importlib +from ..logic.logic import Logic +from ..patches.common.patches import patches, additional_PLMs +from ..utils.parameters import appDir +from ..utils.utils import listDir, exists class PatchAccess(object): def __init__(self): # load all ips patches self.patchesPath = {} - commonDir = os.path.join(appDir, 'worlds/sm/variaRandomizer/patches/common/ips/') - for patch in os.listdir(commonDir): + commonDir = "/".join((appDir, 'worlds/sm/variaRandomizer/patches/common/ips')) + for patch in listDir(commonDir): self.patchesPath[patch] = commonDir - logicDir = os.path.join(appDir, 'worlds/sm/variaRandomizer/patches/{}/ips/'.format(Logic.patches)) - for patch in os.listdir(logicDir): + logicDir = "/".join((appDir, 'worlds/sm/variaRandomizer/patches/{}/ips'.format(Logic.patches))) + for patch in listDir(logicDir): self.patchesPath[patch] = logicDir # load dict patches @@ -27,10 +28,10 @@ class PatchAccess(object): def getPatchPath(self, patch): # is patch preloaded if patch in self.patchesPath: - return os.path.join(self.patchesPath[patch], patch) + return "/".join((self.patchesPath[patch], patch)) else: # patchs from varia_repository used by the customizer for permalinks - if os.path.exists(patch): + if exists(patch): return patch else: raise Exception("unknown patch: {}".format(patch)) diff --git a/worlds/sm/variaRandomizer/rando/Choice.py b/worlds/sm/variaRandomizer/rando/Choice.py index e200448b..b4f4166f 100644 --- a/worlds/sm/variaRandomizer/rando/Choice.py +++ b/worlds/sm/variaRandomizer/rando/Choice.py @@ -1,7 +1,7 @@ import random -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.utils.utils import getRangeDict, chooseFromRange -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocation +from ..utils import log +from ..utils.utils import getRangeDict, chooseFromRange +from ..rando.ItemLocContainer import ItemLocation # helper object to choose item/loc class Choice(object): diff --git a/worlds/sm/variaRandomizer/rando/Filler.py b/worlds/sm/variaRandomizer/rando/Filler.py index 733e7cdb..00caa7e6 100644 --- a/worlds/sm/variaRandomizer/rando/Filler.py +++ b/worlds/sm/variaRandomizer/rando/Filler.py @@ -1,14 +1,14 @@ import copy, time, random -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.logic.cache import RequestCache -from worlds.sm.variaRandomizer.rando.RandoServices import RandoServices -from worlds.sm.variaRandomizer.rando.Choice import ItemThenLocChoice -from worlds.sm.variaRandomizer.rando.RandoServices import ComebackCheckType -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocation, getItemLocationsStr -from worlds.sm.variaRandomizer.utils.parameters import infinity -from worlds.sm.variaRandomizer.logic.helpers import diffValue2txt -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils +from ..utils import log +from ..logic.cache import RequestCache +from ..rando.RandoServices import RandoServices +from ..rando.Choice import ItemThenLocChoice +from ..rando.RandoServices import ComebackCheckType +from ..rando.ItemLocContainer import ItemLocation, getItemLocationsStr +from ..utils.parameters import infinity +from ..logic.helpers import diffValue2txt +from ..graph.graph_utils import GraphUtils # base class for fillers. a filler responsibility is to fill a given # ItemLocContainer while a certain condition is fulfilled (usually diff --git a/worlds/sm/variaRandomizer/rando/GraphBuilder.py b/worlds/sm/variaRandomizer/rando/GraphBuilder.py index 6eeb1d86..9cde4206 100644 --- a/worlds/sm/variaRandomizer/rando/GraphBuilder.py +++ b/worlds/sm/variaRandomizer/rando/GraphBuilder.py @@ -1,9 +1,9 @@ import random, copy -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils, vanillaTransitions, vanillaBossesTransitions, escapeSource, escapeTargets -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.graph.graph import AccessGraphRando as AccessGraph +from ..utils import log +from ..graph.graph_utils import GraphUtils, vanillaTransitions, vanillaBossesTransitions, escapeSource, escapeTargets +from ..logic.logic import Logic +from ..graph.graph import AccessGraphRando as AccessGraph # creates graph and handles randomized escape class GraphBuilder(object): diff --git a/worlds/sm/variaRandomizer/rando/ItemLocContainer.py b/worlds/sm/variaRandomizer/rando/ItemLocContainer.py index 859fe550..524e3190 100644 --- a/worlds/sm/variaRandomizer/rando/ItemLocContainer.py +++ b/worlds/sm/variaRandomizer/rando/ItemLocContainer.py @@ -1,8 +1,8 @@ import copy -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.logic.smbool import SMBool, smboolFalse -from worlds.sm.variaRandomizer.logic.smboolmanager import SMBoolManager +from ..utils import log +from ..logic.smbool import SMBool, smboolFalse +from ..logic.smboolmanager import SMBoolManager from collections import Counter class ItemLocation(object): diff --git a/worlds/sm/variaRandomizer/rando/Items.py b/worlds/sm/variaRandomizer/rando/Items.py index 6c4d3511..6bfa8530 100644 --- a/worlds/sm/variaRandomizer/rando/Items.py +++ b/worlds/sm/variaRandomizer/rando/Items.py @@ -1,5 +1,5 @@ -from worlds.sm.variaRandomizer.utils.utils import randGaussBounds, getRangeDict, chooseFromRange -from worlds.sm.variaRandomizer.utils import log +from ..utils.utils import randGaussBounds, getRangeDict, chooseFromRange +from ..utils import log import logging, copy, random class Item: diff --git a/worlds/sm/variaRandomizer/rando/RandoExec.py b/worlds/sm/variaRandomizer/rando/RandoExec.py index 9ff6fc2d..3505b180 100644 --- a/worlds/sm/variaRandomizer/rando/RandoExec.py +++ b/worlds/sm/variaRandomizer/rando/RandoExec.py @@ -1,16 +1,16 @@ import sys, random, time -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils, getAccessPoint -from worlds.sm.variaRandomizer.rando.Restrictions import Restrictions -from worlds.sm.variaRandomizer.rando.RandoServices import RandoServices -from worlds.sm.variaRandomizer.rando.GraphBuilder import GraphBuilder -from worlds.sm.variaRandomizer.rando.RandoSetup import RandoSetup -from worlds.sm.variaRandomizer.rando.Items import ItemManager -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocation -from worlds.sm.variaRandomizer.utils.vcr import VCR -from worlds.sm.variaRandomizer.utils.doorsmanager import DoorsManager +from ..utils import log +from ..logic.logic import Logic +from ..graph.graph_utils import GraphUtils, getAccessPoint +from ..rando.Restrictions import Restrictions +from ..rando.RandoServices import RandoServices +from ..rando.GraphBuilder import GraphBuilder +from ..rando.RandoSetup import RandoSetup +from ..rando.Items import ItemManager +from ..rando.ItemLocContainer import ItemLocation +from ..utils.vcr import VCR +from ..utils.doorsmanager import DoorsManager # entry point for rando execution ("randomize" method) class RandoExec(object): diff --git a/worlds/sm/variaRandomizer/rando/RandoServices.py b/worlds/sm/variaRandomizer/rando/RandoServices.py index 6ea86c9e..60f9df74 100644 --- a/worlds/sm/variaRandomizer/rando/RandoServices.py +++ b/worlds/sm/variaRandomizer/rando/RandoServices.py @@ -1,10 +1,10 @@ import copy, random, sys, logging, os from enum import Enum, unique -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.utils.parameters import infinity -from worlds.sm.variaRandomizer.rando.ItemLocContainer import getLocListStr, getItemListStr, getItemLocStr, ItemLocation -from worlds.sm.variaRandomizer.logic.helpers import Bosses +from ..utils import log +from ..utils.parameters import infinity +from ..rando.ItemLocContainer import getLocListStr, getItemListStr, getItemLocStr, ItemLocation +from ..logic.helpers import Bosses # used to specify whether we want to come back from locations @unique diff --git a/worlds/sm/variaRandomizer/rando/RandoSettings.py b/worlds/sm/variaRandomizer/rando/RandoSettings.py index 030b14ff..6895b597 100644 --- a/worlds/sm/variaRandomizer/rando/RandoSettings.py +++ b/worlds/sm/variaRandomizer/rando/RandoSettings.py @@ -1,9 +1,9 @@ import sys, random from collections import defaultdict -from worlds.sm.variaRandomizer.rando.Items import ItemManager -from worlds.sm.variaRandomizer.utils.utils import getRangeDict, chooseFromRange -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocation +from ..rando.Items import ItemManager +from ..utils.utils import getRangeDict, chooseFromRange +from ..rando.ItemLocContainer import ItemLocation # Holder for settings and a few utility functions related to them # (especially for plando/rando). diff --git a/worlds/sm/variaRandomizer/rando/RandoSetup.py b/worlds/sm/variaRandomizer/rando/RandoSetup.py index c82802f8..637a5fed 100644 --- a/worlds/sm/variaRandomizer/rando/RandoSetup.py +++ b/worlds/sm/variaRandomizer/rando/RandoSetup.py @@ -1,15 +1,15 @@ import copy, random -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.utils.utils import randGaussBounds -from worlds.sm.variaRandomizer.logic.smbool import SMBool, smboolFalse -from worlds.sm.variaRandomizer.logic.smboolmanager import SMBoolManager -from worlds.sm.variaRandomizer.logic.helpers import Bosses -from worlds.sm.variaRandomizer.graph.graph_utils import getAccessPoint, GraphUtils -from worlds.sm.variaRandomizer.rando.Filler import FrontFiller -from worlds.sm.variaRandomizer.rando.ItemLocContainer import ItemLocContainer, getLocListStr, ItemLocation, getItemListStr -from worlds.sm.variaRandomizer.rando.Restrictions import Restrictions -from worlds.sm.variaRandomizer.utils.parameters import infinity +from ..utils import log +from ..utils.utils import randGaussBounds +from ..logic.smbool import SMBool, smboolFalse +from ..logic.smboolmanager import SMBoolManager +from ..logic.helpers import Bosses +from ..graph.graph_utils import getAccessPoint, GraphUtils +from ..rando.Filler import FrontFiller +from ..rando.ItemLocContainer import ItemLocContainer, getLocListStr, ItemLocation, getItemListStr +from ..rando.Restrictions import Restrictions +from ..utils.parameters import infinity # checks init conditions for the randomizer: processes super fun settings, graph, start location, special restrictions # the entry point is createItemLocContainer diff --git a/worlds/sm/variaRandomizer/rando/Restrictions.py b/worlds/sm/variaRandomizer/rando/Restrictions.py index 953eb2ef..68801231 100644 --- a/worlds/sm/variaRandomizer/rando/Restrictions.py +++ b/worlds/sm/variaRandomizer/rando/Restrictions.py @@ -1,7 +1,7 @@ import copy, random -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.variaRandomizer.graph.graph_utils import getAccessPoint -from worlds.sm.variaRandomizer.rando.ItemLocContainer import getLocListStr +from ..utils import log +from ..graph.graph_utils import getAccessPoint +from ..rando.ItemLocContainer import getLocListStr # Holds settings related to item placement restrictions. # canPlaceAtLocation is the main entry point here diff --git a/worlds/sm/variaRandomizer/randomizer.py b/worlds/sm/variaRandomizer/randomizer.py index 6a2c33ca..332c333c 100644 --- a/worlds/sm/variaRandomizer/randomizer.py +++ b/worlds/sm/variaRandomizer/randomizer.py @@ -3,19 +3,19 @@ from Utils import output_path import argparse, os.path, json, sys, shutil, random, copy, requests -from worlds.sm.variaRandomizer.rando.RandoSettings import RandoSettings, GraphSettings -from worlds.sm.variaRandomizer.rando.RandoExec import RandoExec -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils, getAccessPoint -from worlds.sm.variaRandomizer.utils.parameters import Controller, easy, medium, hard, harder, hardcore, mania, infinity, text2diff, appDir -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches -from worlds.sm.variaRandomizer.rom.rompatcher import RomPatcher -from worlds.sm.variaRandomizer.utils.utils import PresetLoader, loadRandoPreset, getDefaultMultiValues, getPresetDir -from worlds.sm.variaRandomizer.utils.version import displayedVersion -from worlds.sm.variaRandomizer.utils.doorsmanager import DoorsManager -from worlds.sm.variaRandomizer.logic.logic import Logic +from .rando.RandoSettings import RandoSettings, GraphSettings +from .rando.RandoExec import RandoExec +from .graph.graph_utils import GraphUtils, getAccessPoint +from .utils.parameters import Controller, easy, medium, hard, harder, hardcore, mania, infinity, text2diff, appDir +from .rom.rom_patches import RomPatches +from .rom.rompatcher import RomPatcher +from .utils.utils import PresetLoader, loadRandoPreset, getDefaultMultiValues, getPresetDir +from .utils.version import displayedVersion +from .utils.doorsmanager import DoorsManager +from .logic.logic import Logic -from worlds.sm.variaRandomizer.utils import log -from worlds.sm.Options import StartLocation +from .utils import log +from ..Options import StartLocation # we need to know the logic before doing anything else def getLogic(): @@ -327,8 +327,8 @@ class VariaRandomizer: preset = loadRandoPreset(world, self.player, args) # use the skill preset from the rando preset if preset is not None and preset != 'custom' and preset != 'varia_custom' and args.paramsFileName is None: - args.paramsFileName = os.path.join(appDir, getPresetDir(preset), preset+".json") - + args.paramsFileName = "/".join((appDir, getPresetDir(preset), preset+".json")) + # if diff preset given, load it if args.paramsFileName is not None: PresetLoader.factory(args.paramsFileName).load(self.player) @@ -353,7 +353,7 @@ class VariaRandomizer: raise Exception("Got error {} {} {} from trying to fetch varia custom preset named {}".format(response.status_code, response.reason, response.text, preset_name)) else: preset = 'default' - PresetLoader.factory(os.path.join(appDir, getPresetDir('casual'), 'casual.json')).load(self.player) + PresetLoader.factory("/".join((appDir, getPresetDir('casual'), 'casual.json'))).load(self.player) diff --git a/worlds/sm/variaRandomizer/rom/ips.py b/worlds/sm/variaRandomizer/rom/ips.py index 34a41e2e..23c52813 100644 --- a/worlds/sm/variaRandomizer/rom/ips.py +++ b/worlds/sm/variaRandomizer/rom/ips.py @@ -1,6 +1,6 @@ import itertools -from worlds.sm.variaRandomizer.utils.utils import range_union +from ..utils.utils import range_union, openFile # adapted from ips-util for python 3.2 (https://pypi.org/project/ips-util/) class IPS_Patch(object): @@ -25,7 +25,7 @@ class IPS_Patch(object): @staticmethod def load(filename): loaded_patch = IPS_Patch() - with open(filename, 'rb') as file: + with openFile(filename, 'rb') as file: header = file.read(5) if header != b'PATCH': raise Exception('Not a valid IPS patch file!') diff --git a/worlds/sm/variaRandomizer/rom/rom.py b/worlds/sm/variaRandomizer/rom/rom.py index 7b1cf06f..d173f7ab 100644 --- a/worlds/sm/variaRandomizer/rom/rom.py +++ b/worlds/sm/variaRandomizer/rom/rom.py @@ -1,6 +1,6 @@ import base64 -from worlds.sm.variaRandomizer.rom.ips import IPS_Patch +from ..rom.ips import IPS_Patch def pc_to_snes(pcaddress): snesaddress=(((pcaddress<<1)&0x7F0000)|(pcaddress&0x7FFF)|0x8000)|0x800000 diff --git a/worlds/sm/variaRandomizer/rom/rom_patches.py b/worlds/sm/variaRandomizer/rom/rom_patches.py index 26e8a84e..ff5e2aa8 100644 --- a/worlds/sm/variaRandomizer/rom/rom_patches.py +++ b/worlds/sm/variaRandomizer/rom/rom_patches.py @@ -1,4 +1,4 @@ -from worlds.sm.variaRandomizer.logic.smbool import SMBool +from ..logic.smbool import SMBool # layout patches added by randomizers class RomPatches: diff --git a/worlds/sm/variaRandomizer/rom/rompatcher.py b/worlds/sm/variaRandomizer/rom/rompatcher.py index 85cd3bf3..0e052f20 100644 --- a/worlds/sm/variaRandomizer/rom/rompatcher.py +++ b/worlds/sm/variaRandomizer/rom/rompatcher.py @@ -1,13 +1,13 @@ import os, random, re -from worlds.sm.variaRandomizer.rando.Items import ItemManager -from worlds.sm.variaRandomizer.rom.ips import IPS_Patch -from worlds.sm.variaRandomizer.utils.doorsmanager import DoorsManager -from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils, getAccessPoint, locIdsByAreaAddresses -from worlds.sm.variaRandomizer.logic.logic import Logic -from worlds.sm.variaRandomizer.rom.rom import RealROM, snes_to_pc, pc_to_snes -from worlds.sm.variaRandomizer.patches.patchaccess import PatchAccess -from worlds.sm.variaRandomizer.utils.parameters import appDir -from worlds.sm.variaRandomizer.utils import log +from ..rando.Items import ItemManager +from ..rom.ips import IPS_Patch +from ..utils.doorsmanager import DoorsManager +from ..graph.graph_utils import GraphUtils, getAccessPoint, locIdsByAreaAddresses +from ..logic.logic import Logic +from ..rom.rom import RealROM, snes_to_pc, pc_to_snes +from ..patches.patchaccess import PatchAccess +from ..utils.parameters import appDir +from ..utils import log def getWord(w): return (w & 0x00FF, (w & 0xFF00) >> 8) diff --git a/worlds/sm/variaRandomizer/utils/doorsmanager.py b/worlds/sm/variaRandomizer/utils/doorsmanager.py index c8feacdb..0b2a4149 100644 --- a/worlds/sm/variaRandomizer/utils/doorsmanager.py +++ b/worlds/sm/variaRandomizer/utils/doorsmanager.py @@ -1,10 +1,10 @@ import random import copy -from worlds.sm.variaRandomizer.logic.smbool import SMBool -from worlds.sm.variaRandomizer.rom.rom_patches import RomPatches +from ..logic.smbool import SMBool +from ..rom.rom_patches import RomPatches import logging -from worlds.sm.variaRandomizer.utils import log +from ..utils import log LOG = log.get('DoorsManager') colorsList = ['red', 'green', 'yellow', 'wave', 'spazer', 'plasma', 'ice'] diff --git a/worlds/sm/variaRandomizer/utils/parameters.py b/worlds/sm/variaRandomizer/utils/parameters.py index 6bae03b4..2d9313b5 100644 --- a/worlds/sm/variaRandomizer/utils/parameters.py +++ b/worlds/sm/variaRandomizer/utils/parameters.py @@ -1,4 +1,4 @@ -from worlds.sm.variaRandomizer.logic.smbool import SMBool +from ..logic.smbool import SMBool import os import sys from pathlib import Path @@ -61,7 +61,7 @@ def diff4solver(difficulty): return "mania" # allow multiple local repo -appDir = Path(__file__).parents[4] +appDir = str(Path(__file__).parents[4]) def isKnows(knows): return knows[0:len('__')] != '__' and knows[0] == knows[0].upper() diff --git a/worlds/sm/variaRandomizer/utils/utils.py b/worlds/sm/variaRandomizer/utils/utils.py index ba43d710..46c14a16 100644 --- a/worlds/sm/variaRandomizer/utils/utils.py +++ b/worlds/sm/variaRandomizer/utils/utils.py @@ -1,8 +1,59 @@ +import io import os, json, re, random +import pathlib +import sys +from typing import Any +import zipfile -from worlds.sm.variaRandomizer.utils.parameters import Knows, Settings, Controller, isKnows, isSettings, isButton -from worlds.sm.variaRandomizer.utils.parameters import easy, medium, hard, harder, hardcore, mania, text2diff -from worlds.sm.variaRandomizer.logic.smbool import SMBool +from ..utils.parameters import Knows, Settings, Controller, isKnows, isSettings, isButton +from ..utils.parameters import easy, medium, hard, harder, hardcore, mania, text2diff +from ..logic.smbool import SMBool + + +# support for AP world +isAPWorld = ".apworld" in sys.modules[__name__].__file__ + +def getZipFile(): + filename = sys.modules[__name__].__file__ + apworldExt = ".apworld" + zipPath = pathlib.Path(filename[:filename.index(apworldExt) + len(apworldExt)]) + return (zipfile.ZipFile(zipPath), zipPath.stem) + +def openFile(resource: str, mode: str = "r", encoding: None = None): + if isAPWorld: + (zipFile, stem) = getZipFile() + with zipFile as zf: + zipFilePath = resource[resource.index(stem + "/"):] + if mode == 'rb': + return zf.open(zipFilePath, 'r') + else: + return io.TextIOWrapper(zf.open(zipFilePath, mode), encoding) + else: + return open(resource, mode) + +def listDir(resource: str): + if isAPWorld: + (zipFile, stem) = getZipFile() + with zipFile as zf: + zipFilePath = resource[resource.index(stem + "/"):] + path = zipfile.Path(zf, zipFilePath + "/") + files = [f.at[len(zipFilePath)+1:] for f in path.iterdir()] + return files + else: + return os.listdir(resource) + +def exists(resource: str): + if isAPWorld: + (zipFile, stem) = getZipFile() + with zipFile as zf: + if (stem in resource): + zipFilePath = resource[resource.index(stem + "/"):] + path = zipfile.Path(zf, zipFilePath) + return path.exists() + else: + return False + else: + return os.path.exists(resource) def isStdPreset(preset): return preset in ['newbie', 'casual', 'regular', 'veteran', 'expert', 'master', 'samus', 'solution', 'Season_Races', 'SMRAT2021'] @@ -253,7 +304,7 @@ class PresetLoader(object): class PresetLoaderJson(PresetLoader): # when called from the test suite def __init__(self, jsonFileName): - with open(jsonFileName) as jsonFile: + with openFile(jsonFileName) as jsonFile: self.params = json.load(jsonFile) super(PresetLoaderJson, self).__init__() @@ -264,7 +315,7 @@ class PresetLoaderDict(PresetLoader): super(PresetLoaderDict, self).__init__() def getDefaultMultiValues(): - from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils + from ..graph.graph_utils import GraphUtils defaultMultiValues = { 'startLocation': GraphUtils.getStartAccessPointNames(), 'majorsSplit': ['Full', 'FullWithHUD', 'Major', 'Chozo', 'Scavenger'], diff --git a/worlds/smz3/Client.py b/worlds/smz3/Client.py index c942c66c..687a43b0 100644 --- a/worlds/smz3/Client.py +++ b/worlds/smz3/Client.py @@ -86,8 +86,8 @@ class SMZ3SNIClient(SNIClient): recv_index += 1 snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x680, bytes([recv_index & 0xFF, (recv_index >> 8) & 0xFF])) - from worlds.smz3.TotalSMZ3.Location import locations_start_id - from worlds.smz3 import convertLocSMZ3IDToAPID + from .TotalSMZ3.Location import locations_start_id + from . import convertLocSMZ3IDToAPID location_id = locations_start_id + convertLocSMZ3IDToAPID(item_index) ctx.locations_checked.add(location_id) @@ -101,7 +101,7 @@ class SMZ3SNIClient(SNIClient): item_out_ptr = data[2] | (data[3] << 8) - from worlds.smz3.TotalSMZ3.Item import items_start_id + from .TotalSMZ3.Item import items_start_id if item_out_ptr < len(ctx.items_received): item = ctx.items_received[item_out_ptr] item_id = item.item - items_start_id diff --git a/worlds/smz3/TotalSMZ3/Item.py b/worlds/smz3/TotalSMZ3/Item.py index 2aced8bf..b4fc9d59 100644 --- a/worlds/smz3/TotalSMZ3/Item.py +++ b/worlds/smz3/TotalSMZ3/Item.py @@ -3,7 +3,7 @@ import re import copy from typing import List -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic +from .Config import Config, SMLogic class ItemType(Enum): Nothing = 0 @@ -787,15 +787,15 @@ class Progression: return self.Flute and self.CanLiftHeavy() def CanAccessMaridiaPortal(self, world): - import worlds.smz3.TotalSMZ3.Region + from .Region import RewardType if (world.Config.SMLogic == SMLogic.Normal): return self.MoonPearl and self.Flippers and \ self.Gravity and self.Morph and \ - (world.CanAcquire(self, worlds.smz3.TotalSMZ3.Region.RewardType.Agahnim) or self.Hammer and self.CanLiftLight() or self.CanLiftHeavy()) + (world.CanAcquire(self, RewardType.Agahnim) or self.Hammer and self.CanLiftLight() or self.CanLiftHeavy()) else: return self.MoonPearl and self.Flippers and \ (self.CanSpringBallJump() or self.HiJump or self.Gravity) and self.Morph and \ - (world.CanAcquire(self, worlds.smz3.TotalSMZ3.Region.RewardType.Agahnim) or self.Hammer and self.CanLiftLight() or self.CanLiftHeavy()) + (world.CanAcquire(self, RewardType.Agahnim) or self.Hammer and self.CanLiftLight() or self.CanLiftHeavy()) # Start of AP integration items_start_id = 84000 diff --git a/worlds/smz3/TotalSMZ3/Location.py b/worlds/smz3/TotalSMZ3/Location.py index 377d1a33..cb18ddc7 100644 --- a/worlds/smz3/TotalSMZ3/Location.py +++ b/worlds/smz3/TotalSMZ3/Location.py @@ -1,8 +1,8 @@ from enum import Enum from typing import List, Callable -from worlds.smz3.TotalSMZ3.Item import Progression -import worlds.smz3.TotalSMZ3.Region as Region -import worlds.smz3.TotalSMZ3.World as World +from .Item import Progression +from . import Region +from . import World class LocationType(Enum): Regular = 0 diff --git a/worlds/smz3/TotalSMZ3/Patch.py b/worlds/smz3/TotalSMZ3/Patch.py index 2b8d278d..7924386a 100644 --- a/worlds/smz3/TotalSMZ3/Patch.py +++ b/worlds/smz3/TotalSMZ3/Patch.py @@ -4,30 +4,30 @@ from typing import Any, Callable, List, Sequence import random import typing from BaseClasses import Location -from worlds.smz3.TotalSMZ3.Item import Item, ItemType -from worlds.smz3.TotalSMZ3.Location import LocationType -from worlds.smz3.TotalSMZ3.Region import IReward, RewardType, SMRegion, Z3Region -from worlds.smz3.TotalSMZ3.Regions.Zelda.EasternPalace import EasternPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.DesertPalace import DesertPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.TowerOfHera import TowerOfHera -from worlds.smz3.TotalSMZ3.Regions.Zelda.PalaceOfDarkness import PalaceOfDarkness -from worlds.smz3.TotalSMZ3.Regions.Zelda.SwampPalace import SwampPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.SkullWoods import SkullWoods -from worlds.smz3.TotalSMZ3.Regions.Zelda.ThievesTown import ThievesTown -from worlds.smz3.TotalSMZ3.Regions.Zelda.IcePalace import IcePalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.MiseryMire import MiseryMire -from worlds.smz3.TotalSMZ3.Regions.Zelda.TurtleRock import TurtleRock -from worlds.smz3.TotalSMZ3.Regions.Zelda.GanonsTower import GanonsTower -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Kraid import Kraid -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.WreckedShip import WreckedShip -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Maridia.Inner import Inner -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairLower.East import East -from worlds.smz3.TotalSMZ3.Text.StringTable import StringTable +from .Item import Item, ItemType +from .Location import LocationType +from .Region import IReward, RewardType, SMRegion, Z3Region +from .Regions.Zelda.EasternPalace import EasternPalace +from .Regions.Zelda.DesertPalace import DesertPalace +from .Regions.Zelda.TowerOfHera import TowerOfHera +from .Regions.Zelda.PalaceOfDarkness import PalaceOfDarkness +from .Regions.Zelda.SwampPalace import SwampPalace +from .Regions.Zelda.SkullWoods import SkullWoods +from .Regions.Zelda.ThievesTown import ThievesTown +from .Regions.Zelda.IcePalace import IcePalace +from .Regions.Zelda.MiseryMire import MiseryMire +from .Regions.Zelda.TurtleRock import TurtleRock +from .Regions.Zelda.GanonsTower import GanonsTower +from .Regions.SuperMetroid.Brinstar.Kraid import Kraid +from .Regions.SuperMetroid.WreckedShip import WreckedShip +from .Regions.SuperMetroid.Maridia.Inner import Inner +from .Regions.SuperMetroid.NorfairLower.East import East +from .Text.StringTable import StringTable -from worlds.smz3.TotalSMZ3.World import World -from worlds.smz3.TotalSMZ3.Config import Config, OpenTourian, Goal -from worlds.smz3.TotalSMZ3.Text.Texts import Texts -from worlds.smz3.TotalSMZ3.Text.Dialog import Dialog +from .World import World +from .Config import Config, OpenTourian, Goal +from .Text.Texts import Texts +from .Text.Dialog import Dialog class KeycardPlaque: Level1 = 0xe0 @@ -147,7 +147,7 @@ class Patch: return {patch[0]:patch[1] for patch in self.patches} def WriteMedallions(self): - from worlds.smz3.TotalSMZ3.WorldState import Medallion + from .WorldState import Medallion turtleRock = next(region for region in self.myWorld.Regions if isinstance(region, TurtleRock)) miseryMire = next(region for region in self.myWorld.Regions if isinstance(region, MiseryMire)) diff --git a/worlds/smz3/TotalSMZ3/Region.py b/worlds/smz3/TotalSMZ3/Region.py index 00e209ce..2274c556 100644 --- a/worlds/smz3/TotalSMZ3/Region.py +++ b/worlds/smz3/TotalSMZ3/Region.py @@ -1,7 +1,6 @@ from enum import Enum from typing import Dict, List -from worlds.smz3.TotalSMZ3.Config import * -from worlds.smz3.TotalSMZ3.Item import Item, ItemType +from .Config import * class RewardType(Enum): Null = 0 @@ -28,7 +27,7 @@ class IMedallionAccess: Medallion = None class Region: - import worlds.smz3.TotalSMZ3.Location as Location + from . import Location Name: str Area: str diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Blue.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Blue.py index 0b3d1f8b..eac3aaf6 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Blue.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Blue.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType class Blue(SMRegion): Name = "Brinstar Blue" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Green.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Green.py index 380431df..8aa555ce 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Green.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Green.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Green(SMRegion): Name = "Brinstar Green" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Kraid.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Kraid.py index 2b99081d..82ba144b 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Kraid.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Kraid.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion, IReward, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion, IReward, RewardType +from ....Config import Config +from ....Location import Location, LocationType +from ....Item import Progression class Kraid(SMRegion, IReward): Name = "Brinstar Kraid" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Pink.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Pink.py index bb1036fb..4a727ea4 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Pink.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Pink.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Pink(SMRegion): Name = "Brinstar Pink" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Red.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Red.py index cca64e4c..1a0dd1fb 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Red.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Brinstar/Red.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Red(SMRegion): Name = "Brinstar Red" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/Central.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/Central.py index 14c8b08f..d673373b 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/Central.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/Central.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType class Central(SMRegion): Name = "Crateria Central" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/East.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/East.py index 72d10a44..44834f21 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/East.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/East.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class East(SMRegion): Name = "Crateria East" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/West.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/West.py index 5554b088..9a4d6019 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/West.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Crateria/West.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class West(SMRegion): Name = "Crateria West" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Inner.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Inner.py index 7de0798b..c129b876 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Inner.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Inner.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion, IReward, RewardType -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion, IReward, RewardType +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Inner(SMRegion, IReward): Name = "Maridia Inner" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Outer.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Outer.py index 64907452..0766566a 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Outer.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/Maridia/Outer.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Outer(SMRegion): Name = "Maridia Outer" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/East.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/East.py index f1a325a1..6e070f7d 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/East.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/East.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion, IReward, RewardType -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion, IReward, RewardType +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class East(SMRegion, IReward): Name = "Norfair Lower East" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/West.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/West.py index 4e44d28c..ab005988 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/West.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairLower/West.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class West(SMRegion): Name = "Norfair Lower West" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/Crocomire.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/Crocomire.py index b38bbe70..792bd42f 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/Crocomire.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/Crocomire.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class Crocomire(SMRegion): Name = "Norfair Upper Crocomire" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/East.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/East.py index a2dc2b1b..1c27e7d3 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/East.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/East.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class East(SMRegion): Name = "Norfair Upper East" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/West.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/West.py index 5dcafdf4..45add5b3 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/West.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/NorfairUpper/West.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import SMRegion +from ....Config import Config, SMLogic +from ....Location import Location, LocationType +from ....Item import Progression class West(SMRegion): Name = "Norfair Upper West" diff --git a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/WreckedShip.py b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/WreckedShip.py index e83c6f53..d4624f53 100644 --- a/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/WreckedShip.py +++ b/worlds/smz3/TotalSMZ3/Regions/SuperMetroid/WreckedShip.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import SMRegion, IReward, RewardType -from worlds.smz3.TotalSMZ3.Config import Config, SMLogic -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ...Region import SMRegion, IReward, RewardType +from ...Config import Config, SMLogic +from ...Location import Location, LocationType +from ...Item import Progression class WreckedShip(SMRegion, IReward): Name = "Wrecked Ship" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/CastleTower.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/CastleTower.py index 8a1eba58..bca50c00 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/CastleTower.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/CastleTower.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class CastleTower(Z3Region, IReward): Name = "Castle Tower" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/East.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/East.py index be9eb1ba..b860d3c7 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/East.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/East.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from .....Region import Z3Region +from .....Config import Config +from .....Location import Location, LocationType +from .....Item import Progression class East(Z3Region): Name = "Dark World Death Mountain East" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/West.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/West.py index dfe3de55..0a0fa5de 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/West.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/DeathMountain/West.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from .....Region import Z3Region +from .....Config import Config +from .....Location import Location, LocationType class West(Z3Region): Name = "Dark World Death Mountain West" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/Mire.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/Mire.py index d7d7345a..01f6d170 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/Mire.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/Mire.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import Z3Region +from ....Config import Config +from ....Location import Location, LocationType +from ....Item import Progression class Mire(Z3Region): Name = "Dark World Mire" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthEast.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthEast.py index 7ca34cb0..2f23a381 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthEast.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthEast.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import Z3Region, RewardType +from ....Config import Config +from ....Location import Location, LocationType +from ....Item import Progression class NorthEast(Z3Region): Name = "Dark World North East" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthWest.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthWest.py index 28a318e8..73bea10e 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthWest.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/NorthWest.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import Z3Region, RewardType +from ....Config import Config +from ....Location import Location, LocationType +from ....Item import Progression class NorthWest(Z3Region): Name = "Dark World North West" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/South.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/South.py index 14f4515c..417c668a 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/South.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DarkWorld/South.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from ....Region import Z3Region, RewardType +from ....Config import Config +from ....Location import Location, LocationType +from ....Item import Progression class South(Z3Region): Name = "Dark World South" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/DesertPalace.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/DesertPalace.py index 117f2166..0782d65a 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/DesertPalace.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/DesertPalace.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import ItemType, Progression +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import ItemType, Progression class DesertPalace(Z3Region, IReward): Name = "Desert Palace" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/EasternPalace.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/EasternPalace.py index 77ded239..74dbdb64 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/EasternPalace.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/EasternPalace.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class EasternPalace(Z3Region, IReward): Name = "Eastern Palace" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/GanonsTower.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/GanonsTower.py index c1a6d79f..fe810691 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/GanonsTower.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/GanonsTower.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config, GameMode, KeyShuffle -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Item, Progression, ItemType +from ...Region import Z3Region, RewardType +from ...Config import Config, GameMode, KeyShuffle +from ...Location import Location, LocationType +from ...Item import Item, Progression, ItemType class GanonsTower(Z3Region): Name = "Ganon's Tower" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/HyruleCastle.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/HyruleCastle.py index 20a68a3f..498c4124 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/HyruleCastle.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/HyruleCastle.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import ItemType +from ...Region import Z3Region +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import ItemType class HyruleCastle(Z3Region): Name = "Hyrule Castle" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/IcePalace.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/IcePalace.py index 9b16a08b..db29e0dd 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/IcePalace.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/IcePalace.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class IcePalace(Z3Region, IReward): Name = "Ice Palace" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/East.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/East.py index 10cd333a..5975b1db 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/East.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/East.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from .....Region import Z3Region +from .....Config import Config +from .....Location import Location, LocationType +from .....Item import Progression class East(Z3Region): Name = "Light World Death Mountain East" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/West.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/West.py index 47f20f5e..c3fadd52 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/West.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/DeathMountain/West.py @@ -1,7 +1,7 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression +from .....Region import Z3Region +from .....Config import Config +from .....Location import Location, LocationType +from .....Item import Progression class West(Z3Region): Name = "Light World Death Mountain West" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthEast.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthEast.py index c111b07d..6991bc9d 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthEast.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthEast.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from ....Region import Z3Region, RewardType +from ....Config import Config +from ....Location import Location, LocationType class NorthEast(Z3Region): Name = "Light World North East" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthWest.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthWest.py index 46f830dc..75ec33f7 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthWest.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/NorthWest.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from ....Region import Z3Region, RewardType +from ....Config import Config +from ....Location import Location, LocationType class NorthWest(Z3Region): Name = "Light World North West" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/South.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/South.py index 50f5cee7..70431b87 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/South.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/LightWorld/South.py @@ -1,6 +1,6 @@ -from worlds.smz3.TotalSMZ3.Region import Z3Region -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType +from ....Region import Z3Region +from ....Config import Config +from ....Location import Location, LocationType class South(Z3Region): Name = "Light World South" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/MiseryMire.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/MiseryMire.py index b1746184..c008fbb1 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/MiseryMire.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/MiseryMire.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward, IMedallionAccess -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward, IMedallionAccess +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class MiseryMire(Z3Region, IReward, IMedallionAccess): Name = "Misery Mire" @@ -35,7 +35,7 @@ class MiseryMire(Z3Region, IReward, IMedallionAccess): # // Need "CanKillManyEnemies" if implementing swordless def CanEnter(self, items: Progression): - from worlds.smz3.TotalSMZ3.WorldState import Medallion + from ...WorldState import Medallion return (items.Bombos if self.Medallion == Medallion.Bombos else ( items.Ether if self.Medallion == Medallion.Ether else items.Quake)) and items.Sword and \ items.MoonPearl and (items.Boots or items.Hookshot) and \ diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/PalaceOfDarkness.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/PalaceOfDarkness.py index 9184fd28..31e5c5fd 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/PalaceOfDarkness.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/PalaceOfDarkness.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class PalaceOfDarkness(Z3Region, IReward): Name = "Palace of Darkness" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/SkullWoods.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/SkullWoods.py index f991fce3..b84c03f5 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/SkullWoods.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/SkullWoods.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class SkullWoods(Z3Region, IReward): Name = "Skull Woods" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/SwampPalace.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/SwampPalace.py index 27b5a1db..35e88633 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/SwampPalace.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/SwampPalace.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class SwampPalace(Z3Region, IReward): Name = "Swamp Palace" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/ThievesTown.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/ThievesTown.py index ef68b953..003f1f17 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/ThievesTown.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/ThievesTown.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class ThievesTown(Z3Region, IReward): Name = "Thieves' Town" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/TowerOfHera.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/TowerOfHera.py index 45743ac3..521c6c7a 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/TowerOfHera.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/TowerOfHera.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class TowerOfHera(Z3Region, IReward): Name = "Tower of Hera" diff --git a/worlds/smz3/TotalSMZ3/Regions/Zelda/TurtleRock.py b/worlds/smz3/TotalSMZ3/Regions/Zelda/TurtleRock.py index 45546e9e..e797bdda 100644 --- a/worlds/smz3/TotalSMZ3/Regions/Zelda/TurtleRock.py +++ b/worlds/smz3/TotalSMZ3/Regions/Zelda/TurtleRock.py @@ -1,8 +1,8 @@ from typing import List -from worlds.smz3.TotalSMZ3.Region import Z3Region, RewardType, IReward, IMedallionAccess -from worlds.smz3.TotalSMZ3.Config import Config -from worlds.smz3.TotalSMZ3.Location import Location, LocationType -from worlds.smz3.TotalSMZ3.Item import Progression, ItemType +from ...Region import Z3Region, RewardType, IReward, IMedallionAccess +from ...Config import Config +from ...Location import Location, LocationType +from ...Item import Progression, ItemType class TurtleRock(Z3Region, IReward, IMedallionAccess): Name = "Turtle Rock" @@ -47,7 +47,7 @@ class TurtleRock(Z3Region, IReward, IMedallionAccess): return items.Firerod and items.Icerod def CanEnter(self, items: Progression): - from worlds.smz3.TotalSMZ3.WorldState import Medallion + from ...WorldState import Medallion return (items.Bombos if self.Medallion == Medallion.Bombos else ( items.Ether if self.Medallion == Medallion.Ether else items.Quake)) and items.Sword and \ items.MoonPearl and items.CanLiftHeavy() and items.Hammer and items.Somaria and \ diff --git a/worlds/smz3/TotalSMZ3/Text/Dialog.py b/worlds/smz3/TotalSMZ3/Text/Dialog.py index 92e034af..553eb016 100644 --- a/worlds/smz3/TotalSMZ3/Text/Dialog.py +++ b/worlds/smz3/TotalSMZ3/Text/Dialog.py @@ -158,7 +158,7 @@ class Dialog: value = Dialog.letters.get(c, None) return value if value else [ 0xFF ] - #region letter bytes lookup + #regions letter bytes lookup letters = { ' ' : [ 0x4F ], diff --git a/worlds/smz3/TotalSMZ3/Text/StringTable.py b/worlds/smz3/TotalSMZ3/Text/StringTable.py index 13f3f5ed..ed5f794f 100644 --- a/worlds/smz3/TotalSMZ3/Text/StringTable.py +++ b/worlds/smz3/TotalSMZ3/Text/StringTable.py @@ -1,15 +1,15 @@  from typing import Any, List import copy -from worlds.smz3.TotalSMZ3.Text.Dialog import Dialog -from worlds.smz3.TotalSMZ3.Text.Texts import text_folder +from ..Text.Dialog import Dialog +from ..Text.Texts import openFile from Utils import unsafe_parse_yaml class StringTable: @staticmethod def ParseEntries(resource: str): - with open(resource, 'rb') as f: + with openFile(resource, 'rb') as f: yaml = str(f.read(), "utf-8") content = unsafe_parse_yaml(yaml) @@ -23,7 +23,7 @@ class StringTable: else: raise Exception(f"Did not expect an object of type {type(value)}") return result - template = ParseEntries.__func__(text_folder + "/Scripts/StringTable.yaml") + template = ParseEntries.__func__("smz3/TotalSMZ3/Text/Scripts/StringTable.yaml") def __init__(self): self.entries = copy.deepcopy(StringTable.template) diff --git a/worlds/smz3/TotalSMZ3/Text/Texts.py b/worlds/smz3/TotalSMZ3/Text/Texts.py index dfaeee06..377baf01 100644 --- a/worlds/smz3/TotalSMZ3/Text/Texts.py +++ b/worlds/smz3/TotalSMZ3/Text/Texts.py @@ -1,30 +1,49 @@ -from typing import Any, List -from worlds.smz3.TotalSMZ3.Region import Region -from worlds.smz3.TotalSMZ3.Regions.Zelda.GanonsTower import GanonsTower -from worlds.smz3.TotalSMZ3.Item import Item, ItemType +import io +from pathlib import Path +import sys +from typing import Any, List +import zipfile +from ..Region import Region +from ..Regions.Zelda.GanonsTower import GanonsTower +from ..Item import Item, ItemType from Utils import unsafe_parse_yaml import random import os -text_folder = os.path.dirname(__file__) +text_folder = Path(__file__).parents[3] + +def openFile(resource: str, mode: str = "r", encoding: None = None): + filename = sys.modules[__name__].__file__ + apworldExt = ".apworld" + game = "smz3/" + if apworldExt in filename: + zip_path = Path(filename[:filename.index(apworldExt) + len(apworldExt)]) + with zipfile.ZipFile(zip_path) as zf: + zipFilePath = resource[resource.index(game):] + if mode == 'rb': + return zf.open(zipFilePath, 'r') + else: + return io.TextIOWrapper(zf.open(zipFilePath, 'r'), encoding) + else: + return open(os.path.join(text_folder, resource), mode) class Texts: @staticmethod def ParseYamlScripts(resource: str): - with open(resource, 'rb') as f: + with openFile(resource, 'rb') as f: yaml = str(f.read(), "utf-8") return unsafe_parse_yaml(yaml) @staticmethod def ParseTextScript(resource: str): - with open(resource, 'r', encoding="utf-8-sig") as file: + with openFile(resource, 'r') as file: return [text.rstrip('\n') for text in file.read().replace("\r", "").split("---\n") if text] - scripts: Any = ParseYamlScripts.__func__(text_folder + "/Scripts/General.yaml") - blind: List[str] = ParseTextScript.__func__(text_folder + "/Scripts/Blind.txt") - ganon: List[str] = ParseTextScript.__func__(text_folder + "/Scripts/Ganon.txt") - tavernMan: List[str] = ParseTextScript.__func__(text_folder + "/Scripts/TavernMan.txt") - triforceRoom: List[str] = ParseTextScript.__func__(text_folder + "/Scripts/TriforceRoom.txt") + scripts: Any = ParseYamlScripts.__func__("smz3/TotalSMZ3/Text/Scripts/General.yaml") + blind: List[str] = ParseTextScript.__func__("smz3/TotalSMZ3/Text/Scripts/Blind.txt") + ganon: List[str] = ParseTextScript.__func__("smz3/TotalSMZ3/Text/Scripts/Ganon.txt") + tavernMan: List[str] = ParseTextScript.__func__("smz3/TotalSMZ3/Text/Scripts/TavernMan.txt") + triforceRoom: List[str] = ParseTextScript.__func__("smz3/TotalSMZ3/Text/Scripts/TriforceRoom.txt") @staticmethod def SahasrahlaReveal(dungeon: Region): diff --git a/worlds/smz3/TotalSMZ3/World.py b/worlds/smz3/TotalSMZ3/World.py index 722d5858..60249760 100644 --- a/worlds/smz3/TotalSMZ3/World.py +++ b/worlds/smz3/TotalSMZ3/World.py @@ -1,51 +1,51 @@ from typing import Dict, List import random -import worlds.smz3.TotalSMZ3.Region as Region -import worlds.smz3.TotalSMZ3.Config as Config -import worlds.smz3.TotalSMZ3.Item as Item -import worlds.smz3.TotalSMZ3.Location as Location +from . import Region +from . import Config +from . import Item +from . import Location -from worlds.smz3.TotalSMZ3.Regions.Zelda.CastleTower import CastleTower -from worlds.smz3.TotalSMZ3.Regions.Zelda.EasternPalace import EasternPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.DesertPalace import DesertPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.TowerOfHera import TowerOfHera -from worlds.smz3.TotalSMZ3.Regions.Zelda.PalaceOfDarkness import PalaceOfDarkness -from worlds.smz3.TotalSMZ3.Regions.Zelda.SwampPalace import SwampPalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.SkullWoods import SkullWoods -from worlds.smz3.TotalSMZ3.Regions.Zelda.ThievesTown import ThievesTown -from worlds.smz3.TotalSMZ3.Regions.Zelda.IcePalace import IcePalace -from worlds.smz3.TotalSMZ3.Regions.Zelda.MiseryMire import MiseryMire -from worlds.smz3.TotalSMZ3.Regions.Zelda.TurtleRock import TurtleRock -from worlds.smz3.TotalSMZ3.Regions.Zelda.GanonsTower import GanonsTower -from worlds.smz3.TotalSMZ3.Regions.Zelda.LightWorld.DeathMountain.West import West as LightWorldDeathMountainWest -from worlds.smz3.TotalSMZ3.Regions.Zelda.LightWorld.DeathMountain.East import East as LightWorldDeathMountainEast -from worlds.smz3.TotalSMZ3.Regions.Zelda.LightWorld.NorthWest import NorthWest as LightWorldNorthWest -from worlds.smz3.TotalSMZ3.Regions.Zelda.LightWorld.NorthEast import NorthEast as LightWorldNorthEast -from worlds.smz3.TotalSMZ3.Regions.Zelda.LightWorld.South import South as LightWorldSouth -from worlds.smz3.TotalSMZ3.Regions.Zelda.HyruleCastle import HyruleCastle -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.DeathMountain.West import West as DarkWorldDeathMountainWest -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.DeathMountain.East import East as DarkWorldDeathMountainEast -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.NorthWest import NorthWest as DarkWorldNorthWest -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.NorthEast import NorthEast as DarkWorldNorthEast -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.South import South as DarkWorldSouth -from worlds.smz3.TotalSMZ3.Regions.Zelda.DarkWorld.Mire import Mire as DarkWorldMire -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Crateria.Central import Central -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Crateria.West import West as CrateriaWest -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Crateria.East import East as CrateriaEast -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Blue import Blue -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Green import Green -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Kraid import Kraid -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Pink import Pink -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Brinstar.Red import Red -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Maridia.Outer import Outer -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.Maridia.Inner import Inner -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairUpper.West import West as NorfairUpperWest -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairUpper.East import East as NorfairUpperEast -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairUpper.Crocomire import Crocomire -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairLower.West import West as NorfairLowerWest -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.NorfairLower.East import East as NorfairLowerEast -from worlds.smz3.TotalSMZ3.Regions.SuperMetroid.WreckedShip import WreckedShip +from .Regions.Zelda.CastleTower import CastleTower +from .Regions.Zelda.EasternPalace import EasternPalace +from .Regions.Zelda.DesertPalace import DesertPalace +from .Regions.Zelda.TowerOfHera import TowerOfHera +from .Regions.Zelda.PalaceOfDarkness import PalaceOfDarkness +from .Regions.Zelda.SwampPalace import SwampPalace +from .Regions.Zelda.SkullWoods import SkullWoods +from .Regions.Zelda.ThievesTown import ThievesTown +from .Regions.Zelda.IcePalace import IcePalace +from .Regions.Zelda.MiseryMire import MiseryMire +from .Regions.Zelda.TurtleRock import TurtleRock +from .Regions.Zelda.GanonsTower import GanonsTower +from .Regions.Zelda.LightWorld.DeathMountain.West import West as LightWorldDeathMountainWest +from .Regions.Zelda.LightWorld.DeathMountain.East import East as LightWorldDeathMountainEast +from .Regions.Zelda.LightWorld.NorthWest import NorthWest as LightWorldNorthWest +from .Regions.Zelda.LightWorld.NorthEast import NorthEast as LightWorldNorthEast +from .Regions.Zelda.LightWorld.South import South as LightWorldSouth +from .Regions.Zelda.HyruleCastle import HyruleCastle +from .Regions.Zelda.DarkWorld.DeathMountain.West import West as DarkWorldDeathMountainWest +from .Regions.Zelda.DarkWorld.DeathMountain.East import East as DarkWorldDeathMountainEast +from .Regions.Zelda.DarkWorld.NorthWest import NorthWest as DarkWorldNorthWest +from .Regions.Zelda.DarkWorld.NorthEast import NorthEast as DarkWorldNorthEast +from .Regions.Zelda.DarkWorld.South import South as DarkWorldSouth +from .Regions.Zelda.DarkWorld.Mire import Mire as DarkWorldMire +from .Regions.SuperMetroid.Crateria.Central import Central +from .Regions.SuperMetroid.Crateria.West import West as CrateriaWest +from .Regions.SuperMetroid.Crateria.East import East as CrateriaEast +from .Regions.SuperMetroid.Brinstar.Blue import Blue +from .Regions.SuperMetroid.Brinstar.Green import Green +from .Regions.SuperMetroid.Brinstar.Kraid import Kraid +from .Regions.SuperMetroid.Brinstar.Pink import Pink +from .Regions.SuperMetroid.Brinstar.Red import Red +from .Regions.SuperMetroid.Maridia.Outer import Outer +from .Regions.SuperMetroid.Maridia.Inner import Inner +from .Regions.SuperMetroid.NorfairUpper.West import West as NorfairUpperWest +from .Regions.SuperMetroid.NorfairUpper.East import East as NorfairUpperEast +from .Regions.SuperMetroid.NorfairUpper.Crocomire import Crocomire +from .Regions.SuperMetroid.NorfairLower.West import West as NorfairLowerWest +from .Regions.SuperMetroid.NorfairLower.East import East as NorfairLowerEast +from .Regions.SuperMetroid.WreckedShip import WreckedShip class World: Locations: List[Location.Location] diff --git a/worlds/smz3/TotalSMZ3/WorldState.py b/worlds/smz3/TotalSMZ3/WorldState.py index c857b539..bbffffa1 100644 --- a/worlds/smz3/TotalSMZ3/WorldState.py +++ b/worlds/smz3/TotalSMZ3/WorldState.py @@ -2,9 +2,9 @@ from enum import Enum from typing import List from copy import copy -from worlds.smz3.TotalSMZ3.Patch import DropPrize -from worlds.smz3.TotalSMZ3.Region import RewardType -from worlds.smz3.TotalSMZ3.Config import OpenTower, GanonVulnerable, OpenTourian +from .Patch import DropPrize +from .Region import RewardType +from .Config import OpenTower, GanonVulnerable, OpenTourian class Medallion(Enum): Bombos = 0 diff --git a/worlds/smz3/__init__.py b/worlds/smz3/__init__.py index 5e73f5db..969ad9df 100644 --- a/worlds/smz3/__init__.py +++ b/worlds/smz3/__init__.py @@ -8,16 +8,17 @@ from typing import Dict, Set, TextIO from BaseClasses import Region, Entrance, Location, MultiWorld, Item, ItemClassification, CollectionState, \ Tutorial from worlds.generic.Rules import set_rule -from worlds.smz3.TotalSMZ3.Item import ItemType -import worlds.smz3.TotalSMZ3.Item as TotalSMZ3Item -from worlds.smz3.TotalSMZ3.World import World as TotalSMZ3World -from worlds.smz3.TotalSMZ3.Regions.Zelda.GanonsTower import GanonsTower -from worlds.smz3.TotalSMZ3.Config import Config, GameMode, Goal, KeyShuffle, MorphLocation, SMLogic, SwordLocation, Z3Logic, OpenTower, GanonVulnerable, OpenTourian -from worlds.smz3.TotalSMZ3.Location import LocationType, locations_start_id, Location as TotalSMZ3Location -from worlds.smz3.TotalSMZ3.Patch import Patch as TotalSMZ3Patch, getWord, getWordArray -from worlds.smz3.TotalSMZ3.WorldState import WorldState -from worlds.smz3.TotalSMZ3.Region import IReward, IMedallionAccess -from ..AutoWorld import World, AutoLogicRegister, WebWorld +from .TotalSMZ3.Item import ItemType +from .TotalSMZ3 import Item as TotalSMZ3Item +from .TotalSMZ3.World import World as TotalSMZ3World +from .TotalSMZ3.Regions.Zelda.GanonsTower import GanonsTower +from .TotalSMZ3.Config import Config, GameMode, Goal, KeyShuffle, MorphLocation, SMLogic, SwordLocation, Z3Logic, OpenTower, GanonVulnerable, OpenTourian +from .TotalSMZ3.Location import LocationType, locations_start_id, Location as TotalSMZ3Location +from .TotalSMZ3.Patch import Patch as TotalSMZ3Patch, getWord, getWordArray +from .TotalSMZ3.WorldState import WorldState +from .TotalSMZ3.Region import IReward, IMedallionAccess +from .TotalSMZ3.Text.Texts import openFile +from worlds.AutoWorld import World, AutoLogicRegister, WebWorld from .Client import SMZ3SNIClient from .Rom import get_base_rom_bytes, SMZ3DeltaPatch from .ips import IPS_Patch @@ -272,7 +273,7 @@ class SMZ3World(World): idx = 0 offworldSprites = {} for fileName in itemSprites: - with open(world_folder + "/data/custom_sprite/" + fileName, 'rb') as stream: + with openFile(world_folder + "/data/custom_sprite/" + fileName, 'rb') as stream: buffer = bytearray(stream.read()) offworldSprites[0x04Eff2 + 10*((0x6B + 0x40) + idx)] = bytearray(getWordArray(itemSpritesAddress[idx])) + buffer[0:8] offworldSprites[0x090000 + itemSpritesAddress[idx]] = buffer[8:264] diff --git a/worlds/smz3/ips.py b/worlds/smz3/ips.py index 0da2bd49..7e6516c9 100644 --- a/worlds/smz3/ips.py +++ b/worlds/smz3/ips.py @@ -1,5 +1,7 @@ import itertools +from .TotalSMZ3.Text.Texts import openFile + def range_union(ranges): ret = [] for rg in sorted([[r.start, r.stop] for r in ranges]): @@ -33,7 +35,7 @@ class IPS_Patch(object): @staticmethod def load(filename): loaded_patch = IPS_Patch() - with open(filename, 'rb') as file: + with openFile(filename, 'rb') as file: header = file.read(5) if header != b'PATCH': raise Exception('Not a valid IPS patch file!')