from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
FILES = {
    "setup_item_definitions.py": ROOT / "Scripts" / "setup_item_definitions.py",
    "setup_playable_blueprints.py": ROOT / "Scripts" / "setup_playable_blueprints.py",
    "setup_ground_zero_demo_map.py": ROOT / "Scripts" / "setup_ground_zero_demo_map.py",
    "verify_playable_blueprints.py": ROOT / "Scripts" / "verify_playable_blueprints.py",
    "verify_ground_zero_resources.py": ROOT / "Scripts" / "verify_ground_zero_resources.py",
    "GroundZeroResourcePass.md": ROOT / "Docs" / "Terrain" / "GroundZeroResourcePass.md",
    "TechnicalDesignDocument.md": ROOT / "Docs" / "TechnicalDesignDocument.md",
    "AGRARIAN_DEVELOPMENT_ROADMAP.md": ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md",
}

EXPECTED = {
    "setup_item_definitions.py": [
        '"asset": "DA_Item_Food"',
        '"item_id": "food"',
        '"item_type": unreal.AgrarianItemType.FOOD',
    ],
    "setup_playable_blueprints.py": [
        'FOOD_ITEM_PATH = "/Game/Agrarian/DataAssets/Items/DA_Item_Food"',
        '"asset": "BP_EdiblePlantResourceNode"',
        '"yield_item_definition": FOOD_ITEM_PATH',
        '"remaining_harvests": 8',
        '"quantity_per_harvest": 1',
    ],
    "setup_ground_zero_demo_map.py": [
        '"edible_plant_resource"',
        '"/Game/Agrarian/Blueprints/Resources/BP_EdiblePlantResourceNode"',
        '"AGR_GZ_EdiblePlant_CoastalScrub_01"',
        '"AGR_GZ_EdiblePlant_Grassland_02"',
        '"AGR_GZ_EdiblePlant_DrainageCandidate_03"',
    ],
    "verify_playable_blueprints.py": [
        '"/Game/Agrarian/Blueprints/Resources/BP_EdiblePlantResourceNode"',
        '"yield_item_id": "food"',
    ],
    "verify_ground_zero_resources.py": [
        '"food": [',
        '"AGR_GZ_EdiblePlant_CoastalScrub_01"',
        "edible plant",
    ],
    "GroundZeroResourcePass.md": [
        "Edible plants:",
        "`food` item",
        "Added `BP_EdiblePlantResourceNode`",
        "Edible plant nodes: `3`",
    ],
    "TechnicalDesignDocument.md": [
        "edible plants",
        "`BP_EdiblePlantResourceNode`",
        "MVP `food` item",
        "forage patches",
    ],
    "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Add edible plant resource.",
        "`BP_EdiblePlantResourceNode`",
        "Ground Zero forage nodes",
    ],
}


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("Edible plant resource verification failed: " + "; ".join(missing))

    print("Agrarian edible plant resource verification complete.")


if __name__ == "__main__":
    main()
