from pathlib import Path


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

EXPECTED = {
    ROOT / "Source" / "AgrarianGame" / "AgrarianTypes.h": [
        "struct FAgrarianSurvivalSnapshot",
        "float Health = 100.0f;",
        "float Stamina = 100.0f;",
        "float Exhaustion = 0.0f;",
        "float Hunger = 100.0f;",
        "float Thirst = 100.0f;",
        "float BodyTemperature = 37.0f;",
        "float InjurySeverity = 0.0f;",
        "float BleedingSeverity = 0.0f;",
        "float SprainSeverity = 0.0f;",
        "float SicknessSeverity = 0.0f;",
        "bool bIsDead = false;",
        "FName LastDeathReason = NAME_None;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h": [
        "FAgrarianSurvivalSnapshot Survival;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.cpp": [
        "SavedPlayer.Survival = SurvivalComponent->Survival;",
        "SurvivalComponent->ApplySavedState(SavedPlayer->Survival, SavedPlayer->CareHistory);",
    ],
    ROOT / "Docs" / "PersistenceDesignDocument.md": [
        "`FAgrarianSavedPlayer::Survival`",
        "The MVP stat save includes health",
        "bleeding, sprain, sickness, death state, and death reason",
        "`UAgrarianSurvivalComponent::ApplySavedState`",
    ],
    ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Save player stats.",
        "`FAgrarianSavedPlayer::Survival`",
        "state, and death reason",
    ],
}


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("Player stats persistence verification failed: " + "; ".join(missing))

    print("PASS: player stats persist through the saved survival snapshot.")


if __name__ == "__main__":
    main()
