namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Poison Touch is an ability that may poison targets when the Pokémon uses a contact move.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Poison_Touch_(Ability)">Bulbapedia - Poison Touch</see>
/// </summary>
[Script(ScriptCategory.Ability, "poison_touch")]
public class PoisonTouch : Script, IScriptOnIncomingHit
{
    private const int PoisonChance = 30;

    /// <inheritdoc />
    public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.GetHitData(target, hit).IsContact && move.Battle.Random.GetInt(0, 100) < PoisonChance)
            move.User.SetStatus(ScriptUtils.ResolveName<Status.Poisoned>(), target);
    }
}