Ejemplo n.º 1
0
        } //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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the player to play a card if they have a valid card in hand,
        /// and if the card chosen is a playable card
        /// Pre: there must be a discard pile and cards in a user's hand
        /// Post: Will place down a card ontop of the discard pile and remove that card from hand
        /// </summary>
        public static int PickACard(int player, string CardToPlay)
        {
            bool ValidCard = false;


            while (!ValidCard)
            {
                if (ConsoleGame)
                {
                    Trace.Write("\nPick One Of Your Cards Or Enter S to Sort Your Cards: ");
                }
                else
                {
                    Trace.Write("Pick A Card");
                }
                if (ConsoleGame)
                {
                    CardToPlay = Console.ReadLine().ToUpper();
                }


                int Index = CheckIfValidCard(CardToPlay, currentSuit, player);
                //If there is a valid card it will play that card and remove it from hand
                if (Index > INVALIDCARDS)
                {
                    discardPile.Add(hands[player].GetCard(Index));
                    DisplayDiscardPileTopCard();
                    hands[player].RemoveAt(Index);
                    ValidCard = true;
                    //Sorts the players hand
                }
                else if (Index == SORTCARDS)
                {
                    hands[player].Sort();
                    DisplayHand(player);
                    //For Console Games
                }
                else if (Index == INVALIDCARDS && !ConsoleGame)
                {
                    ValidCard = true;
                    return(INVALIDCARDS);
                }
            }
            return(AVALIDCARD);
        }
Ejemplo n.º 3
0
        /// <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();
            }
        }