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>
|
/// <summary>
|
||||||
/// Returns whether the item is usable on the given target.
|
/// Returns whether the item is usable on the given target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool IsTargetValid(IBattlePokemon target) => false;
|
public virtual bool IsTargetValid(IPokemon target) => false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns whether the item can be held by a Pokémon.
|
/// Returns whether the item can be held by a Pokémon.
|
||||||
@@ -51,7 +51,7 @@ public abstract class ItemScript : IDeepCloneable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns whether the item can be held by the given target.
|
/// Returns whether the item can be held by the given target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanTargetHold(IBattlePokemon pokemon) => true;
|
public virtual bool CanTargetHold(IPokemon pokemon) => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the use of the item.
|
/// Handles the use of the item.
|
||||||
@@ -63,7 +63,7 @@ public abstract class ItemScript : IDeepCloneable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the use of the item on the given target.
|
/// Handles the use of the item on the given target.
|
||||||
/// </summary>
|
/// </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;
|
public override ItemTargetType TargetType => ItemTargetType.FoePokemon;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool IsTargetValid(IBattlePokemon target) => target.Battle.IsWildBattle;
|
public override bool IsTargetValid(IPokemon target) => target is IBattlePokemon { Battle: { IsWildBattle: true } };
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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)
|
if (result.IsCaught)
|
||||||
{
|
{
|
||||||
OnAfterSuccessfulCapture(target);
|
OnAfterSuccessfulCapture(battlePokemon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ public class EvolutionItem : ItemScript
|
|||||||
public override ItemTargetType TargetType => ItemTargetType.OwnPokemon;
|
public override ItemTargetType TargetType => ItemTargetType.OwnPokemon;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool IsTargetValid(IBattlePokemon target)
|
public override bool IsTargetValid(IPokemon target)
|
||||||
{
|
{
|
||||||
foreach (var x in target.Species.EvolutionData)
|
foreach (var x in target.Species.EvolutionData)
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ public class EvolutionItem : ItemScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||||
{
|
{
|
||||||
var evolutionData = target.Species.EvolutionData.FirstOrDefault(x =>
|
var evolutionData = target.Species.EvolutionData.FirstOrDefault(x =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public class HealingItem : ItemScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool IsTargetValid(IBattlePokemon target) =>
|
public override bool IsTargetValid(IPokemon target) =>
|
||||||
!target.IsFainted && target.CurrentHealth < target.MaxHealth;
|
!target.IsFainted && target.CurrentHealth < target.MaxHealth;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||||
{
|
{
|
||||||
target.Heal(_healAmount, customEventHook: eventHook);
|
target.Heal(_healAmount, customEventHook: eventHook);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user