// Copyright © 2017-2018 Atomic Software, LLC. All Rights Reserved.
// See LICENSE.md for full license information.

using Atom.Core.Game;
using Atom.Core.Networking.Messages;
using Atom.WorldManagerServer.Logic;
using Atom.WorldManagerServer.Services;

namespace Atom.WorldManagerServer.Networking.Messages.Handlers
{
    public static class UserHandlers
    {
        [MessageHandler(MessageProtocol.NC_USER_LOGINWORLD_REQ)]
        public static void NC_USER_LOGINWORLD_REQ(NetworkMessage msg)
        {
            var UserName = msg.ReadString(256);
            var ValidateNew = msg.ReadString(64);

            AccountLogic.Login(msg.Client, UserName, ValidateNew);
        }

        [MessageHandler(MessageProtocol.NC_USER_NORMALLOGOUT_CMD)]
        public static void NC_USER_NORMALLOGOUT_CMD(NetworkMessage msg)
        {
            var LogoutType = (LogoutType)msg.ReadByte();
            ClientLogic.Logout(msg.Client, LogoutType);
        }

        [MessageHandler(MessageProtocol.NC_USER_WILL_WORLD_SELECT_REQ)]
        public static void NC_USER_WILL_WORLD_SELECT_REQ(NetworkMessage msg)
        {
            TransferService.TransferClientToLogin(msg.Client);
        }
    }
}
