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

namespace PSO2SERVER.Protocol.Packets
{
    public class LoadMaterialStoragePacket : Packet
    {
        public uint player_id { get; set; } = new uint();
        public List<MaterialStorageItem> items { get; set; } = new List<MaterialStorageItem> ();
        public StorageInfo info {  get; set; } = new StorageInfo ();

        #region implemented abstract members of Packet

        public LoadMaterialStoragePacket(Client client)
        {
            player_id = (uint)client._account.AccountId;
        }

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.Write(player_id);
            pkt.WriteMagic((uint)items.Count, 0xAC9, 0x9F);
            foreach (var item in items) {pkt.WriteStruct(item);}
            pkt.WriteStruct(info);
            return pkt.ToArray();
        }

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

        #endregion
    }
}