using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "fake_out")]
public class FakeOut : Script, IScriptStopBeforeMove, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void StopBeforeMove(IExecutingMove move, ref bool stop)
    {
        var battleData = move.User.BattleData;
        if (battleData == null)
            return;
        if (battleData.SwitchInTurn != battleData.Battle.CurrentTurnNumber)
            stop = true;
    }

    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        target.Volatile.Add(new FlinchEffect());
    }
}