using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class MemoryAccessItemSizeInfo
{
	public static MemoryAccessItemSizeEnum ValueToMemoryAccessItemSize(uint value)
	{
		return value switch
		{
			0u => MemoryAccessItemSizeEnum.ITEM_SIZE_8_BITS, 
			1u => MemoryAccessItemSizeEnum.ITEM_SIZE_16_BITS, 
			2u => MemoryAccessItemSizeEnum.ITEM_SIZE_32_BITS, 
			3u => MemoryAccessItemSizeEnum.RFU, 
			_ => MemoryAccessItemSizeEnum.InvalidMemoryAccessItemSizeValue, 
		};
	}

	public static uint MemoryAccessItemSizeToValue(MemoryAccessItemSizeEnum enumItem)
	{
		return enumItem switch
		{
			MemoryAccessItemSizeEnum.ITEM_SIZE_8_BITS => 0u, 
			MemoryAccessItemSizeEnum.ITEM_SIZE_16_BITS => 1u, 
			MemoryAccessItemSizeEnum.ITEM_SIZE_32_BITS => 2u, 
			MemoryAccessItemSizeEnum.RFU => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string MemoryAccessItemSizeToString(MemoryAccessItemSizeEnum enumItem)
	{
		return enumItem switch
		{
			MemoryAccessItemSizeEnum.ITEM_SIZE_8_BITS => "8 bits (byte)", 
			MemoryAccessItemSizeEnum.ITEM_SIZE_16_BITS => "16 bits (byte)", 
			MemoryAccessItemSizeEnum.ITEM_SIZE_32_BITS => "32 bits (byte)", 
			MemoryAccessItemSizeEnum.RFU => "RFU", 
			_ => "Invalid MemoryAccessItemSize Value", 
		};
	}

	public static string MemoryAccessItemSizeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = 8 bits (byte)");
		stringBuilder.AppendLine("0x1 = 16 bits (byte)");
		stringBuilder.AppendLine("0x2 = 32 bits (byte)");
		stringBuilder.AppendLine("0x3 = RFU");
		return stringBuilder.ToString();
	}
}
