Beispiel #1
0
        public void CanSolveTie()
        {
            PlayerReference maruPlayerReference = tournament.RegisterPlayerReference("Maru");

            round.SetPlayersPerGroupCount(3);
            PlayerReference storkPlayerReference = tournament.RegisterPlayerReference("Stork");

            round.SetAdvancingPerGroupCount(2);
            PlayerReference taejaPlayerReference = tournament.RegisterPlayerReference("Taeja");

            BracketRound bracketRound = tournament.AddBracketRound();

            GroupBase group = round.Groups.First();

            foreach (Match match in round.Groups.First().Matches)
            {
                SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
                match.Player1.IncreaseScore(2);
            }

            group.HasProblematicTie().Should().BeTrue();
            group.HasSolvedTie().Should().BeFalse();
            group.SolveTieByChoosing(taejaPlayerReference.Id).Should().BeFalse();

            group.HasProblematicTie().Should().BeTrue();
            group.HasSolvedTie().Should().BeFalse();
            group.SolveTieByChoosing(storkPlayerReference.Id).Should().BeTrue();

            group.HasProblematicTie().Should().BeTrue();
            group.HasSolvedTie().Should().BeTrue();

            bracketRound.Groups.First().Matches[0].Player1.GetName().Should().Be("Taeja");
            bracketRound.Groups.First().Matches[0].Player2.GetName().Should().Be("Stork");
        }
Beispiel #2
0
        public void SolvingTieWhenThereIsNoTieDoesNothing()
        {
            PlayerReference maruPlayerReference  = tournament.RegisterPlayerReference("Maru");
            PlayerReference storkPlayerReference = tournament.RegisterPlayerReference("Stork");
            PlayerReference taejaPlayerReference = tournament.RegisterPlayerReference("Taeja");

            round.SetPlayersPerGroupCount(3);

            GroupBase group = round.Groups.First();
            Match     match;

            match = round.Groups.First().Matches[0];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player1.IncreaseScore(2);

            match = round.Groups.First().Matches[1];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player2.IncreaseScore(2);

            match = round.Groups.First().Matches[2];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player1.IncreaseScore(2);

            group.HasProblematicTie().Should().BeFalse();
            group.SolveTieByChoosing(maruPlayerReference.Id).Should().BeFalse();
        }
Beispiel #3
0
        public static List <PlayerReference> FetchFrom(GroupBase group)
        {
            if (group.GetPlayState() == PlayStateEnum.Finished)
            {
                PlayerStandingsSolver playerStandingsSolver = new PlayerStandingsSolver();
                List <StandingsEntry <PlayerReference> > playerReferences = playerStandingsSolver.FetchFrom(group);
                playerReferences = FilterAdvancingPlayers(group, playerReferences);

                if (group.HasProblematicTie())
                {
                    playerReferences = FilterTyingPlayers(group, playerReferences);
                    playerReferences.AddRange(group.ChoosenTyingPlayerEntries);
                }

                List <PlayerReference> advancingPlayers = new List <PlayerReference>();

                foreach (StandingsEntry <PlayerReference> entry in playerReferences)
                {
                    advancingPlayers.Add(entry.Object);
                }

                return(advancingPlayers);
            }

            return(new List <PlayerReference>());
        }
Beispiel #4
0
        public void CanDetectWhenRoundRobinRoundContainsProblematicTie()
        {
            tournament.RegisterPlayerReference("Maru");
            round.SetPlayersPerGroupCount(3);
            tournament.RegisterPlayerReference("Stork");
            tournament.RegisterPlayerReference("Taeja");
            GroupBase group = round.Groups.First();

            foreach (Match match in round.Groups.First().Matches)
            {
                SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
                match.Player1.IncreaseScore(2);
            }

            group.HasProblematicTie().Should().BeTrue();
        }
Beispiel #5
0
        public void DoesNotFlagRoundAsProlematicTieWhenNoProblematicTieHappens()
        {
            round.SetPlayersPerGroupCount(3);
            tournament.RegisterPlayerReference("Maru");
            tournament.RegisterPlayerReference("Stork");
            tournament.RegisterPlayerReference("Taeja");

            GroupBase group = round.Groups.First();
            Match     match;

            match = round.Groups.First().Matches[0];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player1.IncreaseScore(2);

            match = round.Groups.First().Matches[1];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player2.IncreaseScore(2);

            match = round.Groups.First().Matches[2];
            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
            match.Player1.IncreaseScore(2);

            group.HasProblematicTie().Should().BeFalse();
        }