using System;
using System.Runtime.InteropServices;

using PSO2SERVER.Models;

namespace PSO2SERVER.Protocol.Packets
{
    class PartySetQuestPacket : Packet
    {
        public uint Name {  get; set; }
        public uint Difficulty { get; set; }
        public QuestType QuestType { get; set; }
        public QuestDefiniton QuestDefiniton { get; set; }
        public QuestDifficulty QuestDifficulty { get; set; }
        public ObjectHeader Player { get; set; }
        public ushort unk1 { get; set; } = 0;
        public ushort unk2 { get; set; } = 0;

        public PartySetQuestPacket(uint name, uint difficulty, QuestDefiniton data, QuestDifficulty Questdifficulty, ObjectHeader player)
        {
            Name = name;
            Difficulty = difficulty;
            QuestDefiniton = data;
            QuestDifficulty = Questdifficulty;
            Player = player;
        }

        public override byte[] Build()
        {
            PacketWriter writer = new PacketWriter();
            writer.Write(Name); // Unknown
            writer.Write(Difficulty); // Unknown
            writer.Write((uint)QuestType);
            writer.WriteStruct<QuestDefiniton>(QuestDefiniton);
            writer.WriteStruct<QuestDifficulty>(QuestDifficulty);
            writer.WriteStruct<ObjectHeader>(Player);
            writer.Write(unk1);
            writer.Write(unk2);
            return writer.ToArray();
        }

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