Implements move execution for battle

This commit is contained in:
2024-08-10 11:18:10 +02:00
parent a049dda240
commit 488c717c5a
17 changed files with 433 additions and 14 deletions

View File

@@ -1,5 +1,8 @@
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a turn ends.
/// </summary>
public class EndTurnEvent : IEventData
{
/// <inheritdoc />

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.Events;
/// For example, when a Pokemon gets hurt by poison, we want to show the purple poison animation and the damage at the
/// same time. This is done by batching the events together.
/// </remarks>
public record struct EventBatchId()
public readonly record struct EventBatchId()
{
/// <summary>
/// The unique identifier for this batch of events.

View File

@@ -0,0 +1,35 @@
using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Event triggered when a move hits.
/// </summary>
public class MoveHitEvent : IEventData
{
/// <summary>
/// The move that is being executed.
/// </summary>
public IExecutingMove ExecutingMove { get; }
/// <summary>
/// Data about the hit.
/// </summary>
public IHitData HitData { get; }
/// <summary>
/// The target of the move.
/// </summary>
public IPokemon Target { get; }
/// <inheritdoc cref="MoveHitEvent"/>
public MoveHitEvent(IExecutingMove executingMove, IHitData hitData, IPokemon target)
{
ExecutingMove = executingMove;
HitData = hitData;
Target = target;
}
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}

View File

@@ -0,0 +1,23 @@
using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Triggered when a move misses.
/// </summary>
public class MoveMissEvent : IEventData
{
/// <inheritdoc cref="MoveMissEvent"/>
public MoveMissEvent(IExecutingMove executingMove)
{
ExecutingMove = executingMove;
}
/// <summary>
/// Data about the move that missed.
/// </summary>
public IExecutingMove ExecutingMove { get; }
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}

View File

@@ -0,0 +1,23 @@
using PkmnLib.Dynamic.Models;
namespace PkmnLib.Dynamic.Events;
/// <summary>
/// Runs when a move is used, before the move is executed.
/// </summary>
public class MoveUseEvent : IEventData
{
/// <summary>
/// The move that is being executed.
/// </summary>
public IExecutingMove ExecutingMove { get; }
/// <inheritdoc cref="MoveUseEvent"/>
public MoveUseEvent(IExecutingMove executingMove)
{
ExecutingMove = executingMove;
}
/// <inheritdoc />
public EventBatchId BatchId { get; init; }
}