Deukhoofd 77d7b86a3c
All checks were successful
Build / Build (push) Successful in 1m2s
Implement most pokeballs
2025-07-20 11:15:45 +02:00

38 lines
1.1 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Items.Pokeballs;
/// <summary>
/// An implementation of a pokeball script that just has a flat catch rate bonus.
/// </summary>
[ItemScript("pokeball_flat_modifier")]
public class PokeballFlatModifier : PokeballScript
{
private float _catchModifier;
/// <inheritdoc />
public PokeballFlatModifier(IItem item) : base(item)
{
}
/// <inheritdoc />
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? 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;
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
{
catchRate = catchRate.MultiplyOrMax(_catchModifier);
}
}