37 lines
900 B
C#
37 lines
900 B
C#
using System.Collections.Generic;
|
|
using PkmnLib.Static;
|
|
using PkmnLib.Static.Utils;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Items;
|
|
|
|
/// <summary>
|
|
/// An implementation of a pokeball script that just has a flat catch rate bonus.
|
|
/// </summary>
|
|
[ItemScript("pokeball")]
|
|
public class StaticPokeball : PokeballScript
|
|
{
|
|
private byte _catchRate;
|
|
|
|
/// <inheritdoc />
|
|
public StaticPokeball(IItem item) : base(item)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
|
{
|
|
if (parameters == null || !parameters.TryGetValue("catchRate", out var catchRateObj) ||
|
|
catchRateObj is not byte catchRate)
|
|
{
|
|
catchRate = 1;
|
|
}
|
|
|
|
_catchRate = catchRate;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override byte GetCatchRate(IPokemon target)
|
|
{
|
|
return _catchRate;
|
|
}
|
|
} |