from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
FILES = {
    "AgrarianTypes.h": ROOT / "Source" / "AgrarianGame" / "AgrarianTypes.h",
    "AgrarianSurvivalComponent.h": ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.h",
    "AgrarianSurvivalComponent.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.cpp",
    "AgrarianSaveGame.h": ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h",
    "AgrarianDebugHUD.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianDebugHUD.cpp",
    "PersistenceDesignDocument.md": ROOT / "Docs" / "PersistenceDesignDocument.md",
}

CARE_FIELDS = [
    "NutritionQuality",
    "IllnessBurden",
    "InjuryBurden",
    "SleepQuality",
    "ShelterQuality",
    "StressBurden",
    "WorkloadBurden",
    "TreatmentQuality",
]

EXPECTED = {
    "AgrarianTypes.h": ["struct FAgrarianCareHistorySnapshot", *CARE_FIELDS],
    "AgrarianSurvivalComponent.h": [
        "FAgrarianCareHistorySnapshot CareHistory;",
        "void OnRep_CareHistory();",
        "void ClampCareHistory();",
    ],
    "AgrarianSurvivalComponent.cpp": [
        "DOREPLIFETIME(UAgrarianSurvivalComponent, CareHistory);",
        "void UAgrarianSurvivalComponent::OnRep_CareHistory()",
        "void UAgrarianSurvivalComponent::ClampCareHistory()",
        *CARE_FIELDS,
    ],
    "AgrarianSaveGame.h": ["FAgrarianCareHistorySnapshot CareHistory;"],
    "AgrarianDebugHUD.cpp": ["Care N/S/T", "Burden I/I/S/W"],
    "PersistenceDesignDocument.md": ["CareHistorySnapshot", "Care History Snapshot"],
}


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

    if missing:
        raise RuntimeError("Care history verification failed: " + "; ".join(missing))

    print("Agrarian care history field verification complete.")


if __name__ == "__main__":
    main()
