Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /randovania_randovania /randovania /cli /commands /patcher_data.py
| from __future__ import annotations | |
| import asyncio | |
| import json | |
| from pathlib import Path | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from argparse import ArgumentParser, Namespace, _SubParsersAction | |
| from randovania.layout.preset import Preset | |
| def patcher_data_command_logic(args: Namespace) -> None: | |
| return asyncio.run(patcher_data_command_logic_async(args)) | |
| async def patcher_data_command_logic_async(args: Namespace) -> None: | |
| from randovania.interface_common.worlds_configuration import WorldsConfiguration | |
| from randovania.layout.layout_description import LayoutDescription | |
| layout_description = LayoutDescription.from_file(args.layout_file) | |
| worlds_config = WorldsConfiguration( | |
| args.player_index, | |
| {i: f"Player {i + 1}" for i in range(layout_description.world_count)}, | |
| ) | |
| preset: Preset = layout_description.get_preset(worlds_config.world_index) | |
| cosmetic_patches = preset.game.data.layout.cosmetic_patches.default() | |
| data_factory = preset.game.patch_data_factory(layout_description, worlds_config, cosmetic_patches) | |
| patch_data = data_factory.create_data() | |
| output = json.dumps( | |
| patch_data, | |
| indent=4, | |
| ) | |
| if args.output is not None: | |
| args.output.write_text(output) | |
| else: | |
| print(output) | |
| def add_patcher_data_command(sub_parsers: _SubParsersAction) -> None: | |
| parser: ArgumentParser = sub_parsers.add_parser("patcher-data", help="Exports the patcher data.") | |
| parser.add_argument("--layout-file", type=Path, required=True, help="The rdvgame file to use") | |
| parser.add_argument( | |
| "--player-index", type=int, default=0, help="Number of the player to export, for multiworld games. 0-indexed" | |
| ) | |
| parser.add_argument("--output", type=Path, help="Where to write the output. Defaults to stdout.") | |
| parser.set_defaults(func=patcher_data_command_logic) | |
Xet Storage Details
- Size:
- 1.89 kB
- Xet hash:
- f7511ee0e7421d442f3b166d49150abae39a48802693d1e46e6e5a62385a25c5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.