Lots more work on implementing battling

This commit is contained in:
2024-08-10 09:44:46 +02:00
parent 554e1cf2cd
commit a049dda240
29 changed files with 1226 additions and 48 deletions

View File

@@ -2,8 +2,12 @@ using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a Pokemon takes damage.
/// </summary>
public record DamageEvent : IEventData
{
/// <inheritdoc cref="DamageEvent"/>
public DamageEvent(IPokemon pokemon, uint previousHealth, uint newHealth, DamageSource source)
{
Pokemon = pokemon;
@@ -12,9 +16,24 @@ public record DamageEvent : IEventData
Source = source;
}
/// <summary>
/// The Pokemon that took damage.
/// </summary>
public IPokemon Pokemon { get; init; }
/// <summary>
/// The previous health of the Pokemon.
/// </summary>
public uint PreviousHealth { get; init; }
/// <summary>
/// The new health of the Pokemon.
/// </summary>
public uint NewHealth { get; init; }
/// <summary>
/// The source of the damage.
/// </summary>
public DamageSource Source { get; init; }
/// <inheritdoc />

View File

@@ -0,0 +1,7 @@
namespace PkmnLib.Dynamic.Events;
public class EndTurnEvent : IEventData
{
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}

View File

@@ -2,13 +2,20 @@ using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a Pokemon faints.
/// </summary>
public class FaintEvent : IEventData
{
/// <inheritdoc cref="FaintEvent"/>
public FaintEvent(IPokemon pokemon)
{
Pokemon = pokemon;
}
/// <summary>
/// The Pokemon that fainted.
/// </summary>
public IPokemon Pokemon { get; init; }
/// <inheritdoc />

View File

@@ -7,5 +7,9 @@ namespace PkmnLib.Dynamic.Events;
/// </summary>
public interface IEventData
{
/// <summary>
/// The batch ID indicated which batch of events this belong to. Events with the same batch id
/// should be displayed together.
/// </summary>
public EventBatchId BatchId { get; init; }
}

View File

@@ -2,8 +2,12 @@ using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a Pokemon is healed.
/// </summary>
public class HealEvent : IEventData
{
/// <inheritdoc cref="HealEvent"/>
public HealEvent(IPokemon pokemon, uint previousHealth, uint newHealth)
{
Pokemon = pokemon;
@@ -11,11 +15,22 @@ public class HealEvent : IEventData
NewHealth = newHealth;
}
/// <summary>
/// The Pokemon that was healed.
/// </summary>
public IPokemon Pokemon { get; }
/// <summary>
/// The previous health of the Pokemon.
/// </summary>
public uint PreviousHealth { get; }
/// <summary>
/// The new health of the Pokemon.
/// </summary>
public uint NewHealth { get; }
/// <inheritdoc />
public EventBatchId BatchId { get; init; } = new();
}

View File

@@ -0,0 +1,47 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Static;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Triggered when a Pokemon's stat boost is changed, either positively or negatively.
/// </summary>
public class StatBoostEvent : IEventData
{
/// <inheritdoc cref="StatBoostEvent" />
public StatBoostEvent(IPokemon pokemon, Statistic statistic, sbyte oldBoost, sbyte newBoost)
{
Pokemon = pokemon;
Statistic = statistic;
OldBoost = oldBoost;
NewBoost = newBoost;
}
/// <summary>
/// The Pokemon that had its stat boosted.
/// </summary>
public IPokemon Pokemon { get; }
/// <summary>
/// The statistic that was boosted.
/// </summary>
public Statistic Statistic { get; }
/// <summary>
/// The old boost value.
/// </summary>
public sbyte OldBoost { get; }
/// <summary>
/// The new boost value.
/// </summary>
public sbyte NewBoost { get; }
/// <summary>
/// The difference between the new and old boost values.
/// </summary>
public sbyte BoostDifference => (sbyte)(NewBoost - OldBoost);
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}

View File

@@ -0,0 +1,35 @@
using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a Pokémon is switched in.
/// </summary>
public class SwitchEvent : IEventData
{
/// <inheritdoc cref="SwitchEvent"/>
public SwitchEvent(byte sideIndex, byte position, IPokemon? pokemon)
{
SideIndex = sideIndex;
Position = position;
Pokemon = pokemon;
}
/// <summary>
/// The index of the side that the Pokémon is switching in on.
/// </summary>
public byte SideIndex { get; init; }
/// <summary>
/// The position that the Pokémon is switching in to.
/// </summary>
public byte Position { get; init; }
/// <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; }
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}