public void GetListCharacters(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            var account = user.Accounts.Find(c => c.TcpId == tcpId);

            hub.SendPackage("Agfr", tcpId);
            hub.SendPackage($"Ai{account.ClientId}", tcpId);
            hub.SendPackage("AL", tcpId);
            hub.SendPackage("Af", tcpId);
        }
        public void SelectCharacter(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            var currentAccount = user.Accounts.FirstOrDefault(c => c.TcpId == tcpId);

            string[]         splittedData = package.Substring(3).Split('|');
            int              count        = 2;
            bool             found        = false;
            List <Character> characters   = new List <Character>();

            hub.CallCheck(tcpId).Wait();

            DeepTalk.IsScans.TryGetValue(tcpId, out bool isScan);

            while (count < splittedData.Length && !found)
            {
                string[] _loc11_       = splittedData[count].Split(';');
                int      id            = int.Parse(_loc11_[0]);
                string   characterName = _loc11_[1];
                byte     Level         = byte.Parse(_loc11_[2]);
                short    model         = short.Parse(_loc11_[3]);

                if (isScan)
                {
                    characters.Add(new Character()
                    {
                        BreedId = model, Key = id, Name = characterName, Level = Level
                    });
                }

                if (!isScan && currentAccount != null)
                {
                    if (characterName.ToLower().Equals(currentAccount.CurrentCharacter.Name.ToLower()))
                    {
                        hub.SendPackage($"AS{id}", tcpId, true);
                        hub.SendPackage($"Af", tcpId);
                        hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, $"Selection du personnage {characterName}", tcpId), tcpId).Wait();
                        Debug.WriteLine("Add character " + currentAccount.CurrentCharacter.Key + " to memory");
                        Storage.Instance.AddCharacter(currentAccount.CurrentCharacter);
                        found = true;
                    }
                }
                count++;
            }
            if (isScan)
            {
                user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Characters = characters;
                manager.ReplaceOneAsync(c => c.Id == user.Id, user).Wait();
                hub.DispatchToClient(new CharactersMessage(characters, tcpId), tcpId).Wait();
                hub.DisconnectCli(tcpId, true).Wait();
            }
        }
Example #3
0
        public void GroupInvitationHandler(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            var characterGame = Storage.Instance.GetCharacter(user.Accounts.Find(c => c.TcpId == tcpId).CurrentCharacter.Key);

            hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, package.Substring(3).Split('|')[0].ToLower() + " t'invite à rejoindre son groupe.", tcpId), tcpId).Wait();
            if (characterGame.HasGroup && package.Substring(3).Split('|')[0].ToLower() == characterGame.Group.Leader.Name.ToLower())
            {
                hub.SendPackage("PA", tcpId);
                hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, "Invitation acceptée.", tcpId), tcpId).Wait();
            }
            else
            {
                hub.SendPackage("PR", tcpId);
                hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, "Invitation refusée.", tcpId), tcpId).Wait();
            }
        }
        public void GetServerState(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            string[] serverList = package.Substring(2).Split('|');
            Server   server     = user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Server;
            bool     firstTime  = true;

            foreach (string sv in serverList)
            {
                string[] separator = sv.Split(';');

                int         id          = int.Parse(separator[0]);
                ServerState serverState = (ServerState)byte.Parse(separator[1]);

                if (id == server.Id)
                {
                    server.State = serverState;
                    manager.ReplaceOneAsync(c => c.Id == user.Id, user);
                    hub.DispatchToClient(new LogMessage(LogType.GAME_INFORMATION, $"Le serveur {server.Name} est {server.State}", tcpId), tcpId).Wait();

                    if (serverState != ServerState.ONLINE)
                    {
                        firstTime = false;
                    }
                }
            }

            if (!firstTime && server.State == ServerState.ONLINE)
            {
                hub.SendPackage("Ax", tcpId);
            }
        }
 public void GetSecretQuestion(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     if (user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Server.State == ServerState.ONLINE)
     {
         hub.SendPackage("Ax", tcpId, true);
     }
 }
 public void GetLoginQueue(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     string[] queueData = package.Substring(2).Split('|');
     hub.DispatchToClient(new LogMessage(LogType.GAME_INFORMATION, "[File d'attente] Position " + queueData[0] + "/" + queueData[1], tcpId), tcpId).Wait();
     if (int.Parse(queueData[0]) > 100)
     {
         hub.SendPackage("Af", tcpId);
     }
 }
        public void GetWelcomeKeyAsync(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            var account = user.Accounts.FirstOrDefault(c => c.TcpId == tcpId);

            if (account.CurrentCharacter != null)
            {
                account.CurrentCharacter.State = CharacterStateEnum.CONNECTING;
            }
            account.WelcomeKey = package.Substring(2);
            manager.ReplaceOneAsync(c => c.Id == user.Id, user);

            hub.DispatchToClient(new LogMessage(LogType.GAME_INFORMATION, "Connexion au serveur d'auth", tcpId), tcpId).Wait();

            hub.SendPackage("1.31.3", tcpId);

            hub.SendPackage($"{account.AccountName}\n{Hash.EncryptPassword(account.Password, account.WelcomeKey)}", tcpId);
            hub.SendPackage($"Af", tcpId);
        }
Example #8
0
        public void GetMapHandler(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            var characterGame = Storage.Instance.GetCharacter(user.Accounts.Find(c => c.TcpId == tcpId).CurrentCharacter.Key);

            if (package.Length == 21)
            {
                string[] _loc3 = package.Split('|');
                if (int.TryParse(_loc3[1], out int mapId))
                {
                    hub.SendPackage($"Gdm{mapId}", tcpId);
                    characterGame.Map = new Map(mapId);
                    hub.DispatchToClient(new MapMessage(characterGame.Map, tcpId), tcpId).Wait();
                }
            }
            else
            {
                if (int.TryParse(package.Substring(4).Split('|')[0], out int mapId))
                {
                    characterGame.Map = new Map(mapId);
                    hub.DispatchToClient(new MapMessage(characterGame.Map, tcpId), tcpId).Wait();
                    hub.SendPackage("GI", tcpId);
                }
            }
        }
        public async void GetServerList(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
        {
            //AM.Account account = prmClient.Account;
            string[] loc5    = package.Substring(3).Split('|');
            int      counter = 1;
            bool     picked  = false;

            while (counter < loc5.Length && !picked)
            {
                string[] _loc10_      = loc5[counter].Split(',');
                int      serverId     = int.Parse(_loc10_[0]);
                var      userSelected = user.Accounts.FirstOrDefault(c => c.TcpId == tcpId);
                if (serverId == userSelected.Server.Id)
                {
                    if (user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Server.State == ServerState.ONLINE)
                    {
                        picked = true;
                    }
                    else
                    {
                        var wait = new Random().Next(100, 1000);
                        hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, $"Serveur non accessible pour le moment, je réessaye dans {wait}ms", tcpId), tcpId).Wait();
                        await Task.Delay(wait);
                    }
                }
                else
                {
                    counter++;
                }
            }

            if (picked)
            {
                hub.SendPackage($"AX{user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Server.Id}", tcpId, true);
            }
        }
Example #10
0
 public void GuildInvitationHandler(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, package.Substring(3) + " t'invite à rejoindre sa guilde.", tcpId), tcpId).Wait();
     hub.SendPackage("gJE", tcpId);
     hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, $"Invitation à rejoindre la guilde refusée", tcpId), tcpId).Wait();
 }
 public void ConnectPackageHandle(DeepTalk hub, string package, UserDB account, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService) => hub.SendPackage("GI", tcpId);
 public void ResultServerSelection(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     hub.SendPackage("Ak0", tcpId);
     hub.SendPackage("AV", tcpId);
 }
 public void WelcomeGame(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService) => hub.SendPackage($"AT{user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).GameTicket}", tcpId);
Example #14
0
 public void ChangeScreenHandler(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     hub.SendPackage("GC1", tcpId);
 }
Example #15
0
 public void EndActionHandler(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService)
 {
     string[] idEndAction = package.Substring(3).Split('|');
     hub.SendPackage($"GKK{idEndAction[0]}", tcpId);
 }