Esempio n. 1
0
 private static int AddPlayerToMatch(int playersAdded, MatchGroup match, TempAccumulator accumulator, Player player)
 {
     MatchUtils.UpdateMatchCounters(accumulator, player);
     playersAdded++;
     match.Players.Add(player);
     return(playersAdded);
 }
Esempio n. 2
0
        private static void CreateMatch(Queue <Player> queue, IHostingEnvironment hostingEnvironment)
        {
            int playersAdded = 0;
            var match        = new MatchGroup();
            var accumulator  = new TempAccumulator();

            // 1) Add players from priority queue (if any)
            while (playersAdded < playersPerMatch && topPriorityQueue.Count > 0)
            {
                var player = topPriorityQueue.Dequeue();
                playersAdded = AddPlayerToMatch(playersAdded, match, accumulator, player);
            }

            // 2) Add players from proper queue
            while (playersAdded < playersPerMatch)
            {
                var player = queue.Dequeue();
                playersAdded = AddPlayerToMatch(playersAdded, match, accumulator, player);
            }

            MatchUtils.UpdateMatchStats(accumulator, match, playersAdded, currentMatchNumber);

            matches.Add(match);
            WriteMatchToFile(match, hostingEnvironment);
            currentMatchNumber++;
        }