예제 #1
0
        public void Discard5(ITargetablePlayerState targetPlayer, IList <IDrawableCardState> deck, IList <ISetAsideCardState> setAside)
        {
            var discarded = _cardStateFactory.Discard(targetPlayer.RoundHand);

            targetPlayer.RoundDiscard.Add(discarded);
            var newCard = deck.Any() ?
                          _cardStateFactory.Draw(deck) :
                          _cardStateFactory.Draw(setAside);

            targetPlayer.RoundHand = newCard;
        }
예제 #2
0
        public static IDiscardableCardState Draw(this ICardStateFactory cardStateFactory, IList <IDrawableCardState> deck)
        {
            var drawableCardState = deck.RemoveLast();
            var result            = cardStateFactory.Draw(drawableCardState);

            return(result);
        }
예제 #3
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);
        }
예제 #4
0
        public void Draw(IDrawableTurnState turn)
        {
            var card = _cardStateFactory.Draw(turn.TurnDeck);

            turn.DrawablePlayerState.TurnHand.Add(card);
        }