using PkmnLib.Static.Libraries;
using PkmnLib.Static.Utils;

namespace PkmnLib.Static;

/// <summary>
/// A number that identifies a type. To be used with <see cref="TypeLibrary"/>
/// </summary>
public readonly struct TypeIdentifier : IEquatable<TypeIdentifier>
{
    /// <summary>
    /// The name of the type identifier.
    /// </summary>
    public StringKey Name { get; }

    /// <summary>
    /// The underlying value of the type identifier.
    /// </summary>
    public byte Value { get; }

    /// <inheritdoc cref="TypeIdentifier"/>
    public TypeIdentifier(byte value, StringKey name)
    {
        Value = value;
        Name = name;
    }

    /// <inheritdoc />
    public override int GetHashCode() => Value.GetHashCode();

    /// <inheritdoc />
    public bool Equals(TypeIdentifier other) => Value == other.Value;

    /// <inheritdoc />
    public override bool Equals(object? obj) => obj is TypeIdentifier other && Equals(other);

    public static bool operator ==(TypeIdentifier left, TypeIdentifier right) => left.Equals(right);
    public static bool operator !=(TypeIdentifier left, TypeIdentifier right) => !left.Equals(right);

    /// <inheritdoc />
    public override string ToString() => Name.ToString();
}