Exemple #1
0
 /// <summary>
 /// Cuts the deck of cards at the given location
 /// </summary>
 /// <param name="location">the location at which to cut the deck</param>
 public void Cut(int location)
 {
     int cutIndex = cards.Count - location;
     Card[] newCards = new Card[cards.Count];
     cards.CopyTo(cutIndex, newCards, 0, location);
     cards.CopyTo(0, newCards, location, cutIndex);
     cards.Clear();
     cards.InsertRange(0, newCards);
 }
Exemple #2
0
 /// <summary>
 /// Gets the Blackjack value for the given card
 /// </summary>
 /// <param name="card">the card</param>
 /// <returns>the Blackjack value for the card</returns>
 private int GetBlackjackCardValue(Card card)
 {
     switch (card.Rank)
     {
         case Rank.Ace:
             return 11;
         case Rank.King:
         case Rank.Queen:
         case Rank.Jack:
         case Rank.Ten:
             return 10;
         case Rank.Nine:
             return 9;
         case Rank.Eight:
             return 8;
         case Rank.Seven:
             return 7;
         case Rank.Six:
             return 6;
         case Rank.Five:
             return 5;
         case Rank.Four:
             return 4;
         case Rank.Three:
             return 3;
         case Rank.Two:
             return 2;
         default:
             return 0;
     }
 }
Exemple #3
0
        private void dealACard(string N = "Player")
        {
            if (N == "Player")
            {
                // player
                tmpCard = deck.TakeTopCard();
                tmpCard.FlipOver();
                tmpCard.X = HORIZONTAL_CARD_OFFSET;
                tmpCard.Y = (playerHand.Count * VERTICAL_CARD_SPACING) + TOP_CARD_OFFSET;
                playerHand.Add(tmpCard);

                messages[0].Text = SCORE_MESSAGE_PREFIX + GetBlackjackScore(playerHand).ToString();

                playerHit = true;

            }
            else
            {
                // dealer
                tmpCard = deck.TakeTopCard();
                tmpCard.FlipOver();
                tmpCard.X = WINDOW_WIDTH - HORIZONTAL_CARD_OFFSET;
                tmpCard.Y = (TOP_CARD_OFFSET) + (dealerHand.Count * VERTICAL_CARD_SPACING);
                dealerHand.Add(tmpCard);

                messages[1].Text = SCORE_MESSAGE_PREFIX + GetBlackjackScore(dealerHand).ToString();

                dealerHit = true;

            }
        }