示例#1
0
 def test_OPTGROUP(self):
     # Empty OPTGROUP test
     self.assertEqual(OPTGROUP().xml(),
                      b'<optgroup></optgroup>')
     # Not Empty OPTGROUP test
     self.assertEqual(OPTGROUP('<>', _a='1', _b='2').xml(),
                      b'<optgroup a="1" b="2"><option value="&lt;&gt;">&lt;&gt;</option></optgroup>')
     # With an OPTION
     self.assertEqual(OPTGROUP(OPTION('Option 1', _value='1'), _label='Group 1').xml(),
                      b'<optgroup label="Group 1"><option value="1">Option 1</option></optgroup>')
示例#2
0
    def run(self):
        # init session
        if self.session.plando is None:
            self.session.plando = {
                "state": {},
                "preset": "regular",
                "seed": None,
                "startLocation": "Landing Site",

                # rando params
                "rando": {},

                # set to False in plando.html
                "firstTime": True
            }

        # load presets list
        (stdPresets, tourPresets, comPresets) = loadPresetsList(self.cache)

        # access points
        vanillaAPs = []
        for (src, dest) in vanillaTransitions:
            vanillaAPs += [transition2isolver(src), transition2isolver(dest)]

        vanillaBossesAPs = []
        for (src, dest) in vanillaBossesTransitions:
            vanillaBossesAPs += [
                transition2isolver(src),
                transition2isolver(dest)
            ]

        escapeAPs = []
        for (src, dest) in vanillaEscapeTransitions:
            escapeAPs += [transition2isolver(src), transition2isolver(dest)]

        # generate list of addresses to read in the ROM
        addresses = getAddressesToRead(plando=True)

        startAPs = GraphUtils.getStartAccessPointNamesCategory()
        startAPs = [
            OPTGROUP(_label="Standard", *startAPs["regular"]),
            OPTGROUP(_label="Custom", *startAPs["custom"]),
            OPTGROUP(_label="Custom (Area rando only)", *startAPs["area"])
        ]

        return dict(stdPresets=stdPresets,
                    tourPresets=tourPresets,
                    comPresets=comPresets,
                    vanillaAPs=vanillaAPs,
                    vanillaBossesAPs=vanillaBossesAPs,
                    escapeAPs=escapeAPs,
                    curSession=self.session.plando,
                    addresses=addresses,
                    startAPs=startAPs,
                    version=displayedVersion)
示例#3
0
 def test_SELECT(self):
     self.assertEqual(
         SELECT('<>', _a='1', _b='2').xml(), b'<select a="1" b="2">' +
         b'<option value="&lt;&gt;">&lt;&gt;</option></select>')
     self.assertEqual(
         SELECT(OPTION('option 1', _value='1'),
                OPTION('option 2', _value='2')).xml(),
         b'<select><option value="1">option 1</option><option value="2">option 2</option></select>'
     )
     self.assertEqual(
         SELECT(OPTION('option 1', _value='1', _selected='selected'),
                OPTION('option 2', _value='2'),
                _multiple='multiple').xml(),
         b'<select multiple="multiple"><option selected="selected" value="1">option 1</option><option value="2">option 2</option></select>'
     )
     # More then one select with mutilple
     self.assertEqual(
         SELECT(OPTION('option 1', _value='1', _selected='selected'),
                OPTION('option 2', _value='2', _selected='selected'),
                _multiple='multiple').xml(),
         b'<select multiple="multiple"><option selected="selected" value="1">option 1</option><option selected="selected" value="2">option 2</option></select>'
     )
     # OPTGROUP
     self.assertEqual(
         SELECT(
             OPTGROUP(
                 OPTION('option 1', _value='1'),
                 OPTION('option 2', _value='2'),
                 _label='Group 1',
             )).xml(),
         b'<select><optgroup label="Group 1"><option value="1">option 1</option><option value="2">option 2</option></optgroup></select>'
     )
     # List
     self.assertEqual(
         SELECT([1, 2, 3, 4, 5]).xml(),
         b'<select><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>'
     )
     # Tuple
     self.assertEqual(
         SELECT((1, 2, 3, 4, 5)).xml(),
         b'<select><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>'
     )
     # String value
     self.assertEqual(
         SELECT('Option 1', 'Option 2').xml(),
         b'<select><option value="Option 1">Option 1</option><option value="Option 2">Option 2</option></select>'
     )
     # list as a value
     self.assertEqual(
         SELECT(OPTION('option 1', _value=[1, 2, 3]),
                OPTION('option 2', _value=[4, 5, 6], _selected='selected'),
                _multiple='multiple').xml(),
         b'<select multiple="multiple"><option value="[1, 2, 3]">option 1</option><option selected="selected" value="[4, 5, 6]">option 2</option></select>'
     )
    def run(self):
        # init session
        if self.session.tracker is None:
            self.session.tracker = {
                "state": {},
                "preset": "regular",
                "seed": None,
                "startLocation": "Landing Site",
                # set to False in tracker.html
                "firstTime": True
            }

        # load presets list
        (stdPresets, tourPresets, comPresets) = loadPresetsList(self.cache)

        # access points
        vanillaAPs = []
        for (src, dest) in vanillaTransitions:
            vanillaAPs += [transition2isolver(src), transition2isolver(dest)]

        vanillaBossesAPs = []
        for (src, dest) in vanillaBossesTransitions:
            vanillaBossesAPs += [
                transition2isolver(src),
                transition2isolver(dest)
            ]

        escapeAPs = []
        for (src, dest) in vanillaEscapeTransitions:
            escapeAPs += [transition2isolver(src), transition2isolver(dest)]

        # generate list of addresses to read in the ROM
        addresses = getAddressesToRead()

        startAPs = GraphUtils.getStartAccessPointNamesCategory()
        startAPs = [
            OPTGROUP(_label="Standard", *startAPs["regular"]),
            OPTGROUP(_label="Custom", *startAPs["custom"]),
            OPTGROUP(_label="Custom (Area rando only)", *startAPs["area"])
        ]

        # get ap -> grapharea for auto tracker
        apsGraphArea = {
            locName4isolver(ap.Name): ap.GraphArea
            for ap in accessPoints
        }

        return dict(stdPresets=stdPresets,
                    tourPresets=tourPresets,
                    comPresets=comPresets,
                    vanillaAPs=vanillaAPs,
                    vanillaBossesAPs=vanillaBossesAPs,
                    escapeAPs=escapeAPs,
                    curSession=self.session.tracker,
                    addresses=addresses,
                    startAPs=startAPs,
                    areaAccessPoints=InteractiveSolver.areaAccessPoints,
                    bossAccessPoints=InteractiveSolver.bossAccessPoints,
                    escapeAccessPoints=InteractiveSolver.escapeAccessPoints,
                    nothingScreens=InteractiveSolver.nothingScreens,
                    doorsScreen=InteractiveSolver.doorsScreen,
                    bossBitMasks=InteractiveSolver.bossBitMasks,
                    apsGraphArea=apsGraphArea)
示例#5
0
    def run(self):
        self.initRandomizerSession()

        (stdPresets, tourPresets, comPresets) = loadPresetsList(self.cache)

        randoPresetsDesc = {
            "all_random": "all the parameters set to random",
            "Chozo_Speedrun": "speedrun progression speed with Chozo split",
            "default": "VARIA randomizer default settings",
            "doors_long": "be prepared to hunt for beams and ammo to open doors",
            "doors_short": "uses Chozo/speedrun settings for a quicker door color rando",
            "free": "easiest possible settings",
            "hardway2hell": "harder highway2hell",
            "haste": "inspired by DASH randomizer with Nerfed Charge / Progressive Suits",
            "highway2hell": "favors suitless seeds",
            "hud": "Full rando with remaining major upgrades in the area shown in the HUD",
            "hud_hard": "Low resources and VARIA HUD enabled to help you track of actual items count",
            "hud_start": "Non-vanilla start with Major or Chozo split",
            "minimizer":"Typical 'boss rush' settings with random start and nerfed charge",
            "minimizer_hardcore":"Have fun 'rushing' bosses with no equipment on a tiny map",
            "minimizer_maximizer":"No longer a boss rush",
            "quite_random": "randomizes a few significant settings to have various seeds",
            "scavenger_hard":"Pretty hostile Scavenger mode",
            "scavenger_random":"Randomize everything within Scavenger mode",
            "scavenger_speedrun":"Quickest Scavenger settings",
            "scavenger_vanilla_but_not":"Items are vanilla, but area and bosses are not",
            "stupid_hard": "hardest possible settings",
            "surprise": "quite_random with Area/Boss/Doors/Start settings randomized",
            "vanilla": "closest possible to vanilla Super Metroid",
            "way_of_chozo": "chozo split with boss randomization",
            "where_am_i": "Area mode with random start location and early morph",
            "where_is_morph": "Area mode with late Morph",
            "Multi_Category_Randomizer_Week_1": "Multi-Category Randomizer Tournament week 1",
            "Multi_Category_Randomizer_Week_2": "Multi-Category Randomizer Tournament week 2",
            "Multi_Category_Randomizer_Week_3": "Multi-Category Randomizer Tournament week 3",
            "Multi_Category_Randomizer_Week_4": "Multi-Category Randomizer Tournament week 4",
            "Multi_Category_Randomizer_Week_5": "Multi-Category Randomizer Tournament week 5",
            "Multi_Category_Randomizer_Week_6": "Multi-Category Randomizer Tournament week 6",
            "Multi_Category_Randomizer_Week_7": "Multi-Category Randomizer Tournament week 7",
            "Season_Races": "rando league races (Majors/Minors split)",
            "SGLive2022_Race_1": "SGLive 2022 Super Metroid randomizer tournament race 1",
            "SGLive2022_Race_2": "SGLive 2022 Super Metroid randomizer tournament race 2",
            "SGLive2022_Race_3": "SGLive 2022 Super Metroid randomizer tournament race 3",
            "SMRAT2021": "Super Metroid Randomizer Accessible Tournament 2021",
            "VARIA_Weekly": "Casual logic community races"
        }

        randoPresetsCategories = {
            "Standard": ["", "default", "Chozo_Speedrun", "free", "haste", "vanilla"],
            "Hud": ["hud", "hud_hard", "hud_start"],
            "Scavenger": ["scavenger_hard", "scavenger_random", "scavenger_speedrun", "scavenger_vanilla_but_not"],
            "Area": ["way_of_chozo", "where_am_i", "where_is_morph"],
            "Doors": ["doors_long", "doors_short"],
            "Minimizer": ["minimizer", "minimizer_hardcore", "minimizer_maximizer"],
            "Hard": ["hardway2hell", "highway2hell", "stupid_hard"],
            "Random": ["all_random", "quite_random", "surprise"],
            "Tournament": ["Season_Races", "SMRAT2021", "VARIA_Weekly", "SGLive2022_Race_1", "SGLive2022_Race_2", "SGLive2022_Race_3", "Multi_Category_Randomizer_Week_1", "Multi_Category_Randomizer_Week_2", "Multi_Category_Randomizer_Week_3", "Multi_Category_Randomizer_Week_4", "Multi_Category_Randomizer_Week_5", "Multi_Category_Randomizer_Week_6", "Multi_Category_Randomizer_Week_7"]
        }

        startAPs = GraphUtils.getStartAccessPointNamesCategory()
        startAPs = [OPTGROUP(_label="Standard", *startAPs["regular"]),
                    OPTGROUP(_label="Custom", *startAPs["custom"]),
                    OPTGROUP(_label="Custom (Area rando only)", *startAPs["area"])]

        # get multi
        currentMultiValues = self.getCurrentMultiValues()
        defaultMultiValues = getDefaultMultiValues()

        # objectives self exclusions
        objectivesExclusions = Objectives.getExclusions()
        objectivesTypes = Objectives.getObjectivesTypes()
        objectivesSort = Objectives.getObjectivesSort()
        objectivesCategories = Objectives.getObjectivesCategories()

        # check if we have a guid in the url
        url = self.request.env.request_uri.split('/')
        if len(url) > 0 and url[-1] != 'randomizer':
            # a seed unique key was passed as parameter
            key = url[-1]

            # decode url
            key = urllib.parse.unquote(key)

            # sanity check
            if IS_MATCH('^[0-9a-z-]*$')(key)[1] is None and IS_LENGTH(maxsize=36, minsize=36)(key)[1] is None:
                with DB() as db:
                    seedInfo = db.getSeedInfo(key)
                if seedInfo is not None and len(seedInfo) > 0:
                    defaultParams = getRandomizerDefaultParameters()
                    defaultParams.update(seedInfo)
                    seedInfo = defaultParams

                    # check that the seed ips is available
                    if seedInfo["upload_status"] in ['pending', 'uploaded', 'local']:
                        # load parameters in session
                        for key, value in seedInfo.items():
                            if key in ["complexity", "randoPreset", "raceMode"]:
                                continue
                            elif key in defaultMultiValues:
                                keyMulti = key + 'MultiSelect'
                                if keyMulti in seedInfo:
                                    if key == 'objective' and value == 'nothing':
                                        self.session.randomizer[key] = ""
                                    else:
                                        self.session.randomizer[key] = seedInfo[key]
                                    valueMulti = seedInfo[keyMulti]
                                    if type(valueMulti) == str:
                                        valueMulti = valueMulti.split(',')
                                    self.session.randomizer[keyMulti] = valueMulti
                                    currentMultiValues[key] = valueMulti
                            elif key in self.session.randomizer and 'MultiSelect' not in key:
                                self.session.randomizer[key] = value

        return dict(stdPresets=stdPresets, tourPresets=tourPresets, comPresets=comPresets,
                    randoPresetsDesc=randoPresetsDesc, randoPresetsCategories=randoPresetsCategories,
                    startAPs=startAPs, currentMultiValues=currentMultiValues, defaultMultiValues=defaultMultiValues,
                    maxsize=sys.maxsize, displayNames=displayNames, objectivesExclusions=objectivesExclusions,
                    objectivesTypes=objectivesTypes, objectivesSort=objectivesSort,
                    objectivesCategories=objectivesCategories)