Zillion: remove rom requirement for generation (#2875)

* in the middle of work towards no rom for generation (not working)

* no rom needed for Zillion generation

* revert core changes
This commit is contained in:
Doug Hoskisson
2024-03-03 13:10:14 -08:00
committed by GitHub
parent 4e31e51d7a
commit 113c54f9be
6 changed files with 200 additions and 85 deletions

View File

@@ -0,0 +1,35 @@
from dataclasses import dataclass
import json
from typing import Dict, Tuple
from zilliandomizer.game import Game as ZzGame
@dataclass
class GenData:
""" data passed from generation to patcher """
multi_items: Dict[str, Tuple[str, str]]
""" zz_loc_name to (item_name, player_name) """
zz_game: ZzGame
game_id: bytes
""" the byte string used to detect the rom """
def to_json(self) -> str:
""" serialized data from generation needed to patch rom """
jsonable = {
"multi_items": self.multi_items,
"zz_game": self.zz_game.to_jsonable(),
"game_id": list(self.game_id)
}
return json.dumps(jsonable)
@staticmethod
def from_json(gen_data_str: str) -> "GenData":
""" the reverse of `to_json` """
from_json = json.loads(gen_data_str)
return GenData(
from_json["multi_items"],
ZzGame.from_jsonable(from_json["zz_game"]),
bytes(from_json["game_id"])
)