using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class SynchronousPacketTypeInfo
{
	public static SynchronousPacketTypeEnumCollection ValueToSynchronousPacketType(uint value)
	{
		SynchronousPacketTypeEnumCollection synchronousPacketTypeEnumCollection = new SynchronousPacketTypeEnumCollection();
		synchronousPacketTypeEnumCollection.Hv1 = AssertBitInfo.ValueToAssertBit((value & 0x20) >> 5);
		synchronousPacketTypeEnumCollection.Hv2 = AssertBitInfo.ValueToAssertBit((value & 0x40) >> 6);
		synchronousPacketTypeEnumCollection.Hv3 = AssertBitInfo.ValueToAssertBit((value & 0x80) >> 7);
		return synchronousPacketTypeEnumCollection;
	}

	public static uint SynchronousPacketTypeToValue(SynchronousPacketTypeEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= AssertBitInfo.AssertBitToValue(enumCollection.Hv1) << 5;
		num |= AssertBitInfo.AssertBitToValue(enumCollection.Hv2) << 6;
		return num | (AssertBitInfo.AssertBitToValue(enumCollection.Hv3) << 7);
	}

	public static string SynchronousPacketTypeToString(SynchronousPacketTypeEnumCollection enumCollection)
	{
		string text = "";
		text = text + "HV1: " + AssertBitInfo.AssertBitToString(enumCollection.Hv1) + "\r\n";
		text = text + "HV2: " + AssertBitInfo.AssertBitToString(enumCollection.Hv2) + "\r\n";
		text = text + "HV3: " + AssertBitInfo.AssertBitToString(enumCollection.Hv3) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string SynchronousPacketTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bits 4-0: Reserved for future use");
		stringBuilder.AppendLine("Bit 5: HV1");
		stringBuilder.AppendLine(AssertBitInfo.AssertBitToDescription());
		stringBuilder.AppendLine("Bit 6: HV2");
		stringBuilder.AppendLine(AssertBitInfo.AssertBitToDescription());
		stringBuilder.AppendLine("Bit 7: HV3");
		stringBuilder.AppendLine(AssertBitInfo.AssertBitToDescription());
		stringBuilder.AppendLine("Bits 15-8: Reserved for future use");
		return stringBuilder.ToString();
	}
}
