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

39 lines
1.1 KiB
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 void ChangeCatchRate(IPokemon target, ref byte catchRate);
public virtual void OnAfterSuccessfulCapture(IPokemon target)
{
// Default implementation does nothing.
// Override this method in derived classes to add custom behavior after a successful capture.
}
/// <inheritdoc />
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
{
var battleData = target.BattleData;
var result = battleData?.Battle.AttempCapture(battleData.SideIndex, battleData.Position, Item);
if (result is { IsCaught: true })
{
OnAfterSuccessfulCapture(target);
}
}
}