Exemplo n.º 1
0
        public bool TransferToNextRound(RoundBase currentRound)
        {
            bool roundHasFinished = currentRound.GetPlayState() == PlayStateEnum.Finished;

            if (roundHasFinished)
            {
                RoundBase nextRound            = currentRound.GetNextRound();
                bool      hasRoundToTransferTo = nextRound != null;

                if (hasRoundToTransferTo)
                {
                    PlayerReferences = currentRound.GetAdvancingPlayerReferences();
                    bool hasPlayerReferencesToTransfer = PlayerReferences.Count > 0;

                    if (hasPlayerReferencesToTransfer)
                    {
                        nextRound.ReceiveTransferedPlayerReferences(this);
                        return(true);
                    }

                    // LOG Error: Tried to transfer advancing player references to next round without any player references.
                    return(false);
                }

                // LOG Error: Tried to transfer advancing player references to nonexistent next round.
                return(false);
            }

            // LOG Error: Tried to transfer advancing player references to next round before current round is finished.
            return(false);
        }
Exemplo n.º 2
0
        public void FetchingNextRoundWithLastRoundYieldsNull()
        {
            RoundBase firstRound  = tournament.AddRoundRobinRound();
            RoundBase secondRound = tournament.AddRoundRobinRound();

            RoundBase nextRound = secondRound.GetNextRound();

            nextRound.Should().BeNull();
        }
Exemplo n.º 3
0
        public void CanFetchRoundAfterThisRound()
        {
            RoundBase firstRound  = tournament.AddRoundRobinRound();
            RoundBase secondRound = tournament.AddRoundRobinRound();

            RoundBase nextRound = firstRound.GetNextRound();

            nextRound.Should().Be(secondRound);
        }
Exemplo n.º 4
0
        public void GivenPlayersIsRegisteredToRound(string commaSeparatedPlayerNames, int tournamentIndex)
        {
            List <string> playerNames = StringUtility.ToStringList(commaSeparatedPlayerNames, ",");
            Tournament    tournament  = createdTournaments[tournamentIndex];

            foreach (string playerName in playerNames)
            {
                tournament.RegisterPlayerReference(playerName);
            }

            RoundBase round = tournament.GetFirstRound();

            createdGroups.Clear();
            while (round != null)
            {
                createdGroups.AddRange(round.Groups);
                round = round.GetNextRound();
            }
        }