using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class AuthenticationCompleteInfo : PacketInfoBase
{
	public override string Name => "Authentication Complete";

	public override string DisplayGroup => "Link Control";

	public AuthenticationCompleteInfo(AuthenticationComplete packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		AuthenticationComplete authenticationComplete = (AuthenticationComplete)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(authenticationComplete.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(authenticationComplete.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection_Handle.", 16, FormatValue(authenticationComplete.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		AuthenticationComplete authenticationComplete = (AuthenticationComplete)packet;
		int num = -1;
		if (index == ++num)
		{
			authenticationComplete.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			authenticationComplete.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
	}
}
