from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
HEADER = ROOT / "Source" / "AgrarianGame" / "AgrarianGameCharacter.h"
SOURCE = ROOT / "Source" / "AgrarianGame" / "AgrarianGameCharacter.cpp"


EXPECTED_HEADER_SNIPPETS = [
    "ReplicatedUsing = OnRep_SprintState",
    "ReplicatedUsing = OnRep_ProneState",
    "ReplicatedUsing = OnRep_MovementModifierState",
    "void OnRep_MovementModifierState();",
    "void ServerSetWantsToSprint(bool bNewWantsToSprint);",
    "void ServerSetProne(bool bNewProne);",
    "void ServerSetTerrainMovementMultiplier(float NewTerrainMovementMultiplier);",
]

EXPECTED_SOURCE_SNIPPETS = [
    "bReplicates = true;",
    "SetReplicateMovement(true);",
    "DOREPLIFETIME(AAgrarianGameCharacter, bWantsToSprint);",
    "DOREPLIFETIME(AAgrarianGameCharacter, bIsProne);",
    "DOREPLIFETIME(AAgrarianGameCharacter, AgeYears);",
    "DOREPLIFETIME(AAgrarianGameCharacter, PhysicalConditionMultiplier);",
    "DOREPLIFETIME(AAgrarianGameCharacter, StrengthMultiplier);",
    "DOREPLIFETIME(AAgrarianGameCharacter, EnduranceMultiplier);",
    "DOREPLIFETIME(AAgrarianGameCharacter, TerrainMovementMultiplier);",
    "void AAgrarianGameCharacter::OnRep_SprintState()",
    "void AAgrarianGameCharacter::OnRep_ProneState()",
    "void AAgrarianGameCharacter::OnRep_MovementModifierState()",
    "void AAgrarianGameCharacter::ServerSetWantsToSprint_Implementation",
    "void AAgrarianGameCharacter::ServerSetProne_Implementation",
    "void AAgrarianGameCharacter::ServerSetTerrainMovementMultiplier_Implementation",
]


def assert_contains(label, text, snippets):
    missing = [snippet for snippet in snippets if snippet not in text]
    if missing:
        raise RuntimeError(f"{label} is missing expected replication snippets: {missing}")


def main():
    header_text = HEADER.read_text(encoding="utf-8")
    source_text = SOURCE.read_text(encoding="utf-8")

    assert_contains("AgrarianGameCharacter.h", header_text, EXPECTED_HEADER_SNIPPETS)
    assert_contains("AgrarianGameCharacter.cpp", source_text, EXPECTED_SOURCE_SNIPPETS)

    print("Agrarian player core replication verification complete.")


if __name__ == "__main__":
    main()
