Implementation of Pokeballs
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Items;
|
||||
@@ -11,6 +12,11 @@ public class HealingItem : ItemScript
|
||||
{
|
||||
private uint _healAmount;
|
||||
|
||||
/// <inheritdoc />
|
||||
public HealingItem(IItem item) : base(item)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsItemUsable => true;
|
||||
|
||||
|
||||
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Items/StaticPokeball.cs
Normal file
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Items/StaticPokeball.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user