namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Flame Body is an ability that has a 30% chance of burning the attacker when hit by a contact move.
/// This ability is similar to Effect Spore and Static, but inflicts burn instead of other status conditions.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flame_Body_(Ability)">Bulbapedia - Flame Body</see>
/// </summary>
[Script(ScriptCategory.Ability, "flame_body")]
public class FlameBody : Script, IScriptOnIncomingHit
{
    /// <inheritdoc />
    public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
    {
        if (!move.GetHitData(target, hit).IsContact)
            return;

        var rng = move.Battle.Random;
        if (rng.GetInt(0, 100) >= 30) // 30% chance
            return;

        move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
        move.User.SetStatus(ScriptUtils.ResolveName<Status.Burned>(), move.User);
    }
}