Example #1
0
 /// <summary>
 /// Display deck method used to display the remaining deck
 /// </summary>
 /// <param name="myDeck"></param>
 public void displayDeck(Deck myDeck)
 {
     //loops through the length of the deck
     for (int i = 0; i < myDeck.getCardsRemaining(); i++)
     {
         //displays the current card
         Card tempCard = myDeck.GetCard(i);
         Console.Write(tempCard.ToString());
         if (i != myDeck.getCardsRemaining() - 1)
         {
             Console.Write(", ");
         }
         else
         {
             Console.WriteLine();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Method used to draw cards from the deck
        /// </summary>
        /// <param name="myDeck">a deck object</param>
        public void DrawCards(Deck myDeck)
        {
            bool   attackerDraw = true;
            string filePath     = @"../../GameLog.txt";
            string tempString   = "";

            //check the remaining deck size

            while (attackerDraw)
            {
                //check to see if there are still cards in the deck
                if (myDeck.getCardsRemaining() > 0)
                {
                    //check if the attacker's hand is greater than 6 (standard hand size)
                    int attackerHandSize = this.playerHand.gethandSize();
                    if (attackerHandSize < 6)
                    {
                        Card drawnCard = myDeck.drawCard();
                        tempString += " " + drawnCard.ToString();
                        //output what card the player drew

                        this.playerHand.addCard(drawnCard);
                    }
                    else
                    {
                        attackerDraw = false;
                    }
                }
                else
                {
                    attackerDraw = false;
                }
            }
            if (tempString != "")
            {
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(this.playerName + " drew:" + tempString);
                }
            }
        }