mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 04:01:32 -06:00

* First Pass removal of game-specific code * SMW, DKC3, and SM hooked into AutoClient * All SNES autoclients functional * Fix ALttP Deathlink * Don't default to being ALttP, and properly error check ctx.game * Adjust variable naming * In response to: > we should probably document usage somewhere. I'm open to suggestions of where this should be documented. I think the most valuable documentation for APIs is docstrings and full typing. about websockets change in imports - from websockets documentation: > For convenience, many public APIs can be imported from the websockets package. However, this feature is incompatible with static code analysis. It breaks autocompletion in an IDE or type checking with mypy. If you’re using such tools, use the real import paths. * todo note for python 3.11 typing.NotRequired * missed staging in previous commit * added missing death Game States for DeathLink Co-authored-by: beauxq <beauxq@users.noreply.github.com> Co-authored-by: lordlou <87331798+lordlou@users.noreply.github.com>
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from typing import Tuple, Optional, TypedDict
|
|
|
|
if __name__ == "__main__":
|
|
import ModuleUpdate
|
|
ModuleUpdate.update()
|
|
|
|
from worlds.Files import AutoPatchRegister, APDeltaPatch
|
|
|
|
|
|
class RomMeta(TypedDict):
|
|
server: str
|
|
player: Optional[int]
|
|
player_name: str
|
|
|
|
|
|
def create_rom_file(patch_file: str) -> Tuple[RomMeta, str]:
|
|
auto_handler = AutoPatchRegister.get_handler(patch_file)
|
|
if auto_handler:
|
|
handler: APDeltaPatch = auto_handler(patch_file)
|
|
target = os.path.splitext(patch_file)[0]+handler.result_file_ending
|
|
handler.patch(target)
|
|
return {"server": handler.server,
|
|
"player": handler.player,
|
|
"player_name": handler.player_name}, target
|
|
raise NotImplementedError(f"No Handler for {patch_file} found.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
for file in sys.argv[1:]:
|
|
meta_data, result_file = create_rom_file(file)
|
|
print(f"Patch with meta-data {meta_data} was written to {result_file}")
|