def create_permalink(args): from randovania.layout.permalink import Permalink from randovania.layout.generator_parameters import GeneratorParameters from randovania.interface_common.preset_manager import PresetManager game: RandovaniaGame = RandovaniaGame(args.game) preset_manager = PresetManager(None) presets = [] for preset_name in args.preset_name: versioned = preset_manager.included_preset_with(game, preset_name) if versioned is None: raise ValueError( "Unknown included preset '{}' for game {}. Valid options are: {}" .format(preset_name, game.long_name, [ preset.name for preset in preset_manager.included_presets.values() if preset.game == game ])) presets.append(versioned.get_preset()) seed = args.seed_number if seed is None: seed = random.randint(0, 2**31) return Permalink.from_parameters( GeneratorParameters( seed, spoiler=not args.race, presets=presets, ), )
async def _create_permalink(args_) -> Permalink: from randovania.interface_common.preset_manager import PresetManager preset_manager = PresetManager(None) preset = preset_manager.included_preset_with(RandovaniaGame(args_.game), args_.preset_name).get_preset() return Permalink( args_.seed_number, spoiler=True, presets={i: preset for i in range(args_.player_count)}, )
async def permalink_command_body(args): from randovania.interface_common.preset_manager import PresetManager preset_manager = PresetManager(None) versioned_preset = preset_manager.included_preset_with( RandovaniaGame(args.game), args.preset) if versioned_preset is None: raise ValueError(f"Unknown preset: {args.preset}") seed = args.seed if seed is None: seed = random.randint(0, 2**31) preset = versioned_preset.get_preset() permalink = Permalink( seed_number=seed, spoiler=not args.race, presets={i: preset for i in range(args.player_count)}) print(permalink.as_base64_str) Permalink.from_str(permalink.as_base64_str)