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_Stone"',
        '"item_id": "stone"',
        "Field stone suitable for crude tools",
        '"unit_weight": 1.5',
    ],
    "setup_playable_blueprints.py": [
        'STONE_ITEM_PATH = "/Game/Agrarian/DataAssets/Items/DA_Item_Stone"',
        '"asset": "BP_StoneResourceNode"',
        '"yield_item_definition": STONE_ITEM_PATH',
        '"remaining_harvests": 12',
        '"quantity_per_harvest": 2',
    ],
    "setup_ground_zero_demo_map.py": [
        '"/Game/Agrarian/Blueprints/Resources/BP_StoneResourceNode"',
        '"AGR_GZ_Stone_Slope_01"',
        '"AGR_GZ_Stone_Slope_02"',
        '"AGR_GZ_Stone_ExposedTerrain_03"',
        '"AGR_GZ_Stone_ValleyEdge_04"',
    ],
    "verify_playable_blueprints.py": [
        '"/Game/Agrarian/Blueprints/Resources/BP_StoneResourceNode"',
        '"yield_item_id": "stone"',
    ],
    "verify_ground_zero_resources.py": [
        '"stone": [',
        '"AGR_GZ_Stone_Slope_01"',
        'f"{len(EXPECTED_RESOURCE_LABELS[\'stone\'])} stone nodes."',
    ],
    "GroundZeroResourcePass.md": [
        "- Stone: slope, exposed terrain, and valley-edge areas.",
        "Added `BP_StoneResourceNode`",
        "Stone nodes: `4`",
    ],
    "TechnicalDesignDocument.md": [
        "### Gatherable Resources",
        "`AAgrarianResourceNode`",
        "`DA_Item_Stone`",
        "`BP_StoneResourceNode`",
        "primitive tools, campfires, and early",
        "construction recipes",
    ],
    "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Add stone resource.",
        "`DA_Item_Stone`",
        "`BP_StoneResourceNode`",
        "Ground Zero resource pass",
    ],
}


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

    print("Agrarian stone resource verification complete.")


if __name__ == "__main__":
    main()
