Created
April 2, 2022 14:38
-
-
Save dmitmel/68db51607bf412d39ae0ceb86d08a08e to your computer and use it in GitHub Desktop.
Savegame patcher for https://github.com/Anuken/animdustry/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
from typing import Dict, List, TypedDict | |
import zlib | |
import json | |
import os | |
class SaveData(TypedDict): | |
introDone: bool | |
units: List[str] | |
copper: int | |
rolls: int | |
scores: List[int] | |
lastUnit: str | |
duplicates: Dict[str, int] | |
save_file_path = os.path.expanduser("~/.config/absurd/data.bin") | |
with open(save_file_path, "rb") as file: | |
bin_data = zlib.decompress(file.read(), wbits=-zlib.MAX_WBITS) | |
save_data: SaveData = json.loads(bin_data.decode("utf8")) | |
# save_data["copper"] = 12345 | |
save_data = { | |
"introDone": True, | |
"units": ["alpha", "mono", "oct", "crawler", "zenith", "quad", "oxynoe", "boulder"], | |
"copper": 7, | |
"rolls": 0, | |
"scores": [412, 248, 222, 235, 0], | |
"lastUnit": "mono", | |
"duplicates": { | |
"boulder": 2, | |
"mono": 1, | |
"zenith": 1, | |
"alpha": 1 | |
} | |
} | |
with open(save_file_path, "wb") as file: | |
bin_data = json.dumps(save_data, separators=(",", ":"), ensure_ascii=False).encode("utf8") | |
stream = zlib.compressobj(wbits=-zlib.MAX_WBITS) | |
file.write(stream.compress(bin_data)) | |
file.write(stream.flush()) | |
file.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment