using Sirenix.OdinInspector;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Abstract.Events;
using VOID.Generic.Objects.Weapon;
using VOID.Generic.Util;

namespace VOID.Generic.Status.Effect.Damage
{
    [TypeRegistryItem("Apply Weapon Damage")]
    public class WeaponDamageEffect : BasicEffect
    {
        public override void OnApply()
        {
            if (!source) return;

            var mainHandWeapon = source.unitEquipment.GetEquipped(EquipmentSlotType.MainHand) as WeaponObject;
            var weaponDamageType = mainHandWeapon ? mainHandWeapon.weaponData.damageType : DamageType.Physical;
            var damageMin = source.unitData.subAttributes.damageMin;
            var damageMax = source.unitData.subAttributes.damageMax;

            forObject.TakeDamage(new DamageEvent
            {
                target = forObject,
                attacker = source,
                amount = RandomUtil.RandomInteger(damageMin, damageMax),
                damageType = weaponDamageType
            });
        }
        public override void OnEnd() {}
        public override void OnTurnSelfEnd() {}
        public override void OnTurnSelfStart() {}
        public override void OnCancel() {}
        
        public override string GetSimpleDescription() => "?WEAPON_DAMAGE?";
    }
}