Beispiel #1
0
        public void Player(List <Card> cards)
        {
            int index  = 0;
            int column = 1;

            foreach (Card c in cards)
            {
                playerCardtotal += (int)Enum.Parse(typeof(Card.Rank), Enum.GetName(typeof(Card.Rank), c.CardRank));
                DrawCard.Draw(column == 1 ? 2 : column, 4, cards[index], false);

                index++;
                column *= 14;
            }

            string dealer = string.Format("PLAYER's HAND ({0}):", playerCardtotal);

            DrawCard.WriteAt(dealer, 2, 2);

            //Check if player had a blackjack.
            //Evaluations.BlackJack(playerCardtotal, dealerCardTotal);
            //if (playerCardtotal == 21)
            //    RevealDownCard();

            //Check if player bust.
            Evaluations.PlayerBust(playerCardtotal, dealerCardTotal);
        }
Beispiel #2
0
        public void Dealer(List <Card> cards)
        {
            int index  = 0;
            int column = 1;

            foreach (Card c in cards)
            {
                //Check if second card.
                if (index == 1)
                {
                    DrawCard.Draw(column, 16, cards[index], true);
                }
                else
                {
                    //Get first card total only.
                    firstCardTotal += (int)Enum.Parse(typeof(Card.Rank), Enum.GetName(typeof(Card.Rank), c.CardRank));

                    //Ternary operator align column to 0 because initial value must be 1 in order to multiply by 12.
                    DrawCard.Draw(column == 1 ? 2: column, 16, cards[index], false);
                }

                //Dealer's down card.
                downCard = cards[1];
                index++;
                column *= 14;
            }

            string dealer = string.Format("DEALER's HAND ({0}):", firstCardTotal);

            DrawCard.WriteAt(dealer, 2, 14);

            //Check if dealer bust.
            Evaluations.DealerBust(playerCardtotal, dealerCardTotal);
        }
Beispiel #3
0
        private void AddCard(Card card, int newColumn, int row, int actor)
        {
            int column = 26;

            if (actor == player)
            {
                playerCardtotal += (int)Enum.Parse(typeof(Card.Rank), Enum.GetName(typeof(Card.Rank), card.CardRank));
            }
            else if (actor == dealer)
            {
                dealerCardTotal += (int)Enum.Parse(typeof(Card.Rank), Enum.GetName(typeof(Card.Rank), card.CardRank));
            }
            DrawCard.Draw(column + newColumn, row, card, false);
        }