using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class MoreFieldValuesInfo
{
	public static MoreFieldValuesEnum ValueToMoreFieldValues(uint value)
	{
		switch (value)
		{
		case 0u:
			return MoreFieldValuesEnum.LAST_MESSAGE;
		case 1u:
			return MoreFieldValuesEnum.MORE_MESSAGES;
		default:
			if (value >= 2 && value <= 255)
			{
				return MoreFieldValuesEnum.RFU;
			}
			return MoreFieldValuesEnum.InvalidMoreFieldValuesValue;
		}
	}

	public static uint MoreFieldValuesToValue(MoreFieldValuesEnum enumItem)
	{
		return enumItem switch
		{
			MoreFieldValuesEnum.LAST_MESSAGE => 0u, 
			MoreFieldValuesEnum.MORE_MESSAGES => 1u, 
			MoreFieldValuesEnum.RFU => 2u, 
			_ => uint.MaxValue, 
		};
	}

	public static string MoreFieldValuesToString(MoreFieldValuesEnum enumItem)
	{
		return enumItem switch
		{
			MoreFieldValuesEnum.LAST_MESSAGE => "LAST_MESSAGE", 
			MoreFieldValuesEnum.MORE_MESSAGES => "MORE_MESSAGES", 
			MoreFieldValuesEnum.RFU => "RFU", 
			_ => "Invalid MoreFieldValues Value", 
		};
	}

	public static string MoreFieldValuesToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = LAST_MESSAGE");
		stringBuilder.AppendLine("0x1 = MORE_MESSAGES");
		stringBuilder.AppendLine("0x2-0xFF = RFU");
		return stringBuilder.ToString();
	}
}
