Пример #1
0
        public IInitialRoundState CreateRound(IEnumerable <IRoundPlayerState> players)
        {
            IList <IRoundPlayerState>          remainingPlayers = null;
            IList <ISetAsideCardState>         removedFromRound = CreateRemovedFromRound();
            IList <IDrawableCardState>         drawDeck         = null;
            IEnumerable <IShufflableCardState> shufflableDeck   = _deckFactory.Create();
            var round = new RoundState(players,
                                       remainingPlayers,
                                       removedFromRound,
                                       drawDeck,
                                       roundIndex: 0,
                                       winningPlayerState: null,
                                       currentPlayerState: null,
                                       drawableTurnState: null,
                                       discardableTurnState: null,
                                       shufflableDeck: shufflableDeck);

            return(round);
        }
Пример #2
0
        public IRunningRoundState StartRound(IInitialRoundState round)
        {
            var shuffledDeck     = _deckShuffleService.Shuffle(round.ShufflableDeck).ToList();
            var remainingPlayers = _roundFactory.CreateRemainingPlayers();
            var roundPlayers     = round.Players.ToArray();

            foreach (var roundPlayer in roundPlayers)
            {
                roundPlayer.OutOfRound = false;
                roundPlayer.RoundHand  = _cardStateFactory.Draw(shuffledDeck);
                remainingPlayers.Add(roundPlayer);
            }
            var removedFromRound   = _roundFactory.CreateRemovedFromRound();
            var cardsToRemoveCount = _deckRemovalService.GetCardsToRemoveCount(roundPlayers.Count());

            for (int removedCardIndex = 0; removedCardIndex < cardsToRemoveCount; removedCardIndex++)
            {
                var removedCard = _cardStateFactory.SetAside(shuffledDeck);
                removedFromRound.Add(removedCard);
            }
            int roundIndex    = round.RoundIndex;
            var currentPlayer = roundPlayers.First();

            var turnDeck = shuffledDeck.RemoveLast();

            var drawableTurnState = _turnStateFactory.CreateTurn(currentPlayer, turnDeck);
            var runningRound      = new RoundState(roundPlayers,
                                                   remainingPlayers,
                                                   removedFromRound,
                                                   shuffledDeck,
                                                   roundIndex,
                                                   winningPlayerState: null,
                                                   currentPlayerState: currentPlayer,
                                                   drawableTurnState: drawableTurnState,
                                                   discardableTurnState: null,
                                                   shufflableDeck: null);

            return(runningRound);
        }