namespace PkmnLib.Plugin.Gen7.Scripts.Items.Pokeballs; /// /// An implementation of a pokeball script that just has a flat catch rate bonus. /// [ItemScript("pokeball_flat_modifier")] public class PokeballFlatModifier : PokeballScript { private float _catchModifier; /// public PokeballFlatModifier(IItem item) : base(item) { } /// public override void OnInitialize(IReadOnlyDictionary? parameters) { var catchModifier = 1f; if (parameters != null && parameters.TryGetValue("catchRate", out var catchRateObj)) { catchModifier = catchRateObj switch { float catchModifierFloat => catchModifierFloat, int catchModifierInt => catchModifierInt, _ => catchModifier, }; } _catchModifier = catchModifier; } /// public override void ChangeCatchRate(IPokemon target, ref byte catchRate) { catchRate = catchRate.MultiplyOrMax(_catchModifier); } }