using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "spit_up")]
public class SpitUp : Script, IScriptChangeBasePower
{
    /// <inheritdoc />
    public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
    {
        var stockpileEffect = move.User.Volatile.Get<StockpileEffect>();
        if (stockpileEffect == null || stockpileEffect.StockpileCount == 0)
        {
            move.GetHitData(target, hit).Fail();
            return;
        }
        var stockpileCount = stockpileEffect.StockpileCount;
        basePower = basePower.MultiplyOrMax(stockpileCount);
        move.User.Volatile.Remove<StockpileEffect>();
    }
}