2022-03-18 03:53:09 +00:00
|
|
|
from __future__ import annotations
|
2021-11-13 19:52:30 +00:00
|
|
|
|
2020-03-05 23:48:23 +00:00
|
|
|
import os
|
2020-04-15 08:11:47 +00:00
|
|
|
import sys
|
2022-09-29 22:36:30 +00:00
|
|
|
from typing import Tuple, Optional, TypedDict
|
2020-03-05 23:48:23 +00:00
|
|
|
|
2022-09-29 22:36:30 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
import ModuleUpdate
|
|
|
|
ModuleUpdate.update()
|
2022-03-18 03:53:09 +00:00
|
|
|
|
2024-02-14 23:23:05 +00:00
|
|
|
from worlds.Files import AutoPatchRegister, APPatch
|
2022-03-18 03:53:09 +00:00
|
|
|
|
|
|
|
|
2022-09-29 22:36:30 +00:00
|
|
|
class RomMeta(TypedDict):
|
|
|
|
server: str
|
|
|
|
player: Optional[int]
|
|
|
|
player_name: str
|
2021-11-14 20:03:17 +00:00
|
|
|
|
|
|
|
|
2022-09-29 22:36:30 +00:00
|
|
|
def create_rom_file(patch_file: str) -> Tuple[RomMeta, str]:
|
2022-03-18 03:53:09 +00:00
|
|
|
auto_handler = AutoPatchRegister.get_handler(patch_file)
|
|
|
|
if auto_handler:
|
2024-02-14 23:23:05 +00:00
|
|
|
handler: APPatch = auto_handler(patch_file)
|
2022-03-18 03:53:09 +00:00
|
|
|
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
|
2022-09-29 22:36:30 +00:00
|
|
|
raise NotImplementedError(f"No Handler for {patch_file} found.")
|
2021-11-12 13:36:34 +00:00
|
|
|
|
|
|
|
|
2020-03-17 18:16:11 +00:00
|
|
|
if __name__ == "__main__":
|
2022-09-29 22:36:30 +00:00
|
|
|
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}")
|