}//end of IncrementNumOfUserAces /// <summary> /// Resets variables. /// </summary> public static void ResetTotals() { ReplacementCards(4); hands[0] = new Hand(cardPile.DealCards(2)); hands[1] = new Hand(cardPile.DealCards(2)); totalPoints[0] = 0; totalPoints[1] = 0; numOfUserAcesWithValueOne = 0; }//end of ResetTotals
/// <summary> /// Fill the Tableaus with Cards /// </summary> private static void FillTableaus() { const int LENGTH_OF_TABLEAUS_ARRAY = 7; for (int i = 0; i < LENGTH_OF_TABLEAUS_ARRAY; i++) { List <Card> tableauCards = cardPile.DealCards(i + 1); tableaus[i] = new Hand(tableauCards); } }
/// <summary> /// Instantiates all the games variables, used in the setup function. Sets hands, deck and discard /// </summary> private static void DealInitial() { List <Card> hand1 = deck.DealCards(8); List <Card> hand2 = deck.DealCards(8); discard.AddCard(deck.DealOneCard()); playerHand = new Hand(hand1); compHand = new Hand(hand2); SetLegalMove(discard.GetLastCardInPile()); }
/// <summary> /// a /// </summary> public static void StartGame() { _canplay = true; IsUserTurn = true; _drawPile = new CardPile(true); _drawPile.ShufflePile(); _discardPile = new CardPile(); UserHand = new Hand(_drawPile.DealCards(8)); ComputerHand = new Hand(_drawPile.DealCards(8)); _discardPile.AddCard(_drawPile.DealOneCard()); }
static int maxHandSize = 13; //maximum hand size /// <summary> /// Sets up the game from the starting point, 8 cards per player, /// and a card added to the discard deck /// </summary> public static void SetupGame() { deck = new CardPile(true); deck.ShufflePile(); discard = new CardPile(); discard.AddCard(deck.DealOneCard()); int startHand = 8; playerHand = new Hand(deck.DealCards(startHand)); compHand = new Hand(deck.DealCards(startHand)); legalMove = discard.GetLastCardInPile(); }
}// End DisplayGuiHand /// <summary> /// Used for testing and left for reference. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void testButton_Click(object sender, EventArgs e) { const int testNumOfCardsForDealer = 2; const int testNumOfCardsForPlayer = 8; CardPile testCardPile = new CardPile(true); testCardPile.Shuffle(); Hand testHandForDealer = new Hand(testCardPile.DealCards(testNumOfCardsForDealer)); Hand testHandForPlayer = new Hand(testCardPile.DealCards(testNumOfCardsForPlayer)); DisplayGuiHand(testHandForDealer, dealerTableLayoutPanel); DisplayGuiHand(testHandForPlayer, playerTableLayoutPanel); }
public static void SetUpGame() { cardpile = new CardPile(); hand[0] = null; hand[1] = null; totalPoints[0] = 0; totalPoints[1] = 0; numOfGamesWon[0] = 0; numOfGamesWon[1] = 0; numOfUserAcesWithValueOne[0] = 0; numOfUserAcesWithValueOne[1] = 0; cardpile = new CardPile(true); cardpile.Shuffle(); hand[0] = new Hand(cardpile.DealCards(2)); hand[1] = new Hand(cardpile.DealCards(2)); }
public static List <Card> FullDeckInOrder() { CardPile cardPile = new CardPile(true); List <Card> allCards = cardPile.DealCards(cardPile.GetCount()); allCards.Reverse(); return(allCards); }
public static void NewRound() { _deck = new CardPile(fullDeck: true); _deck.ShufflePile(); _playerHand = new Hand(); _dealerHand = new Hand(); foreach (Card card in _deck.DealCards(STARTING_HAND_SIZE)) { _playerHand.AddCard(card); } foreach (Card card in _deck.DealCards(STARTING_HAND_SIZE)) { _dealerHand.AddCard(card); } }
//Return hand with dealt cards from the drawPile public static Hand DealCards(CardPile drawPile) { //Deal 8 cards and add them to the contructor of the Hand class List <Card> cards = new List <Card>(drawPile.DealCards(8)); Hand hand = new Hand(cards); //return cards return(hand); }
// Private helper methods to setup the game /// <summary> /// Initializes hand objects in the tableauPiles array /// including dealing number of cards reqiured for initial board layout /// </summary> private static void SetupTableau() { int numOfCards; for (int tableauNo = 0; tableauNo < NUM_OF_TABLEAU; tableauNo++) { // Each hand of cards contains the array position + 1 number of cards numOfCards = tableauNo + 1; tableauPiles[tableauNo] = new Hand(drawPile.DealCards(numOfCards)); } }
/// <summary> /// Sets up the solitare game from beginning /// </summary> public static void SetupGame() { deck = new CardPile(true); deck.ShufflePile(); for (int i = 0; i < numOfHands; i++) { playRevealed[i] = i; Hand temp = new Hand(deck.DealCards(i + 1)); playHands.Add(temp); } current.AddCard(deck.DealOneCard()); }
/// <summary> /// Attempts to draw a Card into the given Hand. /// </summary> /// <param name="hand"></param> /// <returns></returns> private static ActionResult DrawCard(Hand hand) { Hand otherHand; if (IsUserTurn) { otherHand = ComputerHand; } else { otherHand = UserHand; } if (IsHandPlayable(hand) == true) { return(ActionResult.CannotDraw); } else if ((IsDrawPileEmpty == true) && (IsHandPlayable(hand) == false)) { foreach (Card card in _discardPile.DealCards(_discardPile.GetCount())) { _drawPile.AddCard(card); } _discardPile.AddCard(_drawPile.DealOneCard()); return(ActionResult.FlippedDeck); } hand.AddCard(_drawPile.DealOneCard()); if (hand.GetCount() == 13 && (IsHandPlayable(hand) == false)) { if ((IsHandPlayable(hand) == false) && (hand.GetCount() == 13) && (IsHandPlayable(otherHand) == false) && otherHand.GetCount() == 13) { IsPlaying = true; IsUserTurn = !IsUserTurn; return(ActionResult.DrewAndResetPiles); } else { IsUserTurn = !IsUserTurn; IsPlaying = true; return(ActionResult.DrewAndNoMovePossible); } } else if (IsHandPlayable(hand) == false) { return(ActionResult.DrewUnplayableCard); } return(ActionResult.DrewPlayableCard); }
/// <summary> /// Setup the game for a new round. /// </summary> public static void SetUpGame() { ensurePlayableCardPile(); const int dealNumOfCardsForAll = 2; numOfUserAcesWithValueOne = 0; hands = new Hand[2]; totalPoints = new int[2]; cardPile.Shuffle(); List <Card> setUpDealCardsForDealer = cardPile.DealCards(dealNumOfCardsForAll); List <Card> setUpCardsForPlayer = cardPile.DealCards(dealNumOfCardsForAll); hands[DEALER] = new Hand(setUpDealCardsForDealer); hands[PLAYER] = new Hand(setUpCardsForPlayer); foreach (Card card in setUpDealCardsForDealer) { FaceValue cardFaceValue = card.GetFaceValue(); addPlayerPoints(DEALER, cardFaceValue); } foreach (Card card in setUpCardsForPlayer) { FaceValue cardFaceValue = card.GetFaceValue(); addPlayerPoints(PLAYER, cardFaceValue); if (card.GetFaceValue() == FaceValue.Ace) { IncrementNumOfUserAcesWithValueOne(); } } ensurePlayableCardPile(); }
// Class methods /// <summary> /// Initializes the class variables at start of a new game. /// </summary> public static void SetUpGame() { totalPoints = new int[] { 0, 0 }; numOfUserAcesWithValueOne = 0; //Move this to a method of its own // Create new deck of cards if the pile is empty if (cardPile.GetCount() < (NUM_OF_PLAYERS * INITIAL_HAND_SIZE)) { cardPile = new CardPile(true); cardPile.Shuffle(); } // Shuffle cards cardPile.Shuffle(); // Deal intital hand for player and dealer Hand playerHand = new Hand(cardPile.DealCards(INITIAL_HAND_SIZE)); Hand dealerHand = new Hand(cardPile.DealCards(INITIAL_HAND_SIZE)); // Store dealt cards in hands arrays hands[PLAYER] = playerHand; hands[DEALER] = dealerHand; } // end SetUpGame
public void TestDealCardsAfterAddingCards() { CardPile pile = new CardPile(); List <Card> cardsToAdd = new List <Card> { new Card(Suit.Spades, FaceValue.Ace), new Card(Suit.Clubs, FaceValue.Queen), new Card(Suit.Clubs, FaceValue.Four), new Card(Suit.Hearts, FaceValue.Seven), new Card(Suit.Diamonds, FaceValue.Seven) }; foreach (Card card in cardsToAdd) { pile.AddCard(card); } List <Card> dealtCards = pile.DealCards(4); for (int i = 0; i < 4; i++) { Assert.IsTrue(dealtCards[i].Equals(cardsToAdd[i])); } }