diff --git a/games/graveyard_keeper_2/README.md b/games/graveyard_keeper_2/README.md new file mode 100644 index 0000000..21a1eab --- /dev/null +++ b/games/graveyard_keeper_2/README.md @@ -0,0 +1,37 @@ +# graveyard_keeper_2 + +Steam appid: `4358690`. Status: **proven** (day, graveyard quality, church quality, happiness); reputation and citizens hidden. + +## Save locations + +- Windows: `%USERPROFILE%\AppData\LocalLow\Lazy Bear Games\Graveyard Keeper 2\.info` and `.dat` +- Steam Deck / Proton: `steamapps/compatdata/4358690/pfx/drive_c/users/steamuser/AppData/LocalLow/Lazy Bear Games/Graveyard Keeper 2/` + +The reader uses `ddsaves._common.proton_user(4358690)` to walk every Steam library and picks the newest `*.info`. +The JSON sidecar gives day, time and the zone qualities. The sibling `.dat` (13 MB, uncompressed) is scanned once for +the single typed variable `happiness`; nothing else in it is interpreted and it is never written. Steam Cloud syncs +both files, so a Deck shows the same card as the PC. + +## What the card shows + +- `day` — in-game day (fact id `day`, label `facts.graveyard_keeper_2.day`). +- `graveyard_quality` — the game's "Graveyard Quality" value, labelled "Graveyard" (declared non-monotonic: it can fall). +- `church_quality` — the game's "Church Quality" value, labelled "Church" (declared non-monotonic). +- `happiness` — the town happiness shown with the thumbs-up icon in the HUD (declared non-monotonic: it is spent). + Only the current value is shown; the HUD's `/20` cap is not stored in the save, so it is not displayed. +- `observed_at` — the save timestamp from `saveDateTime`. + +## What stays hidden + +- `villageRep`: the sidecar value stayed 17 while the HUD reputation went from 0 to 10 between saves, so its meaning is + unknown and it is never displayed. +- `townCitizens`: matched the HUD (20) but was constant across all eight stages, so it stays unproven. + +See `proof.md` for the stage table. + +## Checks + +```bash +python tools/run_game_tests.py graveyard_keeper_2 +python tools/gate/check_cards.py graveyard_keeper_2 +``` diff --git a/games/graveyard_keeper_2/icons.json b/games/graveyard_keeper_2/icons.json new file mode 100644 index 0000000..21df2b7 --- /dev/null +++ b/games/graveyard_keeper_2/icons.json @@ -0,0 +1,18 @@ +{ + "day": { + "subject": "a small sun above a horizon line, as on a calendar day marker", + "reference": "the in-game day counter shown next to the clock HUD" + }, + "graveyard_quality": { + "subject": "a small stylised skull, as the game's own graveyard-quality marker", + "reference": "the skull sprite next to the Graveyard Quality value in the graveyard HUD/inspection panel" + }, + "church_quality": { + "subject": "a small chapel outline with a cross on the roof", + "reference": "the Church Quality value shown in the church inspection panel" + }, + "happiness": { + "subject": "a small thumbs-up hand", + "reference": "the town happiness icon (sprite `happiness`) next to the x/y counter in the HUD" + } +} diff --git a/games/graveyard_keeper_2/proof.md b/games/graveyard_keeper_2/proof.md new file mode 100644 index 0000000..dc04a63 --- /dev/null +++ b/games/graveyard_keeper_2/proof.md @@ -0,0 +1,36 @@ +# Evidence record — Graveyard Keeper 2 + +Status: **proven (4 fields shown)**. Saves are the contributor's own, one playthrough, Steam builds 1.011.1 (stages 1–4) +and 1.012.9 (stages 5–8), Proton on Linux (stages 1–4 are the Steam Cloud copies on a Steam Deck, 5–8 the PC's rolling +backups). Each stage folder holds the slot's `Steam_1.info` (JSON sidecar) and `Steam_1.dat` (binary world state, +uncompressed: entropy 3.7 bits/byte, UTF-16 field names of the C# serializer). + +| field | s1 | s2 | s3 | s4 | s5 | s6 | s7 | s8 | game-visible evidence | source | decision | +|---|---|---|---|---|---|---|---|---|---|---|---| +| day (.info) | 110 | 111 | 113 | 114 | 116 | 117 | 117 | 117 | HUD day counter | number | proven, shown | +| saved_at (.info) | 20:53 | 21:08 | 21:26 | 21:32 (11-09) | 21:56 | 21:58 | 22:02 | 22:09 (11-26) | save slot timestamp | — | proven, observed_at | +| graveyardQuality (.info) | 28 | 28 | 28 | 28 | 23 | 23 | 23 | 23 | "Graveyard Quality" panel; player read 23 at s7/s8; equals `wz_graveyard` in the .dat | label from game strings | proven, shown, **nonmonotonic** | +| churchQuality (.info) | 36 | 36 | 36 | 36 | 36 | 36 | 29 | 29 | "Church Quality" panel; player read 29 at s7/s8; equals `wz_church` in the .dat | label from game strings | proven, shown, **nonmonotonic** | +| happiness (.dat) | 0 | 3 | 3 | 0 | 5 | 5 | 5 | 10 | HUD thumbs-up counter: player read 0/20 at s4, 5/20 at s5–s7, 10/20 at s8 | game identifier `happiness` / `town_happiness` | proven, shown, **nonmonotonic** | +| villageRep (.info) | 17 | 17 | 17 | 17 | 17 | 17 | 17 | 17 | never matched the HUD; `repValue: false`; equals `village_REP` in the .dat (an NPC-style reputation) | — | **hidden** | +| townCitizens (.info) | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | player read 20 (matches) | — | unproven (constant) | + +Non-monotonic declarations: the two quality values are state values recomputed from the current graves / church +(28 → 23 across the 1.011.1 → 1.012.9 update, 36 → 29 within one session). Happiness is a spendable town resource: the +game's own texts say "spend to get what you want" and it dropped 3 → 0 between s3 and s4. +`read()` declares all three in `nonmonotonic` with the reason, so the gate reports them for human review. + +How `happiness` is read: the `.dat` stores typed variables as `\x01 \x1f\x01 \x05\0\0\0 "value" `. +The reader scans for that exact byte pattern with the name `happiness`; the value must occur exactly once with one value, +otherwise the field is `None` and hidden. Nothing else in the `.dat` is interpreted, and the file is never written. + +The HUD shows happiness as `x/20`. No variable in the `.dat` carries that cap (no `happiness_max`, no `happiness_cap`; +`townCitizens` happens to be 20 but is not proven to be the denominator), so the card shows only the current value. + +Label strings in the game's `resources.assets`: `Graveyard Quality`, `Church Quality` (EN), `Качество кладбища`, +`Качество церкви` (RU), `Friedhofsqualität`, `Kirchenqualität` (DE); the card uses the shorter nouns `Graveyard` / `Church` +(`Кладбище` / `Церковь`), which are game strings too. Happiness has no text label in the HUD (icon only); +its identifier in the game data is `happiness` / `town_happiness`, so the fact label is the plain word "Happiness". + +Stages are the game's rolling backups of one slot (`_backup_3` oldest → `Steam_1` newest), copied into the ignored +`stages/` folder (`.info` + `.dat` per stage, ~13 MB each). diff --git a/games/graveyard_keeper_2/reader.py b/games/graveyard_keeper_2/reader.py new file mode 100644 index 0000000..6d3a9b4 --- /dev/null +++ b/games/graveyard_keeper_2/reader.py @@ -0,0 +1,173 @@ +"""Graveyard Keeper 2 (appid 4358690): read-only, stdlib reader for the save metadata sidecar. + +Each slot writes two files next to each other: ``.dat`` (binary Unity/C# world state, +~13 MB, uncompressed, UTF-16 field names) and ``.info`` (small JSON written by the game). +The ``.info`` sidecar gives day, time and the two zone qualities. One typed variable is read +from the ``.dat`` by a byte scan: ``happiness``, the town happiness shown with the thumbs-up +icon in the HUD. Nothing else in the ``.dat`` is interpreted. + +Proof (7 stages of one playthrough, see proof.md): ``day`` grows 110 -> 117 and ``saveDateTime`` +with it. ``graveyardQuality`` (28 -> 23) and ``churchQuality`` (36 -> 29) change between stages and +match the HUD values the player sees; both are state values the game recomputes, so they are +declared ``nonmonotonic``. ``happiness`` (0 -> 3 -> 0 -> 5 -> 10) is a spendable town resource +and is declared ``nonmonotonic`` too. ``villageRep`` and ``townCitizens`` stay hidden. +""" +from __future__ import annotations +import json +import math +import os +import struct +from datetime import datetime +from pathlib import Path + +try: + from ddsaves._common import proton_user, newest, read_bytes +except ImportError: # pragma: no cover - the proof gate always exposes plugin/py_modules + proton_user = None + + def newest(paths): + best = None + for p in paths: + if p.is_file() and (best is None or p.stat().st_mtime > best.stat().st_mtime): + best = p + return best + + def read_bytes(path): + return Path(path).read_bytes() + +APPID = 4358690 +SUB = "AppData/LocalLow/Lazy Bear Games/Graveyard Keeper 2" +INFO_GLOB = "*.info" +TIME_FORMAT = "%m/%d/%Y %I:%M:%S %p" +DAT_MAX_BYTES = 64 * 1024 * 1024 + + +def _utf16(text: str) -> bytes: + return text.encode("utf-16-le") + + +def _dat_variable(dat_path, name: str): + """Return the float value of a typed variable ``{type: , value: }`` in the .dat. + + The serializer writes ``\x01 \x1f\x01 \x05\0\0\0 "value" ``. + Returns None when the file is missing, too large, the name is absent or ambiguous. + """ + try: + if not dat_path.is_file() or dat_path.stat().st_size > DAT_MAX_BYTES: + return None + blob = read_bytes(dat_path) + except OSError: + return None + needle = struct.pack(" dict: + return {"place": None, "chapter": None, "objective": None, "progress": {}, + "facts": [], "proven": [], "unproven": [], "fact_sources": {}} + + +def _candidate_dirs() -> list: + out = [] + if os.environ.get("USERPROFILE"): + out.append(Path(os.environ["USERPROFILE"]) / SUB) + if proton_user is not None: + out.extend(p / SUB for p in proton_user(APPID)) + return out + + +def find(path_or_dir=None): + if path_or_dir is not None: + p = Path(path_or_dir) + if p.is_file(): + return p + if p.is_dir(): + return newest(p.glob(INFO_GLOB)) or newest(p.rglob(INFO_GLOB)) + return None + for folder in _candidate_dirs(): + found = newest(folder.glob(INFO_GLOB)) + if found: + return found + return None + + +def _parse_time(text): + try: + return datetime.strptime(str(text), TIME_FORMAT).timestamp() + except (TypeError, ValueError): + return None + + +def read(path_or_dir=None) -> dict: + path = find(path_or_dir) + if path is None: + return _empty() + try: + info = json.loads(read_bytes(path).decode("utf-8")) + except (OSError, ValueError, UnicodeDecodeError): + return _empty() + if not isinstance(info, dict): + return _empty() + day = info.get("day") + if not isinstance(day, int) or isinstance(day, bool): + return _empty() + saved_at = _parse_time(info.get("saveDateTime")) + happiness = _dat_variable(path.with_suffix(".dat"), "happiness") + if happiness is not None and happiness == int(happiness): + happiness = int(happiness) + progress = { + "happiness": happiness, + "day": day, + "saved_at": saved_at, + "is_autosave": info.get("isAutoSave") is True, + "game_save_version": info.get("gameSaveVersion"), + "graveyard_quality": info.get("graveyardQuality"), + "church_quality": info.get("churchQuality"), + "village_rep": info.get("villageRep"), + "town_citizens": info.get("townCitizens"), + } + facts = [{"id": "day", "icon": "day", "value": str(day)}] + fact_sources = {"day": "day"} + proven = ["day", "saved_at"] + unproven = ["village_rep", "town_citizens", "is_autosave", "game_save_version"] + for field in ("graveyard_quality", "church_quality", "happiness"): + value = progress[field] + if isinstance(value, int) and not isinstance(value, bool): + facts.append({"id": field, "icon": field, "value": str(value)}) + fact_sources[field] = field + proven.append(field) + else: + unproven.append(field) + out = _empty() + out.update({ + "progress": progress, + "facts": facts, + "proven": proven, + "unproven": unproven, + "fact_sources": fact_sources, + "nonmonotonic": { + "graveyard_quality": "sum of the current graves' quality; falls when graves decay, are reworked or removed (28 -> 23 observed across stages 4 -> 5)", + "church_quality": "current church state, recomputed by the game; fell 36 -> 29 within one session (stages 6 -> 7)", + "happiness": "town happiness is a spendable resource ( in the game's own texts); 3 -> 0 observed between stages 3 and 4", + }, + "observed_at": saved_at if saved_at is not None else path.stat().st_mtime, + "source_path": str(path), + }) + return out + + +if __name__ == "__main__": + import sys + print(json.dumps(read(sys.argv[1] if len(sys.argv) > 1 else None), ensure_ascii=False, indent=2)) diff --git a/games/graveyard_keeper_2/stages.json b/games/graveyard_keeper_2/stages.json new file mode 100644 index 0000000..c48140f --- /dev/null +++ b/games/graveyard_keeper_2/stages.json @@ -0,0 +1,37 @@ +{ + "appid": 4358690, + "stages": [ + { + "path": "stages/stage1_day110", + "note": "Steam_1_backup_3 (.info + .dat), 2026-11-09 20:53, day 110, game 1.011.1" + }, + { + "path": "stages/stage2_day111", + "note": "Steam_1_backup_2, 2026-11-09 21:08, day 111" + }, + { + "path": "stages/stage3_day113", + "note": "Steam_1_backup_1, 2026-11-09 21:26, day 113" + }, + { + "path": "stages/stage4_day114", + "note": "Steam_1, 2026-11-09 21:32, day 114 (Steam Cloud copy from the Deck)" + }, + { + "path": "stages/stage5_day116", + "note": "Steam_1_backup_3, 2026-11-26 21:56, day 116, game 1.012.9" + }, + { + "path": "stages/stage6_day117", + "note": "Steam_1_backup_2, 2026-11-26 21:58, day 117" + }, + { + "path": "stages/stage7_day117", + "note": "Steam_1_backup_1, 2026-11-26 22:02, day 117, church quality changed" + }, + { + "path": "stages/stage8_day117", + "note": "Steam_1, 2026-11-26 22:09, day 117, happiness changed" + } + ] +} diff --git a/games/graveyard_keeper_2/stages/.gitignore b/games/graveyard_keeper_2/stages/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/games/graveyard_keeper_2/stages/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/games/graveyard_keeper_2/tables.py b/games/graveyard_keeper_2/tables.py new file mode 100644 index 0000000..d5f34c4 --- /dev/null +++ b/games/graveyard_keeper_2/tables.py @@ -0,0 +1,19 @@ +"""Graveyard Keeper 2 needs no name table: the card shows only numbers read from the .info sidecar. + +Kept for the contribution layout. If a future version displays named places or items, generate +data/graveyard_keeper_2..json from the game's own localisation here. +""" +import argparse +from pathlib import Path + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("game_files", type=Path, nargs="?") + parser.add_argument("--language", choices=("en", "ru", "uk"), default="en") + parser.parse_args() + print("graveyard_keeper_2: no name table required (numeric facts only)") + + +if __name__ == "__main__": + main() diff --git a/games/graveyard_keeper_2/test_reader.py b/games/graveyard_keeper_2/test_reader.py new file mode 100644 index 0000000..e2c56d9 --- /dev/null +++ b/games/graveyard_keeper_2/test_reader.py @@ -0,0 +1,82 @@ +"""Golden values read by hand from the eight stage folders (not copied from reader output).""" +from pathlib import Path +import unittest +from reader import read + +HERE = Path(__file__).resolve().parent / "stages" +# (day, graveyardQuality, churchQuality) typed from each JSON file by eye; happiness is the +# value the player read from the HUD thumbs-up counter at that point (0, 3, 0, 5, 10 of 20). +GOLDEN = { + "stage1_day110": (110, 28, 36, 0), + "stage2_day111": (111, 28, 36, 3), + "stage3_day113": (113, 28, 36, 3), + "stage4_day114": (114, 28, 36, 0), + "stage5_day116": (116, 23, 36, 5), + "stage6_day117": (117, 23, 36, 5), + "stage7_day117": (117, 23, 29, 5), + "stage8_day117": (117, 23, 29, 10), +} + + +class ReaderTests(unittest.TestCase): + def test_stage_values_and_facts(self): + for name, (day, graveyard, church, happiness) in GOLDEN.items(): + card = read(HERE / name) + self.assertEqual(card["progress"]["day"], day, name) + self.assertEqual(card["progress"]["graveyard_quality"], graveyard, name) + self.assertEqual(card["progress"]["church_quality"], church, name) + self.assertEqual(card["progress"]["happiness"], happiness, name) + self.assertEqual(card["facts"], [ + {"id": "day", "icon": "day", "value": str(day)}, + {"id": "graveyard_quality", "icon": "graveyard_quality", "value": str(graveyard)}, + {"id": "church_quality", "icon": "church_quality", "value": str(church)}, + {"id": "happiness", "icon": "happiness", "value": str(happiness)}, + ], name) + for field in ("day", "graveyard_quality", "church_quality", "happiness"): + self.assertIn(field, card["proven"]) + self.assertEqual(card["fact_sources"][field], field) + + def test_quality_fields_declare_nonmonotonic(self): + card = read(HERE / "stage8_day117") + for field in ("graveyard_quality", "church_quality", "happiness"): + self.assertTrue(card["nonmonotonic"][field].strip()) + self.assertNotIn("day", card["nonmonotonic"]) + + def test_saved_at_is_parsed_and_increases(self): + times = [read(HERE / n)["progress"]["saved_at"] for n in sorted(HERE.glob("stage*"))] + self.assertTrue(all(isinstance(t, float) for t in times)) + self.assertEqual(times, sorted(times)) + + def test_unverified_fields_stay_hidden(self): + card = read(HERE / "stage8_day117") + self.assertEqual(card["progress"]["village_rep"], 17) # HUD reputation moved 0 -> 10 while this stayed 17: not the HUD value + self.assertEqual(card["progress"]["town_citizens"], 20) + for field in ("village_rep", "town_citizens"): + self.assertIn(field, card["unproven"]) + self.assertNotIn(field, card["proven"]) + self.assertIsNone(card["place"]) + + def test_directory_picks_newest_info(self): + card = read(HERE) + self.assertEqual(card["progress"]["day"], 117) + self.assertEqual(card["progress"]["church_quality"], 29) + self.assertEqual(card["progress"]["happiness"], 10) + + def test_info_without_dat_hides_happiness(self): + import shutil, tempfile + with tempfile.TemporaryDirectory() as tmp: + shutil.copy(HERE / "stage8_day117" / "Steam_1.info", tmp) + card = read(tmp) + self.assertEqual(card["progress"]["day"], 117) + self.assertIsNone(card["progress"]["happiness"]) + self.assertIn("happiness", card["unproven"]) + self.assertEqual([f["id"] for f in card["facts"]], ["day", "graveyard_quality", "church_quality"]) + + def test_missing_input_displays_nothing(self): + card = read(HERE / "does_not_exist.info") + self.assertEqual(card["facts"], []) + self.assertEqual(card["proven"], []) + + +if __name__ == "__main__": + unittest.main() diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..b596bca --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,10 @@ +{ + "facts": { + "graveyard_keeper_2": { + "day": "Day", + "graveyard_quality": "Graveyard", + "church_quality": "Church", + "happiness": "Happiness" + } + } +}