namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "struggle")]
public class Struggle : Script, IScriptChangeNumberOfHits, IScriptIsInvulnerableToMove, IScriptChangeEffectiveness,
    IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
    {
        numberOfHits = 1;
    }

    /// <inheritdoc />
    public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
    {
        invulnerable = false;
    }

    /// <inheritdoc />
    public void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
    {
        effectiveness = 1;
    }

    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var damage = move.User.MaxHealth / 4;
        if (damage == 0)
            damage = 1;
        move.User.Damage(damage, DamageSource.Struggle, new EventBatchId());
    }
}