38 lines
1.1 KiB
C#
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);
|
|
}
|
|
} |