public ChampionShipController(ISwitchingRule switchingRule,
                               ITiebreakerRule tiebreakRule,
                               IMovieService movieService,
                               IChampionShipRepository championShipRepository)
 {
     this.switchingRule          = switchingRule;
     this.tiebreakRule           = tiebreakRule;
     this.movieService           = movieService;
     this.championShipRepository = championShipRepository;
 }
示例#2
0
        public void Start(ISwitchingRule switchingRule, ITiebreakerRule tiebreakerRule)
        {
            Games
                = switchingRule.PerformSwitching(Players.ToList());

            foreach (var game in Games)
            {
                game.Play(tiebreakerRule);
            }

            Winners
                = Games.Select(a => a.Winner);
        }
示例#3
0
文件: Game.cs 项目: BetoCR/CopaFilmes
        public void Play(ITiebreakerRule tieBreakerRule)
        {
            if (Player1.nota.Equals(Player2.nota))
            {
                //Aplica critério de desempate
                Winner = tieBreakerRule.ApplyAndGetWinner(Player1, Player2);
                return;
            }

            if (Player1.nota > Player2.nota)
            {
                Winner = Player1;
            }
            else
            {
                Winner = Player2;
            }
        }
示例#4
0
        public void Start(ISwitchingRule switchingRule, ITiebreakerRule tiebreakerRule)
        {
            var phaseNumber = 1;

            var players = new List <Movie>();

            players.AddRange(Movies);

            var playersCount = players.Count();

            ChampionShipPhase phase = null;

            while (playersCount > 1)
            {
                phase
                    = new ChampionShipPhase($"Fase {phaseNumber}", players);

                phases.Add(phase);

                phase.Start(switchingRule, tiebreakerRule);

                players
                    = phase.Winners.OrderBy(a => a.titulo).ToList();

                playersCount
                    = players.Count();

                phaseNumber++;
            }

            ChampionShipWinner
                = phase.Winners.First();

            var lastGame =
                phase.Games.FirstOrDefault();

            ChampionShipVice
                = lastGame.Player1.Equals(ChampionShipWinner) ? lastGame.Player2 : lastGame.Player1;
        }