using PkmnLib.Dynamic.Models;
using PkmnLib.Static;

namespace PkmnLib.Dynamic.Libraries;

/// <summary>
/// Represents the result of a capture attempt.
/// </summary>
public record struct CaptureResult
{
    /// <inheritdoc cref="CaptureResult"/>
    public CaptureResult(bool IsCaught, int Shakes, bool CriticalCapture)
    {
        this.IsCaught = IsCaught;
        this.Shakes = Shakes;
        this.CriticalCapture = CriticalCapture;
    }

    /// <summary>
    /// Indicates whether the capture was successful.
    /// </summary>
    public bool IsCaught { get; init; }

    /// <summary>
    /// The number of shakes the Poké Ball made before the capture attempt was successful or failed.
    /// </summary>
    public int Shakes { get; init; }

    /// <summary>
    /// Indicates whether a critical capture occurred. A critical capture is a special case where the Poké Ball
    /// shakes only once and then captures the Pokémon.
    /// </summary>
    public bool CriticalCapture { get; init; }

    /// <summary>
    /// Creates a <see cref="CaptureResult"/> indicating a failed capture attempt.
    /// </summary>
    public static CaptureResult Failed => new(false, 0, false);
}

/// <summary>
/// Interface for a library that handles Pokémon capture mechanics.
/// </summary>
public interface ICaptureLibrary
{
    /// <summary>
    /// Attempts to capture a Pokémon using a specified item (e.g., Poké Ball).
    /// </summary>
    CaptureResult TryCapture(IPokemon target, IItem captureItem, IBattleRandom random);
}