mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
SM and SMZ3 apworld support (#1677)
This commit is contained in:
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -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():
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
@@ -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' )
|
||||
|
@@ -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 = [
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from worlds.sm.variaRandomizer.utils.parameters import infinity
|
||||
from ..utils.parameters import infinity
|
||||
import copy
|
||||
|
||||
class Location:
|
||||
|
@@ -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 = [
|
||||
|
@@ -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):
|
||||
|
@@ -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)
|
||||
|
@@ -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):
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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))
|
||||
|
@@ -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):
|
||||
|
@@ -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
|
||||
|
@@ -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):
|
||||
|
@@ -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):
|
||||
|
@@ -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:
|
||||
|
@@ -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):
|
||||
|
@@ -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
|
||||
|
@@ -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).
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
@@ -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!')
|
||||
|
@@ -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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from worlds.sm.variaRandomizer.logic.smbool import SMBool
|
||||
from ..logic.smbool import SMBool
|
||||
|
||||
# layout patches added by randomizers
|
||||
class RomPatches:
|
||||
|
@@ -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)
|
||||
|
@@ -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']
|
||||
|
@@ -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()
|
||||
|
@@ -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'],
|
||||
|
Reference in New Issue
Block a user