using System.Collections.Generic;
using NUnit.Framework;
using Sirenix.Utilities;
using Test.Util;
using UnityEditor;
using UnityEngine;
using VOID.ScriptableObjects.Abilities;

namespace Test.EditMode.GameData.Generic
{
    public class BasicAttackAbilityTest
    {
        private List<BasicAttackAbility> _abilities = new();

        [OneTimeSetUp]
        public void Setup()
        {
            AssetDatabase.FindAssets($"t:{nameof(BasicAttackAbility)}").ForEach(guid =>
            {
                var path = AssetDatabase.GUIDToAssetPath(guid);
                var ability = AssetDatabase.LoadAssetAtPath<BasicAttackAbility>(path);

                _abilities.Add(ability);
            });
        }

        [OneTimeTearDown]
        public void Cleanup()
        {
            _abilities.Clear();
            _abilities = null;
        }

        [Test]
        public void CastingAnimationList_IsEmpty()
        {
            _abilities.ForEach(ability =>
            {
                var assetPath = AssetDatabase.GetAssetPath(ability.GetInstanceID());
                var assetHyperLink = DebugLogUtil.Hyperlink(assetPath);
                if (ability.castingAnimationList)
                    Debug.LogError($"ScriptableObject: {assetHyperLink} casting animation is selected. Basic Attack dont use that",
                        ability);
            });
        }

        [Test]
        public void CastUsages_MustBeOne()
        {
            _abilities.ForEach(ability =>
            {
                var assetPath = AssetDatabase.GetAssetPath(ability.GetInstanceID());
                var assetHyperLink = DebugLogUtil.Hyperlink(assetPath);
                if (ability.castUsages != 1)
                    Debug.LogError($"ScriptableObject: {assetHyperLink} cast usages for basic attack must be 1.", ability);
            });
        }
    }
}

