Tweaks and fixes for Pokemon capture
All checks were successful
Build / Build (push) Successful in 1m34s
All checks were successful
Build / Build (push) Successful in 1m34s
This commit is contained in:
parent
cccffc4954
commit
a5675024a4
@ -1,5 +1,6 @@
|
|||||||
using PkmnLib.Dynamic.Libraries;
|
using PkmnLib.Dynamic.Libraries;
|
||||||
using PkmnLib.Dynamic.Models;
|
using PkmnLib.Dynamic.Models;
|
||||||
|
using PkmnLib.Static;
|
||||||
|
|
||||||
namespace PkmnLib.Dynamic.Events;
|
namespace PkmnLib.Dynamic.Events;
|
||||||
|
|
||||||
@ -9,10 +10,11 @@ namespace PkmnLib.Dynamic.Events;
|
|||||||
public class CaptureAttemptEvent : IEventData
|
public class CaptureAttemptEvent : IEventData
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="CaptureAttemptEvent"/>
|
/// <inheritdoc cref="CaptureAttemptEvent"/>
|
||||||
public CaptureAttemptEvent(IPokemon target, CaptureResult result)
|
public CaptureAttemptEvent(IPokemon target, CaptureResult result, IItem captureItem)
|
||||||
{
|
{
|
||||||
Target = target;
|
Target = target;
|
||||||
Result = result;
|
Result = result;
|
||||||
|
CaptureItem = captureItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -25,6 +27,11 @@ public class CaptureAttemptEvent : IEventData
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CaptureResult Result { get; init; }
|
public CaptureResult Result { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The item used to attempt the capture (e.g., a Poké Ball).
|
||||||
|
/// </summary>
|
||||||
|
public IItem CaptureItem { get; init; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public EventBatchId BatchId { get; init; }
|
public EventBatchId BatchId { get; init; }
|
||||||
}
|
}
|
@ -533,7 +533,15 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
var side = Sides[target.BattleData!.SideIndex];
|
var side = Sides[target.BattleData!.SideIndex];
|
||||||
side.ForceClearPokemonFromField(target.BattleData.Position);
|
side.ForceClearPokemonFromField(target.BattleData.Position);
|
||||||
}
|
}
|
||||||
EventHook.Invoke(new CaptureAttemptEvent(target, attemptCapture));
|
EventHook.Invoke(new CaptureAttemptEvent(target, attemptCapture, item));
|
||||||
|
|
||||||
|
if (!CanSlotBeFilled(sideIndex, position))
|
||||||
|
{
|
||||||
|
Sides[sideIndex].MarkPositionAsUnfillable(position);
|
||||||
|
}
|
||||||
|
Sides[sideIndex].ForceClearPokemonFromField(position);
|
||||||
|
|
||||||
|
ValidateBattleState();
|
||||||
return attemptCapture;
|
return attemptCapture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,16 @@ public abstract class PokeballScript : ItemScript
|
|||||||
// Override this method in derived classes to add custom behavior after a successful capture.
|
// Override this method in derived classes to add custom behavior after a successful capture.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool IsItemUsable => true;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool RequiresTarget => true;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool IsTargetValid(IPokemon target) =>
|
||||||
|
target.BattleData is not null && target.BattleData.Battle.IsWildBattle;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user