using PSO2SERVER.Models;

namespace PSO2SERVER.Protocol.Packets
{
    public class SetQuestInfoPacket : Packet
    {
        /// <summary>
        /// name ID of the quest.
        /// </summary>
        public uint Name { get; set; }

        public uint Unk1 { get; set; }
        public uint Unk2 { get; set; }
        public ushort Unk3 { get; set; }
        public ushort Unk4 { get; set; }

        /// <summary>
        /// Player who accepted the quest.
        /// </summary>
        public ObjectHeader Player { get; set; }

        public uint[] Unk5 { get; set; } = new uint[5];
        public byte Unk6 { get; set; }
        public byte Unk7 { get; set; }
        public byte Unk8 { get; set; }

        /// <summary>
        /// PartyQuest difficulty.
        /// </summary>
        public byte Diff { get; set; }

        /// <summary>
        /// PartyQuest type.
        /// </summary>
        public QuestType QuestType { get; set; }

        QuestDef questdef;

        public SetQuestInfoPacket(QuestDef questdef, ushort partydiff, uint accountid)
        {
            this.questdef = questdef;
            Diff = (byte)partydiff;
            Player = new ObjectHeader(accountid, ObjectType.Player);
        }
        public override byte[] Build()
        {
            PacketWriter writer = new PacketWriter();
            writer.Write(questdef.NameId);
            writer.Write(Unk1);
            writer.Write(Unk2);
            writer.Write(Unk3);
            writer.Write(Unk4);
            //writer.Write((ushort)1);
            writer.WriteObjectHeader(Player);
            writer.Write(0);
            writer.Write(0);
            writer.Write(0);
            writer.Write(0);
            writer.Write(0);
            writer.Write(Unk6);
            writer.Write(Unk7);
            writer.Write(Unk8);
            writer.Write(Diff);
            writer.Write((byte)QuestType);
            return writer.ToArray();
        }
        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x0E, 0x25, PacketFlags.None);
        }
    }
}