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

namespace PSO2SERVER.Protocol.Packets
{
    public class ShipListPacket : Packet
    {
        public List<ShipEntry> shipEntries { get; set; } = new List<ShipEntry>();
        public int timestamp { get; set; }
        public uint unk { get; set; }

        public ShipListPacket(List<ShipEntry> entries, int timestamp, uint unk)
        {
            shipEntries = entries;
            this.timestamp = timestamp;
            this.unk = unk;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.WriteMagic((uint)shipEntries.Count, 0xE418, 0x51);

            foreach (var entry in shipEntries)
                pkt.WriteStruct(entry);

            pkt.Write(timestamp);
            pkt.Write(unk);
            return pkt.ToArray();
        }

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

        #endregion
    }
}