using PSO2SERVER.Models;
using PSO2SERVER.Object;
using PSO2SERVER.Protocol.Packets;
using PSO2SERVER.Zone;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static PSO2SERVER.Protocol.Handlers.TeleportLobbyToCafe;

namespace PSO2SERVER.Protocol.Handlers
{
    [PacketHandlerAttr(0x03, 0x35)]
    public class TeleportLobbyToCasino : PacketHandler
    {
        /// (0x03, 0x35) Move Lobby -> Casino.
        public struct CasinoTransportPacket
        {
            public uint unk1;
            public uint unk2;
            public uint unk3;
        }
        ///[<--] 0x03 - 0x35 (TeleportLobbyToCasino) (Flags None) (20 字节)
        /// unk1 0 unk2 0 unk3 16
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            if (context._account == null)
                return;

            var reader = new PacketReader(data, position, size);
            var pkt = reader.ReadStruct<CasinoTransportPacket>();

            Logger.Write($"unk1 {pkt.unk1} unk2 {pkt.unk2} unk3 {pkt.unk3}");

            // Dunno what these are yet.
            context.SendPacket(new Unk110APacket((uint)context._account.AccountId));
            context.SendPacket(new Unk1E0CPacket(101));

            Map casinoMap = ZoneManager.Instance.MapFromInstance("casino", "lobby");
            casinoMap.SpawnClient(context, casinoMap.GetDefaultLocation());

        }
    }
}
