from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]

EXPECTED = {
    ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h": [
        "float WorldHours = 8.0f;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.cpp": [
        "SaveGame->WorldHours = GameState->WorldHours;",
        "GameState->WorldHours = SaveGame->WorldHours;",
        "!GameState->HasAuthority()",
    ],
    ROOT / "Docs" / "PersistenceDesignDocument.md": [
        "`UAgrarianSaveGame::WorldHours`",
        "`AAgrarianGameState::WorldHours`",
        "restores it only on authority",
    ],
    ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Save world time.",
        "`UAgrarianSaveGame::WorldHours`",
        "restore it on server authority",
    ],
}


def main() -> None:
    missing = []
    for path, snippets in EXPECTED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)}: {snippet}")

    if missing:
        raise RuntimeError("World time persistence verification failed: " + "; ".join(missing))

    print("PASS: world time persists through the authoritative world save state.")


if __name__ == "__main__":
    main()
