"""
Tier 1: Feature Coverage — Cocos Creator Resource Asset Bundle Integrity.
Validates that client/cocos/assets/resources/ contains all required game assets:
UI atlases, characters, monsters, weapons, currencies, map tiles, and VFX.
"""

from __future__ import annotations

from pathlib import Path
import pytest


class TestCocosResourceAssets:
    """Verifies that Cocos Creator has complete game assets in its resources bundle."""

    @pytest.fixture
    def resources_dir(self) -> Path:
        p = Path("client/cocos/assets/resources")
        assert p.exists(), "Cocos resources directory must exist"
        return p

    def test_essential_asset_categories_exist(self, resources_dir: Path) -> None:
        required_categories = [
            "animations",
            "banners",
            "characters",
            "currencies",
            "environment",
            "loading",
            "map",
            "monsters",
            "portraits",
            "savage_vfx",
            "shop",
            "skills",
            "ui",
            "vfx",
            "vltk1",
            "weapons",
        ]
        for cat in required_categories:
            cat_path = resources_dir / cat
            assert cat_path.is_dir(), f"Missing required resource category: {cat}"

    def test_ui_submodules_exist(self, resources_dir: Path) -> None:
        ui_modules = [
            "combat",
            "ascendancy",
            "dialogue",
            "endgame_atlas",
            "guild",
            "meridian",
            "quests",
            "security",
            "stash",
            "agent_orb",
        ]
        for mod in ui_modules:
            mod_path = resources_dir / "ui" / mod
            assert mod_path.is_dir(), f"Missing UI submodule: {mod}"

    def test_minimum_asset_file_count(self, resources_dir: Path) -> None:
        total_files = list(resources_dir.rglob("*.*"))
        assert len(total_files) >= 300, f"Expected >= 300 assets, found {len(total_files)}"

    def test_vfx_atlas_and_normal_exist(self, resources_dir: Path) -> None:
        vfx_dir = resources_dir / "vfx"
        assert (vfx_dir / "savage_primal_skills_vfx_atlas.png").exists()
        assert (vfx_dir / "savage_primal_skills_vfx_atlas.json").exists()
        assert (vfx_dir / "savage_primal_skills_vfx_atlas_normal.png").exists()
