Restructure save games into a zipped bundle.

This is the first step toward bundling all assets related to a save game
into a single item. That makes it easier to avoid clobbering "temporary"
assets from other games like the state.json, but also makes it easier
for players to file bug reports, since there's only a single asset to
upload.

This is only the first step because so far it only includes the various
save files: start of turn, end of last turn before results processing,
and "latest" (the game saved explicitly by the player).
This commit is contained in:
Dan Albert
2023-01-04 14:29:16 -08:00
parent 575470ae1b
commit 0f34946127
29 changed files with 650 additions and 162 deletions

26
game/persistence/paths.py Normal file
View File

@@ -0,0 +1,26 @@
from __future__ import annotations
from pathlib import Path
_dcs_saved_game_folder: Path | None = None
def set_dcs_save_game_directory(user_folder: Path) -> None:
global _dcs_saved_game_folder
_dcs_saved_game_folder = user_folder
if not save_dir().exists():
save_dir().mkdir(parents=True)
def base_path() -> str:
global _dcs_saved_game_folder
assert _dcs_saved_game_folder is not None
return str(_dcs_saved_game_folder)
def save_dir() -> Path:
return Path(base_path()) / "Liberation" / "Saves"
def mission_path_for(name: str) -> Path:
return Path(base_path()) / "Missions" / name