using System; using System.Collections.Generic; using System.Linq; using PkmnLib.Static; using PkmnLib.Static.Utils; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "change_multiple_user_stat_boosts")] public class ChangeMultipleUserStatBoosts : Script { private Dictionary<Statistic, sbyte> _statBoosts = new(); /// <inheritdoc /> public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } foreach (var par in parameters) { if (!Enum.TryParse<Statistic>(par.Key, true, out var stat)) throw new ArgumentException($"Invalid stat name: {par.Key}"); if (par.Value is sbyte value) { _statBoosts[stat] = value; } } } /// <inheritdoc /> public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) { EventBatchId batchId = new(); foreach (var stat in _statBoosts!) { move.User.ChangeStatBoost(stat.Key, stat.Value, true, batchId); } } }