using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "outrage")]
public class Outrage : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.User.Volatile.Contains<OutrageEffect>())
            return;

        var battleData = move.User.BattleData;
        if (battleData == null)
            return;

        var turns = battleData.Battle.Random.GetBool() ? 2 : 3;
        move.User.Volatile.Add(new OutrageEffect(move.User, turns, move.MoveChoice.TargetSide,
            move.MoveChoice.TargetPosition));
    }
}