Move itemscript back to using IPokemon instead of IBattlePokemon
All checks were successful
Build / Build (push) Successful in 3m24s
All checks were successful
Build / Build (push) Successful in 3m24s
This commit is contained in:
@@ -41,7 +41,7 @@ public abstract class ItemScript : IDeepCloneable
|
||||
/// <summary>
|
||||
/// Returns whether the item is usable on the given target.
|
||||
/// </summary>
|
||||
public virtual bool IsTargetValid(IBattlePokemon target) => false;
|
||||
public virtual bool IsTargetValid(IPokemon target) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the item can be held by a Pokémon.
|
||||
@@ -51,7 +51,7 @@ public abstract class ItemScript : IDeepCloneable
|
||||
/// <summary>
|
||||
/// Returns whether the item can be held by the given target.
|
||||
/// </summary>
|
||||
public virtual bool CanTargetHold(IBattlePokemon pokemon) => true;
|
||||
public virtual bool CanTargetHold(IPokemon pokemon) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the use of the item.
|
||||
@@ -63,7 +63,7 @@ public abstract class ItemScript : IDeepCloneable
|
||||
/// <summary>
|
||||
/// Handles the use of the item on the given target.
|
||||
/// </summary>
|
||||
public virtual void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
||||
public virtual void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,17 @@ public abstract class PokeballScript : ItemScript
|
||||
public override ItemTargetType TargetType => ItemTargetType.FoePokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IBattlePokemon target) => target.Battle.IsWildBattle;
|
||||
public override bool IsTargetValid(IPokemon target) => target is IBattlePokemon { Battle: { IsWildBattle: true } };
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
{
|
||||
var result = target.Battle.AttempCapture(target.SideIndex, target.Position, Item);
|
||||
if (target is not IBattlePokemon battlePokemon)
|
||||
return;
|
||||
var result = battlePokemon.Battle.AttempCapture(battlePokemon.SideIndex, battlePokemon.Position, Item);
|
||||
if (result.IsCaught)
|
||||
{
|
||||
OnAfterSuccessfulCapture(target);
|
||||
OnAfterSuccessfulCapture(battlePokemon);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user