/// <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) { Card[] newCards = new Card[cards.Count]; cards.CopyTo(location, newCards, 0, cards.Count - location); cards.CopyTo(0, newCards, location, location); cards.InsertRange(0, newCards); }
/// <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); }
/// <summary> /// Adds a card to the top of the hand, making sure the card is face down /// </summary> /// <param name="card">the card to add</param> public void AddCard(Card card) { if (card.FaceUp) { card.FlipOver(); } cards.Add(card); // move the card to the hand location card.X = x; card.Y = y; }
/// <summary> /// Adds a card to the top of the battle pile /// </summary> /// <param name="card">the card to add</param> public void AddCard(Card card) { cards.Add(card); // shift top card offset for added card if (cards.Count > 1) { topCardX += (int)(card.Width * CARD_OFFSET_PERCENT); } // move the card to the appropriate location card.X = topCardX; card.Y = y; }
/// <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; } }
private void positionNextPlayerCard(Card card) { card.Y = playerHand[playerHand.Count - 1].DrawRectangle.Bottom + VERTICAL_CARD_SPACING; card.X = HORIZONTAL_CARD_OFFSET; }
private void positionNextDealerCard(Card card) { card.Y = dealerHand[dealerHand.Count - 1].DrawRectangle.Bottom + VERTICAL_CARD_SPACING; card.X = WINDOW_WIDTH - HORIZONTAL_CARD_OFFSET; }