using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class CsrPacketTypeInfo
{
	public static CsrPacketTypeEnum ValueToCsrPacketType(uint value)
	{
		return value switch
		{
			4u => CsrPacketTypeEnum.DH1, 
			11u => CsrPacketTypeEnum.DH3, 
			15u => CsrPacketTypeEnum.DH5, 
			20u => CsrPacketTypeEnum.TWO_DH1, 
			26u => CsrPacketTypeEnum.TWO_DH3, 
			30u => CsrPacketTypeEnum.TWO_DH5, 
			24u => CsrPacketTypeEnum.THREE_DH1, 
			27u => CsrPacketTypeEnum.THREE_DH3, 
			31u => CsrPacketTypeEnum.THREE_DH5, 
			_ => CsrPacketTypeEnum.InvalidCsrPacketTypeValue, 
		};
	}

	public static uint CsrPacketTypeToValue(CsrPacketTypeEnum enumItem)
	{
		return enumItem switch
		{
			CsrPacketTypeEnum.DH1 => 4u, 
			CsrPacketTypeEnum.DH3 => 11u, 
			CsrPacketTypeEnum.DH5 => 15u, 
			CsrPacketTypeEnum.TWO_DH1 => 20u, 
			CsrPacketTypeEnum.TWO_DH3 => 26u, 
			CsrPacketTypeEnum.TWO_DH5 => 30u, 
			CsrPacketTypeEnum.THREE_DH1 => 24u, 
			CsrPacketTypeEnum.THREE_DH3 => 27u, 
			CsrPacketTypeEnum.THREE_DH5 => 31u, 
			_ => uint.MaxValue, 
		};
	}

	public static string CsrPacketTypeToString(CsrPacketTypeEnum enumItem)
	{
		return enumItem switch
		{
			CsrPacketTypeEnum.DH1 => "DH1", 
			CsrPacketTypeEnum.DH3 => "DH3", 
			CsrPacketTypeEnum.DH5 => "DH5", 
			CsrPacketTypeEnum.TWO_DH1 => "TWO_DH1", 
			CsrPacketTypeEnum.TWO_DH3 => "TWO_DH3", 
			CsrPacketTypeEnum.TWO_DH5 => "TWO_DH5", 
			CsrPacketTypeEnum.THREE_DH1 => "THREE_DH1", 
			CsrPacketTypeEnum.THREE_DH3 => "THREE_DH3", 
			CsrPacketTypeEnum.THREE_DH5 => "THREE_DH5", 
			_ => "Invalid CsrPacketType Value", 
		};
	}

	public static string CsrPacketTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x4 = DH1");
		stringBuilder.AppendLine("0xB = DH3");
		stringBuilder.AppendLine("0xF = DH5");
		stringBuilder.AppendLine("0x14 = TWO_DH1");
		stringBuilder.AppendLine("0x1A = TWO_DH3");
		stringBuilder.AppendLine("0x1E = TWO_DH5");
		stringBuilder.AppendLine("0x18 = THREE_DH1");
		stringBuilder.AppendLine("0x1B = THREE_DH3");
		stringBuilder.AppendLine("0x1F = THREE_DH5");
		return stringBuilder.ToString();
	}
}
