예제 #1
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>());
        }
예제 #2
0
        public void ThenPlayStateOfGroupIsSetTo(int groupIndex, string playStateString)
        {
            GroupBase group = createdGroups[groupIndex];

            PlayStateEnum playState = ParsePlayStateString(playStateString);

            group.GetPlayState().Should().Be(playState);
        }
예제 #3
0
        public void GivenGroupsWithinTournamentIsPlayedOutAndBettedOn(Table table)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            foreach (TableRow row in table.Rows)
            {
                TestUtilities.ParseTargetGroupToPlay(row, out int tournamentIndex, out int roundIndex, out int groupIndex);

                bool tournamentIndexIsValid = createdTournaments.Count > tournamentIndex;
                bool roundIndexIsValid      = createdTournaments[tournamentIndex].Rounds.Count > roundIndex;
                bool groupIndexIsValid      = createdTournaments[tournamentIndex].Rounds[roundIndex].Groups.Count > groupIndex;

                if (!tournamentIndexIsValid || !roundIndexIsValid || !groupIndexIsValid)
                {
                    throw new IndexOutOfRangeException("Tournament, round, or group with given index does not exist");
                }

                SystemTimeMocker.Reset();
                Tournament tournament = createdTournaments[tournamentIndex];
                RoundBase  round      = tournament.Rounds[roundIndex];
                GroupBase  group      = round.Groups[groupIndex];

                while (group.GetPlayState() != PlayStateEnum.Finished)
                {
                    bool tournamentHasBetters = tournament.Betters.Count > 0;
                    if (tournamentHasBetters)
                    {
                        PlaceBetsOnAvailableMatchesInGroup(tournament.Betters, group);
                    }

                    foreach (Match match in group.Matches)
                    {
                        if (match.IsReady() && match.GetPlayState() == PlayStateEnum.NotBegun)
                        {
                            SystemTimeMocker.SetOneSecondAfter(match.StartDateTime);
                            break;
                        }
                    }

                    bool playedMatchesSuccessfully = PlayAvailableMatches(group);

                    if (!playedMatchesSuccessfully)
                    {
                        break;
                    }
                }
            }
        }
예제 #4
0
        public void RoundIsOngoingUntilTieIsSolved()
        {
            tournament.RegisterPlayerReference("Maru");
            tournament.RegisterPlayerReference("Stork");
            round.SetPlayersPerGroupCount(3);
            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.GetPlayState().Should().Be(PlayStateEnum.Ongoing);
        }