using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class IoCapabilityInfo
{
	public static IoCapabilityEnum ValueToIoCapability(uint value)
	{
		switch (value)
		{
		case 0u:
			return IoCapabilityEnum.DisplayOnly;
		case 1u:
			return IoCapabilityEnum.DisplayYesNo;
		case 2u:
			return IoCapabilityEnum.KeyboardOnly;
		case 3u:
			return IoCapabilityEnum.NoInputNoOutput;
		default:
			if (value >= 4 && value <= 255)
			{
				return IoCapabilityEnum.RESERVED_FOR_FUTURE_USE;
			}
			return IoCapabilityEnum.InvalidIoCapabilityValue;
		}
	}

	public static uint IoCapabilityToValue(IoCapabilityEnum enumItem)
	{
		return enumItem switch
		{
			IoCapabilityEnum.DisplayOnly => 0u, 
			IoCapabilityEnum.DisplayYesNo => 1u, 
			IoCapabilityEnum.KeyboardOnly => 2u, 
			IoCapabilityEnum.NoInputNoOutput => 3u, 
			IoCapabilityEnum.RESERVED_FOR_FUTURE_USE => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string IoCapabilityToString(IoCapabilityEnum enumItem)
	{
		return enumItem switch
		{
			IoCapabilityEnum.DisplayOnly => "DisplayOnly", 
			IoCapabilityEnum.DisplayYesNo => "DisplayYesNo", 
			IoCapabilityEnum.KeyboardOnly => "KeyboardOnly", 
			IoCapabilityEnum.NoInputNoOutput => "NoInputNoOutput", 
			IoCapabilityEnum.RESERVED_FOR_FUTURE_USE => "Reserved for future use", 
			_ => "Invalid IoCapability Value", 
		};
	}

	public static string IoCapabilityToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = DisplayOnly");
		stringBuilder.AppendLine("0x1 = DisplayYesNo");
		stringBuilder.AppendLine("0x2 = KeyboardOnly");
		stringBuilder.AppendLine("0x3 = NoInputNoOutput");
		stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
