Beispiel #1
0
        public bool AskForCard(Player player1, Player player2, Values value)
        {
            var questionString = new StringBuilder();

            questionString.Append(Name + " asked for " + value + "s\n");
            var result = false;

            if (player1.HasCard(value))
            {
                questionString.Append(string.Format("{0} has {1} of {2}s\n", player1.Name, TakeCard(player1, value),
                                                    value));
                result = true;
            }
            else
            {
                questionString.Append(player1.Name + " has 0 " + value + "s\n");
            }
            if (player2.HasCard(value))
            {
                questionString.Append(string.Format("{0} has {1} of {2}s\n", player2.Name, TakeCard(player2, value),
                                                    value));
                result = true;
            }
            else
            {
                questionString.Append(player2.Name + " has 0 " + value + "s\n");
            }

            Question = questionString.ToString();
            return(result);
        }
Beispiel #2
0
 public bool AskForCards(Player other_player, Faces face)
 {
     // If the other player has a card of the face you're asking for, they must give the card to you
     if (other_player.HasCard(face))
     {
         other_player.GiveCards(this, face);
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        public static Faces ChooseFace(Player player)
        {
            // Reads in player's choice of face to ask other player for
            Console.Write("What card face would you like to ask for?\nEnter face here (ex. Two): ");
            string face_str = Console.ReadLine();

            Console.WriteLine();

            while (!player.HasCard(face_str))
            {
                if (str_list.Contains(face_str))
                {
                    if (face_str == "Six")
                    {
                        Console.Write("You don't have hany {0}es. Please choose a face from your hand.\nEnter face: ", face_str);
                    }
                    else
                    {
                        Console.Write("You don't have hany {0}s.  Please choose a face from your hand.\nEnter face: ", face_str);
                    }
                    face_str = Console.ReadLine();
                    Console.WriteLine();
                }
                else
                {
                    Console.Write("{0} is not a valid face.\nPlease enter a valid face here (ex. Ace, Two, Three...): ", face_str);
                    face_str = Console.ReadLine();
                    Console.WriteLine();
                }
            }

            Console.WriteLine();

            Faces face = (Faces)Enum.Parse(typeof(Faces), face_str);

            return(face);
        }