} //end SetUpGame /// <summary> /// Sets up the discard pile so that the first card is the top card of the draw deck, /// also the current suit is changed to that of the top cards /// Pre: drawpile needs to be initialised /// Post: Displays the Top card of the Discard pile and changes the current suit /// </summary> private static void SetUpTheDiscardPile() { discardPile = new CardPile(); //discardPile.Add(new Card(Suit.Hearts, FaceValue.Eight)); discardPile.Add(drawPile.DealOneCard()); DisplayDiscardPileTopCard(); currentSuit = discardPile.GetLastCardInPile().GetSuit(); }
/// <summary> /// Adds a card to the players hand /// Pre: If the user or dealer isn't at 21 or they havent stood /// Post: Deals a card to the user and then returns the new handvalue of the player /// </summary> public static int AddCard(int player) { hands[player].Add(cardPile.DealOneCard()); Trace.WriteLine("\nDealing a Card"); DisplayHand(player); return(HandValue(player)); }
/// <summary> /// Checks the drawpile if there is anymore cards left in it, if not it will flip discard pile over, /// and make it become the new drawpile /// Pre: Drawpile must be initialised and is called when a player picks up a card /// Post: Flips the discard pile making it the new draw pile and displays the new discard pile card. /// </summary> public static void CheckDrawPile() { int CardsinDiscardpile = discardPile.GetCount(); if (drawPile.GetCount() == 0) { Trace.WriteLine("\nThere are no more cards in the draw pile, Turning Over the DiscardPile"); for (int i = 0; i < CardsinDiscardpile; i++) { drawPile.Add(discardPile.DealOneCard()); } discardPile.Add(drawPile.DealOneCard()); currentSuit = discardPile.GetLastCardInPile().GetSuit(); DisplayDiscardPileTopCard(); } }