Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -12,7 +12,7 @@ public record AbilityTriggerEvent : IEventData
/// <summary>
/// The Pokémon whose ability is being triggered.
/// </summary>
public IPokemon Pokemon { get; }
public IBattlePokemon Pokemon { get; }
/// <summary>
/// The ability that is being triggered for the Pokémon.
@@ -22,7 +22,7 @@ public record AbilityTriggerEvent : IEventData
public Dictionary<StringKey, object?>? Metadata { get; init; } = null;
/// <inheritdoc cref="AbilityTriggerEvent"/>
public AbilityTriggerEvent(IPokemon pokemon)
public AbilityTriggerEvent(IBattlePokemon pokemon)
{
Pokemon = pokemon;
Ability = pokemon.ActiveAbility;

View File

@@ -10,7 +10,7 @@ namespace PkmnLib.Dynamic.Events;
public class CaptureAttemptEvent : IEventData
{
/// <inheritdoc cref="CaptureAttemptEvent"/>
public CaptureAttemptEvent(IPokemon target, CaptureResult result, IItem captureItem)
public CaptureAttemptEvent(IBattlePokemon target, CaptureResult result, IItem captureItem)
{
Target = target;
Result = result;
@@ -20,7 +20,7 @@ public class CaptureAttemptEvent : IEventData
/// <summary>
/// The Pokémon that is being captured.
/// </summary>
public IPokemon Target { get; init; }
public IBattlePokemon Target { get; init; }
/// <summary>
/// The result of the capture attempt.

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.Events;
public record DamageEvent : IEventData
{
/// <inheritdoc cref="DamageEvent"/>
public DamageEvent(IPokemon pokemon, uint previousHealth, uint newHealth, DamageSource source)
public DamageEvent(IBattlePokemon pokemon, uint previousHealth, uint newHealth, DamageSource source)
{
Pokemon = pokemon;
PreviousHealth = previousHealth;
@@ -19,7 +19,7 @@ public record DamageEvent : IEventData
/// <summary>
/// The Pokemon that took damage.
/// </summary>
public IPokemon Pokemon { get; init; }
public IBattlePokemon Pokemon { get; init; }
/// <summary>
/// The previous health of the Pokemon.

View File

@@ -5,11 +5,11 @@ namespace PkmnLib.Dynamic.Events;
public class DisplaySpeciesChangeEvent : IEventData
{
public IPokemon Pokemon { get; }
public IBattlePokemon Pokemon { get; }
public ISpecies? Species { get; }
public IForm? Form { get; }
public DisplaySpeciesChangeEvent(IPokemon pokemon, ISpecies? species, IForm? form)
public DisplaySpeciesChangeEvent(IBattlePokemon pokemon, ISpecies? species, IForm? form)
{
Pokemon = pokemon;
Species = species;

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.Events;
public class FaintEvent : IEventData
{
/// <inheritdoc cref="FaintEvent"/>
public FaintEvent(IPokemon pokemon)
public FaintEvent(IBattlePokemon pokemon)
{
Pokemon = pokemon;
}
@@ -16,7 +16,7 @@ public class FaintEvent : IEventData
/// <summary>
/// The Pokemon that fainted.
/// </summary>
public IPokemon Pokemon { get; init; }
public IBattlePokemon Pokemon { get; init; }
/// <inheritdoc />
public EventBatchId BatchId { get; init; } = new();

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.Events;
public class FleeEvent : IEventData
{
/// <inheritdoc cref="FleeEvent"/>
public FleeEvent(IPokemon pokemon, bool success)
public FleeEvent(IBattlePokemon pokemon, bool success)
{
Pokemon = pokemon;
Success = success;
@@ -17,7 +17,7 @@ public class FleeEvent : IEventData
/// <summary>
/// The Pokémon that attempted to flee.
/// </summary>
public IPokemon Pokemon { get; }
public IBattlePokemon Pokemon { get; }
/// <summary>
/// Indicates whether the flee attempt was successful.

View File

@@ -5,13 +5,13 @@ namespace PkmnLib.Dynamic.Events;
public record ItemUseEvent : IEventData
{
public ItemUseEvent(IPokemon pokemon, IItem itemUsed)
public ItemUseEvent(IBattlePokemon pokemon, IItem itemUsed)
{
Pokemon = pokemon;
ItemUsed = itemUsed;
}
public IPokemon Pokemon { get; set; }
public IBattlePokemon Pokemon { get; set; }
public IItem ItemUsed { get; set; }
/// <inheritdoc />

View File

@@ -20,10 +20,10 @@ public class MoveHitEvent : IEventData
/// <summary>
/// The target of the move.
/// </summary>
public IPokemon Target { get; }
public IBattlePokemon Target { get; }
/// <inheritdoc cref="MoveHitEvent"/>
public MoveHitEvent(IExecutingMove executingMove, IHitData hitData, IPokemon target)
public MoveHitEvent(IExecutingMove executingMove, IHitData hitData, IBattlePokemon target)
{
ExecutingMove = executingMove;
HitData = hitData;

View File

@@ -5,9 +5,9 @@ namespace PkmnLib.Dynamic.Events;
public class MoveInvulnerableEvent : IEventData
{
public IExecutingMove ExecutingMove { get; }
public IPokemon Target { get; }
public IBattlePokemon Target { get; }
public MoveInvulnerableEvent(IExecutingMove executingMove, IPokemon target)
public MoveInvulnerableEvent(IExecutingMove executingMove, IBattlePokemon target)
{
ExecutingMove = executingMove;
Target = target;

View File

@@ -9,7 +9,7 @@ namespace PkmnLib.Dynamic.Events;
public class StatBoostEvent : IEventData
{
/// <inheritdoc cref="StatBoostEvent" />
public StatBoostEvent(IPokemon pokemon, Statistic statistic, sbyte oldBoost, sbyte newBoost)
public StatBoostEvent(IBattlePokemon pokemon, Statistic statistic, sbyte oldBoost, sbyte newBoost)
{
Pokemon = pokemon;
Statistic = statistic;
@@ -20,7 +20,7 @@ public class StatBoostEvent : IEventData
/// <summary>
/// The Pokemon that had its stat boosted.
/// </summary>
public IPokemon Pokemon { get; }
public IBattlePokemon Pokemon { get; }
/// <summary>
/// The statistic that was boosted.

View File

@@ -9,7 +9,7 @@ namespace PkmnLib.Dynamic.Events;
public record StatusChangeEvent : IEventData
{
/// <inheritdoc cref="StatusChangeEvent"/>
public StatusChangeEvent(IPokemon pokemon, StringKey? previousStatus, StringKey? newStatus)
public StatusChangeEvent(IBattlePokemon pokemon, StringKey? previousStatus, StringKey? newStatus)
{
Pokemon = pokemon;
PreviousStatus = previousStatus;
@@ -19,7 +19,7 @@ public record StatusChangeEvent : IEventData
/// <summary>
/// The Pokémon whose status has changed.
/// </summary>
public IPokemon Pokemon { get; }
public IBattlePokemon Pokemon { get; }
/// <summary>
/// The new status of the Pokémon after the change.

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.Events;
public class SwitchEvent : IEventData
{
/// <inheritdoc cref="SwitchEvent"/>
public SwitchEvent(byte sideIndex, byte position, IPokemon? pokemon)
public SwitchEvent(byte sideIndex, byte position, IBattlePokemon? pokemon)
{
SideIndex = sideIndex;
Position = position;
@@ -28,7 +28,7 @@ public class SwitchEvent : IEventData
/// <summary>
/// The Pokémon that is switching in. If null, no Pokémon is switching in, and the slot is empty after the switch.
/// </summary>
public IPokemon? Pokemon { get; init; }
public IBattlePokemon? Pokemon { get; init; }
/// <inheritdoc />
public EventBatchId BatchId { get; init; }