Deukhoofd defb1349ca
All checks were successful
Build / Build (push) Successful in 47s
Add EventHook parameter to item use scripts
Items can be used on Pokemon outside of battle, and we want the user of the library to be able to check for what changed. This allows for example a heal event to be sent back to the user of the library after using an item.
2025-06-15 11:59:17 +02:00

29 lines
763 B
C#

using PkmnLib.Dynamic.Events;
using PkmnLib.Dynamic.Models;
using PkmnLib.Static;
namespace PkmnLib.Dynamic.ScriptHandling;
/// <summary>
/// Base class for Pokéball scripts.
/// </summary>
public abstract class PokeballScript : ItemScript
{
/// <inheritdoc />
protected PokeballScript(IItem item) : base(item)
{
}
/// <summary>
/// Returns the catch rate of the Pokéball against the given target Pokémon.
/// </summary>
public abstract byte GetCatchRate(IPokemon target);
/// <inheritdoc />
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
{
var battleData = target.BattleData;
battleData?.Battle.AttempCapture(battleData.SideIndex, battleData.Position, Item);
}
}