using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class RfDiscoveryIdInfo
{
	public static RfDiscoveryIdEnum ValueToRfDiscoveryId(uint value)
	{
		if (value == 0)
		{
			return RfDiscoveryIdEnum.RFU;
		}
		if (value >= 1 && value <= 254)
		{
			return RfDiscoveryIdEnum.DYNAMIC;
		}
		if (value >= 2 && value <= 255)
		{
			return RfDiscoveryIdEnum.RFU;
		}
		return RfDiscoveryIdEnum.InvalidRfDiscoveryIdValue;
	}

	public static uint RfDiscoveryIdToValue(RfDiscoveryIdEnum enumItem)
	{
		switch (enumItem)
		{
		case RfDiscoveryIdEnum.RFU:
			return 0u;
		case RfDiscoveryIdEnum.DYNAMIC:
			return 1u;
		default:
			if (enumItem == RfDiscoveryIdEnum.RFU)
			{
				return 2u;
			}
			return uint.MaxValue;
		}
	}

	public static string RfDiscoveryIdToString(RfDiscoveryIdEnum enumItem)
	{
		switch (enumItem)
		{
		case RfDiscoveryIdEnum.RFU:
			return "RFU";
		case RfDiscoveryIdEnum.DYNAMIC:
			return "Dyanmically assigned by the NFCC.";
		default:
			if (enumItem == RfDiscoveryIdEnum.RFU)
			{
				return "RFU";
			}
			return "Invalid RfDiscoveryId Value";
		}
	}

	public static string RfDiscoveryIdToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = RFU");
		stringBuilder.AppendLine("0x1-0xFE = Dyanmically assigned by the NFCC.");
		stringBuilder.AppendLine("0x2-0xFF = RFU");
		return stringBuilder.ToString();
	}
}
