Esempio n. 1
0
 private async Task Process(MatchMakerStatus status)
 {
     MatchMakerJoinedQueues = status.JoinedQueues;
     MatchMakerStatusUpdated(this, status);
 }
        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
                };


                // check for instant battle start
                if (invitationBattles?.Any() != true && players.Count > 0) // nobody invited atm and some in queue
                {
                    var testPlayers = players.Values.Where(x => x != null && x.Name != name).ToList(); // get all currently queued players except for self
                    var testSelf = new PlayerEntry(conus.User, possibleQueues.ToList()); // readd self but with all queues
                    testPlayers.Add(testSelf);
                    var testBattles = ProposeBattles(testPlayers); 
                    ret.InstantStartQueues = testBattles.Where(x => x.Players.Contains(testSelf)).Select(x => x.QueueType.Name).Distinct().ToList();
                }

                await conus.SendCommand(ret);
            }
        }
 private MatchMakerStatus ToMatchMakerStatus(PlayerEntry entry)
 {
     var ret = new MatchMakerStatus()
     {
         QueueCounts = queuesCounts,
         IngameCounts = ingameCounts,
     };
     if (entry != null)
     {
         ret.JoinedQueues = entry.QueueTypes.Select(x => x.Name).ToList();
         ret.CurrentEloWidth = entry.EloWidth;
         ret.JoinedTime = entry.JoinedTime;
         ret.BannedSeconds = BannedSeconds(entry.Name);
     }
     return ret;
 }