using PkmnLib.Dynamic.Events;
using PkmnLib.Dynamic.Models;
using PkmnLib.Static;
namespace PkmnLib.Dynamic.ScriptHandling;
///
/// Base class for Pokéball scripts.
///
public abstract class PokeballScript : ItemScript
{
///
protected PokeballScript(IItem item) : base(item)
{
}
///
/// Returns the catch rate of the Pokéball against the given target Pokémon.
///
public abstract void ChangeCatchRate(IBattlePokemon target, ref byte catchRate);
public virtual void OnAfterSuccessfulCapture(IBattlePokemon target)
{
// Default implementation does nothing.
// Override this method in derived classes to add custom behavior after a successful capture.
}
///
public override bool IsItemUsable => true;
///
public override ItemTargetType TargetType => ItemTargetType.FoePokemon;
///
public override bool IsTargetValid(IBattlePokemon target) => target.Battle.IsWildBattle;
///
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
{
var result = target.Battle.AttempCapture(target.SideIndex, target.Position, Item);
if (result.IsCaught)
{
OnAfterSuccessfulCapture(target);
}
}
}