using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class PeerIdentityAddressTypeInfo
{
	public static PeerIdentityAddressTypeEnum ValueToPeerIdentityAddressType(uint value)
	{
		switch (value)
		{
		case 0u:
			return PeerIdentityAddressTypeEnum.Public_Identity_Address;
		case 1u:
			return PeerIdentityAddressTypeEnum.Random_static_Identity_Address;
		default:
			if (value >= 2 && value <= 255)
			{
				return PeerIdentityAddressTypeEnum.Reserved_for_future_use;
			}
			return PeerIdentityAddressTypeEnum.InvalidPeerIdentityAddressTypeValue;
		}
	}

	public static uint PeerIdentityAddressTypeToValue(PeerIdentityAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerIdentityAddressTypeEnum.Public_Identity_Address => 0u, 
			PeerIdentityAddressTypeEnum.Random_static_Identity_Address => 1u, 
			PeerIdentityAddressTypeEnum.Reserved_for_future_use => 2u, 
			_ => uint.MaxValue, 
		};
	}

	public static string PeerIdentityAddressTypeToString(PeerIdentityAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerIdentityAddressTypeEnum.Public_Identity_Address => "Public Identity Address", 
			PeerIdentityAddressTypeEnum.Random_static_Identity_Address => "Random (static) Identity Address", 
			PeerIdentityAddressTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid PeerIdentityAddressType Value", 
		};
	}

	public static string PeerIdentityAddressTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Public Identity Address");
		stringBuilder.AppendLine("0x1 = Random (static) Identity Address");
		stringBuilder.AppendLine("0x2-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
