mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
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:
35
worlds/zillion/gen_data.py
Normal file
35
worlds/zillion/gen_data.py
Normal 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"])
|
||||
)
|
Reference in New Issue
Block a user