using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class RoleInfo
{
	public static RoleEnum ValueToRole(uint value)
	{
		switch (value)
		{
		case 0u:
			return RoleEnum.Connection_is_master;
		case 1u:
			return RoleEnum.Connection_is_slave;
		default:
			if (value >= 2 && value <= 255)
			{
				return RoleEnum.RESERVED_FOR_FUTURE_USE;
			}
			return RoleEnum.InvalidRoleValue;
		}
	}

	public static uint RoleToValue(RoleEnum enumItem)
	{
		return enumItem switch
		{
			RoleEnum.Connection_is_master => 0u, 
			RoleEnum.Connection_is_slave => 1u, 
			RoleEnum.RESERVED_FOR_FUTURE_USE => 2u, 
			_ => uint.MaxValue, 
		};
	}

	public static string RoleToString(RoleEnum enumItem)
	{
		return enumItem switch
		{
			RoleEnum.Connection_is_master => "Connection is master", 
			RoleEnum.Connection_is_slave => "Connection is slave", 
			RoleEnum.RESERVED_FOR_FUTURE_USE => "Reserved for future use", 
			_ => "Invalid Role Value", 
		};
	}

	public static string RoleToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Connection is master");
		stringBuilder.AppendLine("0x1 = Connection is slave");
		stringBuilder.AppendLine("0x2-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
