public ChampionShipController(ISwitchingRule switchingRule, ITiebreakerRule tiebreakRule, IMovieService movieService, IChampionShipRepository championShipRepository) { this.switchingRule = switchingRule; this.tiebreakRule = tiebreakRule; this.movieService = movieService; this.championShipRepository = championShipRepository; }
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); }
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; }