} // end CheckTurnOver /// <summary> /// Finds correct table and adds all the cards in the stack to the table /// </summary> /// <param name="played"></param> /// <param name="destination"></param> private static void AddToTable(Card[] played, Card destination) { // if ((tableau1.GetCount() != 0) && (tableau1.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau1.Add(played[i]); tableCardsInPlay[1]++; } } else if ((tableau2.GetCount() != 0) && (tableau2.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau2.Add(played[i]); tableCardsInPlay[2]++; } } else if ((tableau3.GetCount() != 0) && (tableau3.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau3.Add(played[i]); tableCardsInPlay[3]++; } } else if ((tableau4.GetCount() != 0) && (tableau4.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau4.Add(played[i]); tableCardsInPlay[4]++; } } else if ((tableau5.GetCount() != 0) && (tableau5.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau5.Add(played[i]); tableCardsInPlay[5]++; } } else if ((tableau6.GetCount() != 0) && (tableau6.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau6.Add(played[i]); tableCardsInPlay[6]++; } } else if ((tableau7.GetCount() != 0) && (tableau7.GetLastCardInPile() == destination)) { for (int i = 0; i < played.Length; i++) { tableau7.Add(played[i]); tableCardsInPlay[7]++; } } }
/// <summary> /// Swaps the deck and discard if the deck has run out of cards, then /// places the last card from the discard pile back onto the discard deck /// </summary> public static void DeckDiscardSwap() { if (deck.GetCount() == 0) { deck = discard; deck.RemoveLastCard(); Card card = discard.GetLastCardInPile(); discard = new CardPile(); discard.AddCard(card); } }
public void TestGetLastCardInPileAfterAddCard() { CardPile pile = new CardPile(); pile.AddCard(new Card(Suit.Clubs, FaceValue.Ace)); Assert.IsTrue( pile.GetLastCardInPile().Equals(new Card(Suit.Clubs, FaceValue.Ace)) ); pile.AddCard(new Card(Suit.Hearts, FaceValue.Seven)); Assert.IsTrue( pile.GetLastCardInPile().Equals(new Card(Suit.Hearts, FaceValue.Seven)) ); }
} // end DealStart /// <summary> /// Checks if clicked card is allowed to be played and play the card /// </summary> /// <param name="card"></param> /// <param name="hand"></param> /// <returns></returns> public static bool IsGoodClick(Card card, Suit suit) { Card discard = discardPile.GetLastCardInPile(); // check if the clicked card has a playable suit, facevalue or is an eight if ((card.GetSuit() == suit) || (card.GetFaceValue() == discard.GetFaceValue()) || (card.GetFaceValue() == FaceValue.Eight)) { hands[1].Remove(card); discardPile.Add(card); return(true); } else { return(false); } // end if } // end IsGoodClick
/// <summary> /// Place a card in a Suit Pile /// </summary> /// <param name="played"></param> /// <param name="destination"></param> private static void SuitPlace(Card played, Card destination) { if ((suitPileOne.GetCount() != 0) && (suitPileOne.GetLastCardInPile().GetSuit() == destination.GetSuit())) { suitPileOne.Add(played); } else if ((suitPileTwo.GetCount() != 0) && (suitPileTwo.GetLastCardInPile().GetSuit() == destination.GetSuit())) { suitPileTwo.Add(played); } else if ((suitPileThree.GetCount() != 0) && (suitPileThree.GetLastCardInPile().GetSuit() == destination.GetSuit())) { suitPileThree.Add(played); } else if ((suitPileFour.GetCount() != 0) && (suitPileFour.GetLastCardInPile().GetSuit() == destination.GetSuit())) { suitPileFour.Add(played); } }
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(); }
private void Displaydiscard() { CardPile dis = Solitaire_Game.get_discardPile(); if (dis.GetCount() > 0) { Discard_Pile_pictureBox1.Image = Games.Images.GetCardImage(dis.GetLastCardInPile()); } else if (dis.GetCount() == 0) { Discard_Pile_pictureBox1.Image = null; } }
//Create Discard Pile from Draw Pile Last Card public static CardPile SetDiscardPile(CardPile drawPile) { //Declare new card pile CardPile discardPile = new CardPile(); //Retrieve last card from draw pile and add it to the discard pile Card lastCard = drawPile.GetLastCardInPile(); discardPile.AddCard(lastCard); //Remove the last card from the draw pile drawPile.RemoveLastCard(); //return the discard pile return(discardPile); }
//Method DistoSuit(num). //This method moves the Ace card from the Discard pile to the Suit Piles. public static bool DisToSuit(int num) { num--; // if discard not null if (discardPile.GetCount() == 0) { return(false); } //if ace if (checkvalue(discardPile.GetLastCardInPile()) == 1 && suitPiles[num].GetCount() == 0 ) { suitPiles[num].Add(discardPile.DealLastOneCard()); return(true); } //if not ace else { // if suit is null if (suitPiles[num].GetCount() == 0) { return(false); } //if facevalue is the same and value difference is 1 if (Check_Position(suitPiles[num].GetLastCardInPile(), discardPile.GetLastCardInPile()) && suitPiles[num].GetLastCardInPile().GetSuit().Equals(discardPile.GetLastCardInPile().GetSuit()) ) { suitPiles[num].Add(discardPile.DealLastOneCard()); return(true); } return(false); } }
/// <summary> /// /// </summary> /// <returns></returns> public static Card GetTopDiscard() { return(discardPile.GetLastCardInPile()); }