Files
shortdeck/shortdeck_server/persistence.py
2025-09-30 18:09:49 +08:00

17 lines
373 B
Python

from __future__ import annotations
import json
from pathlib import Path
from typing import Any, Dict
DATA_DIR = Path(__file__).parent.joinpath("data")
DATA_DIR.mkdir(exist_ok=True)
def append_game_history(game_id, entry):
file = DATA_DIR / f"{game_id}.jsonl"
with file.open("a", encoding="utf-8") as f:
f.write(json.dumps(entry))
f.write("\n")