using PkmnLib.Dynamic.ScriptHandling;

namespace PkmnLib.Dynamic.Models.Choices;

/// <summary>
/// A choice to pass a turn.
/// </summary>
public interface IPassChoice : ITurnChoice
{
}

/// <inheritdoc cref="IPassChoice"/>
public class PassChoice : TurnChoice, IPassChoice
{
    /// <inheritdoc cref="PassChoice"/>
    public PassChoice(IPokemon user) : base(user)
    {
    }

    /// <inheritdoc />
    public override int ScriptCount => User.ScriptCount;

    /// <inheritdoc />
    public override void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts)
    {
    }

    /// <inheritdoc />
    public override void CollectScripts(List<IEnumerable<ScriptContainer>> scripts)
    {
        User.CollectScripts(scripts);
    }

    /// <inheritdoc />
    public override string ToString() =>
        $"PassChoice: {User}";

    protected bool Equals(PassChoice other) => other.User == User;

    /// <inheritdoc />
    public override bool Equals(object? obj)
    {
        if (obj is null)
            return false;
        if (ReferenceEquals(this, obj))
            return true;
        if (obj is not PassChoice other)
            return false;
        return Equals(other);
    }

    /// <inheritdoc />
    public override int GetHashCode() =>
        // ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
        User?.GetHashCode() ?? 0;
}