Exemplo n.º 1
0
        private async Task UpdatePlayerStatus(string name)
        {
            ConnectedUser conus;

            if (server.ConnectedUsers.TryGetValue(name, out conus))
            {
                PlayerEntry entry;
                players.TryGetValue(name, out entry);
                var ret = new MatchMakerStatus()
                {
                    QueueCounts      = queuesCounts,
                    IngameCounts     = ingameCounts,
                    JoinedQueues     = entry?.QueueTypes.Select(x => x.Name).ToList(),
                    CurrentEloWidth  = entry?.EloWidth,
                    JoinedTime       = entry?.JoinedTime,
                    BannedSeconds    = BannedSeconds(name),
                    UserCount        = server.ConnectedUsers.Count,
                    UserCountDiscord = server.GetDiscordUserCount()
                };


                // check for instant battle start - only non partied people
                if ((invitationBattles?.Any() != true) && (players.Count > 0) && (server.PartyManager.GetParty(name) == null))
                // nobody invited atm and some in queue
                {
                    ret.InstantStartQueues = new List <string>();
                    // iterate each queue to check all possible instant starts
                    foreach (var queue in PossibleQueues)
                    {
                        // get all currently queued players except for self
                        var testPlayers = players.Values.Where(x => (x != null) && (x.Name != name)).ToList();
                        var testSelf    = new PlayerEntry(conus.User, new List <MatchMakerSetup.Queue> {
                            queue
                        }, null);
                        testPlayers.Add(testSelf);
                        var testBattles = ProposeBattles(testPlayers, false);
                        ret.InstantStartQueues.AddRange(testBattles.Where(x => x.Players.Contains(testSelf)).Select(x => x.QueueType.Name).Distinct().ToList());
                    }
                }

                await conus.SendCommand(ret);
            }
        }