Exemplo n.º 1
0
        public static void hitForCurrentPlayer()
        {
            // track the player that took an action
            Player player = null;

            // draw a random card from active deck
            Card drawnCard = ActiveDeck.drawCard();

            updateActiveDeckCount();

            // get current player
            if (PlayerTurnIndex == Players.Count)
            {
                // no more players to iterate.
                // its the dealer's turn
                // give dealer the drawn card
                player = TableDealer;
            }
            else
            {
                // give card to player
                // retrieve the player
                player = Players[PlayerTurnIndex];
            }

            // give card to player
            player.receiveCard(drawnCard);
        }
Exemplo n.º 2
0
        public void RandomCardDraw_ReturnsVoid()
        {
            // Arrange
            const int           CARDS_DRAWN = 3;
            List <List <Card> > drawSeq     = new List <List <Card> >();

            // Act
            for (int i = 0; i < 2; i++)
            {
                drawSeq.Add(new List <Card>());
                ActiveDeck activeDeck = new ActiveDeck();
                activeDeck.createDeck(); // creates a fresh deck of 52 cards of the same sequence
                // draw 3 cards
                for (int j = 0; j < CARDS_DRAWN; j++)
                {
                    drawSeq[i].Add(activeDeck.drawCard());
                }
            }

            // determine sequencing
            bool equalSequence = true;

            for (int cardSequence = 0; cardSequence < CARDS_DRAWN; cardSequence++)
            {
                if (drawSeq[0][cardSequence].getId() != drawSeq[1][cardSequence].getId())
                {
                    equalSequence = false;
                    break;
                }
            }

            // Assert
            Assert.IsFalse(equalSequence);
        }
Exemplo n.º 3
0
        private static void dealInititalHand()
        {
            // give out 2 cards to dealer
            for (int i = 0; i < Settings.initialCardDrawCount; i++)
            {
                Card card = ActiveDeck.drawCard();
                updateActiveDeckCount();
                TableDealer.receiveCard(card);
            }

            // give out 2 cards to each player
            Players.ForEach(player =>
            {
                for (int i = 0; i < Settings.initialCardDrawCount; i++)
                {
                    Card card = ActiveDeck.drawCard();
                    updateActiveDeckCount();
                    player.receiveCard(card);
                }
            });
        }