Example #1
0
        private void CollectTeams(ICollection <Player>[] teams, ICollection <Player> playersPool, TeamGenerationAlgorithm algorithm)
        {
            switch (algorithm)
            {
            case TeamGenerationAlgorithm.Baskets:
                CollectTeamsUsingBaskets(teams, playersPool);
                break;

            case TeamGenerationAlgorithm.Snake:
                CollectTeamsUsingSnake(teams, playersPool);
                break;
            }
        }
Example #2
0
        public IEnumerable <Player>[] Generate(ICollection <Player> gameParticipants, TeamGenerationAlgorithm algorithm)
        {
            if (gameParticipants == null || gameParticipants.Count == 0)
            {
                return(null);
            }

            var fullTeamsCount = gameParticipants.Count / teamMembersCount;
            var remainingCount = gameParticipants.Count - fullTeamsCount * teamMembersCount;
            var teamsCount     = remainingCount == 0 || remainingCount == fullTeamsCount ? fullTeamsCount : fullTeamsCount + 1;
            var teams          = new List <Player> [teamsCount];

            for (var i = 0; i < teamsCount; i++)
            {
                teams[i] = new List <Player>();
            }

            var playersPool = new List <Player>(gameParticipants);

            CollectTeams(teams, playersPool, algorithm);

            return(teams);
        }