示例#1
0
文件: Hand.cs 项目: aphim/Durak-Game
        /// <summary>
        /// Function used for displaying the hand in the GUI
        /// </summary>
        /// <returns>the hand in a string format</returns>
        public override string ToString()
        {
            String tempString = "";

            //loops through the hand
            for (int i = 0; i < this.gethandSize(); i++)
            {
                //displays the current card
                Card tempCard = this.GetCard(i);

                tempString += " " + tempCard.ToString();
            }
            return(tempString);
        }
示例#2
0
文件: Field.cs 项目: aphim/Durak-Game
 /// <summary>
 /// Method used to display the discard pile
 /// </summary>
 public void displayDiscarded()
 {
     //loops through the discard pile
     for (int i = 0; i < this.getDiscard().Count; i++)
     {
         //displays the current card
         Card tempCard = (Card)this.getDiscard()[i];
         Console.Write(tempCard.ToString());
         if (i != this.getDiscard().Count - 1)
         {
             Console.Write(", ");
         }
         else
         {
             Console.WriteLine();
         }
     }
 }
示例#3
0
文件: Deck.cs 项目: aphim/Durak-Game
 /// <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();
         }
     }
 }
示例#4
0
文件: Hand.cs 项目: aphim/Durak-Game
 /// <summary>
 /// Method used to display the current hand
 /// </summary>
 public void displayHand()
 {
     //loops through the hand
     for (int i = 0; i < this.gethandSize(); i++)
     {
         //displays the current card
         Card tempCard = this.GetCard(i);
         Console.Write(tempCard.ToString());
         if (i != this.gethandSize() - 1)
         {
             Console.Write(", ");
         }
         else
         {
             Console.WriteLine();
         }
     }
 }
示例#5
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);
                }
            }
        }