// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.

using System.Text;

namespace Wonderking.Packets.Incoming;

[PacketId(OperationCode.CharacterDeletion)]
public class CharacterDeletePacket : IPacket
{
    public byte Slot { get; set; }
    public string Name { get; set; }
    public uint Unknown { get; set; }

    public void Deserialize(byte[] data)
    {
        Span<byte> span = data;
        Slot = span[0];
        Name = Encoding.ASCII.GetString(span.Slice(1, 20)).TrimEnd('\0').TrimEnd('\n').TrimEnd('\0');
        Unknown = BitConverter.ToUInt32(span.Slice(21, 4));
    }

    public byte[] Serialize()
    {
        throw new NotSupportedException();
    }
}