Exemple #1
0
        private IEnumerable <JogadorHistorico> ReplaceOneOpponents(
            IEnumerable <JogadorHistorico> team, IBestPlayerStrategy strategy, int round,
            IList <JogadorHistorico> jogadores, IList <JogadorHistorico> blockedPlayers)
        {
            var worstPlayer = team
                              .Where(x => PlayerHaveOpponents(x, team))
                              .OrderBy(strategy.FunctionWorstPlayer)
                              .ThenBy(x => x.JogosNum)
                              .ThenBy(x => x.PrecoNum)
                              .FirstOrDefault();

            var newPlayers = strategy.DoTheMagic(round, jogadores, 1, worstPlayer.PosicaoId, blockedPlayers).Single();

            team = team.Append(newPlayers);

            team = team
                   .Where(x => x.JogadorHistoricoId != worstPlayer.JogadorHistoricoId)
                   .OrderBy(x => x.PosicaoId)
                   .ToList();

            if (team.Count() != 13)
            {
                throw new Exception("Não deu bom ao retirar um jogador no método ReplaceOneOpponents!");
            }

            blockedPlayers.Add(newPlayers);

            return(team);
        }
Exemple #2
0
 private IEnumerable <JogadorHistorico> GetTeam(int round, IList <JogadorHistorico> jogadores, IBestPlayerStrategy strategy, EsquemaPosicoes esquema)
 {
     return(new List <JogadorHistorico>(strategy.DoTheMagic(round, jogadores, esquema.Goleiro, 1))
            .Concat(strategy.DoTheMagic(round, jogadores, esquema.Laterais, 2))
            .Concat(strategy.DoTheMagic(round, jogadores, esquema.Zagueiros, 3))
            .Concat(strategy.DoTheMagic(round, jogadores, esquema.Meias, 4))
            .Concat(strategy.DoTheMagic(round, jogadores, esquema.Atacantes, 5))
            .Concat(strategy.DoTheMagic(round, jogadores, esquema.Tecnico, 6))
            .Concat(strategy.DoTheMagic(round, jogadores, 1)));
 }