Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -17,9 +17,9 @@ public abstract class PokeballScript : ItemScript
|
||||
/// <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 abstract void ChangeCatchRate(IBattlePokemon target, ref byte catchRate);
|
||||
|
||||
public virtual void OnAfterSuccessfulCapture(IPokemon target)
|
||||
public virtual void OnAfterSuccessfulCapture(IBattlePokemon target)
|
||||
{
|
||||
// Default implementation does nothing.
|
||||
// Override this method in derived classes to add custom behavior after a successful capture.
|
||||
@@ -32,16 +32,13 @@ public abstract class PokeballScript : ItemScript
|
||||
public override ItemTargetType TargetType => ItemTargetType.FoePokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IPokemon target) =>
|
||||
target.BattleData is not null && target.BattleData.Battle.IsWildBattle;
|
||||
public override bool IsTargetValid(IBattlePokemon target) => target.Battle.IsWildBattle;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
|
||||
var result = battleData?.Battle.AttempCapture(battleData.SideIndex, battleData.Position, Item);
|
||||
if (result is { IsCaught: true })
|
||||
var result = target.Battle.AttempCapture(target.SideIndex, target.Position, Item);
|
||||
if (result.IsCaught)
|
||||
{
|
||||
OnAfterSuccessfulCapture(target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user