using PkmnLib.Plugin.Gen7.Scripts.Side;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "mat_block")]
public class MatBlock : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var battleData = move.User.BattleData;
        if (battleData == null)
            return;
        if (battleData.SwitchInTurn != battleData.Battle.CurrentTurnNumber)
        {
            move.GetHitData(target, hit).Fail();
            return;
        }

        battleData.BattleSide.VolatileScripts.Add(new MatBlockEffect());
    }
}