namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "flare_blitz")]
public class FlareBlitz : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var battleData = target.BattleData;
        if (battleData == null)
            return;

        var hitData = move.GetHitData(target, hit);
        var recoilDamage = hitData.Damage * (1 / 3);

        var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
        move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
        if (triggerArgs.Prevent)
            return;

        if (battleData.Battle.Random.EffectChance(10, move, target, hit))
        {
            target.SetStatus("burned", move.User);
        }

        move.User.Damage(recoilDamage, DamageSource.Misc);
    }
}