using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PSO2SERVER.Protocol.Packets
{
    public class BlockBalancePacket : Packet
    {
        public byte[] unk1 { get; set; } = new byte[0x20];
        public string blockname { get; set; } = string.Empty; //0x20 wide
        public byte[] ip { get; set; } = new byte[4];
        public ushort port { get; set; }
        public byte[] data { get; set; } = new byte[0x11A];


        public BlockBalancePacket(string blockname, ushort port)
        {
            this.blockname = blockname;
            ip = ServerApp.BindAddress.GetAddressBytes();
            this.port = port;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.Write(unk1);
            pkt.WriteFixedLengthUtf16(blockname, 0x20);
            pkt.Write(ip);
            pkt.Write(port);
            pkt.Write(new byte[0x11A]);
            return pkt.ToArray();
        }

        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x11, 0x2C, PacketFlags.None);
        }

        #endregion
    }
}