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

namespace PSO2SERVER.Protocol.Packets
{
    public class SetLobbyEventPacket : Packet
    {
        /// Event string ID.
        public string event_name { get; set; } //Ascii
        /// Voice line string ID.
        public string voice_line { get; set; } //Ascii
        /// Event start timestamp.
        public Duration start_time { get; set; }
        /// Event end timestamp.
        public Duration end_time { get; set; }
        public uint repeat_secs { get; set; }
        public ulong unk4 { get; set; }

        public SetLobbyEventPacket(string eventname, string voiceline, Duration starttime, Duration endtime, uint repeatsecs, ulong unk4)
        {
            this.event_name = eventname;
            this.voice_line = voiceline;
            this.start_time = starttime;
            this.end_time = endtime;
            this.repeat_secs = repeatsecs;
            this.unk4 = unk4;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.WriteAscii(event_name, 0xA6E4, 0xFB);
            pkt.WriteAscii(voice_line, 0xA6E4, 0xFB);
            pkt.WriteStruct(start_time);
            pkt.WriteStruct(end_time);
            pkt.Write(repeat_secs);
            pkt.Write(unk4);
            return pkt.ToArray();
        }

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

        #endregion
    }
}