예제 #1
0
        /// <summary>
        /// Makes one player play a round
        /// </summary>
        /// <param name="player">The player asking for a card</param>
        /// <param name="playerToAsk">The player being asked for a card</param>
        /// <param name="valueToAskFor">The value to ask the player for</param>
        /// <param name="stock">The stock to draw cards from</param>
        /// <returns>A message that describes what just happened</returns>
        public string PlayRound(Player player, Player playerToAsk,
                                Values valueToAskFor, Deck stock)
        {
            var valuePlural = (valueToAskFor == Values.Six) ? "Sixes" : $"{valueToAskFor}s";
            var message     = $"{player.Name} asked {playerToAsk.Name}"
                              + $" for {valuePlural}{Environment.NewLine}";
            var cards = playerToAsk.DoYouHaveAny(valueToAskFor, stock);

            if (cards.Count() > 0)
            {
                player.AddCardsAndPullOutBooks(cards);
                message += $"{playerToAsk.Name} has {cards.Count()}"
                           + $" {valueToAskFor} card{Player.S(cards.Count())}";
            }
            else if (stock.Count == 0)
            {
                message += $"The stock is out of cards";
            }
            else
            {
                player.DrawCard(stock);
                message += $"{player.Name} drew a card";
            }

            if (player.Hand.Count() == 0)
            {
                player.GetNextHand(stock);
                message += $"{Environment.NewLine}{player.Name} ran out of cards,"
                           + $" drew {player.Hand.Count()} from the stock";
            }

            return(message);
        }
예제 #2
0
 public static void DrawCardIfHandIsEmpty(Player player)
 {
     if (player.HandIsEmpty())
     {
         player.DrawCard(deck);
     }
 }
예제 #3
0
        public static void GoFish(Player player1, Player player2, Faces face)
        {
            if (face == Faces.Six)
            {
                Console.WriteLine("{0} doesn't have any {1}es. Go Fish!", player2.Name, face);
            }
            else
            {
                Console.WriteLine("{0} doesn't have any {1}s. Go Fish!", player2.Name, face);
            }
            player1.DrawCard(deck);

            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }