Exemplo n.º 1
0
        public void Game()
        {
            TempCards = new List <Card>();
            Console.WriteLine("Let's play the Drunkard! The rules are very simple:each of the players throws the top card of his deck onto the table." +
                              "A player whose card is older takes all the cards from the table and puts them under the bottom of his deck.Ace is older than all cards except six.");
            Console.WriteLine("Press any key to start the game.");
            Console.ReadKey();
            int count = 0;

            while (Player1.Count != 0 && Player2.Count != 0)
            {
                Console.WriteLine($"\nYour card is: {Player1[0]}. My card is: {Player2[0]}");
                Thread.Sleep(200);
                if ((int)Player1[0].Value > (int)Player2[0].Value)
                {
                    if (Player1[0].Value == CardValue.Ace && Player2[0].Value == CardValue.six)
                    {
                        TakeCards(Player1, Player2);
                        Player2.AddRange(TempCards.GetRange(0, TempCards.Count));
                        TempCards.Clear();
                        Console.WriteLine($"I take your card. There are {Player1.Count} cards in your deck, and {Player2.Count} in mine.");
                    }
                    else
                    {
                        TakeCards(Player2, Player1);
                        Player1.AddRange(TempCards.GetRange(0, TempCards.Count));
                        TempCards.Clear();
                        Console.WriteLine($"You take my card. There are {Player1.Count} cards in your deck, and {Player2.Count} in mine.");
                    }
                }

                else if ((int)Player1[0].Value < (int)Player2[0].Value)
                {
                    if (Player2[0].Value == CardValue.Ace && Player1[0].Value == CardValue.six)
                    {
                        TakeCards(Player2, Player1);
                        Player1.AddRange(TempCards.GetRange(0, TempCards.Count));
                        TempCards.Clear();
                        Console.WriteLine($"You take my card. There are {Player1.Count} cards in your deck, and {Player2.Count} in mine.");
                    }
                    else
                    {
                        TakeCards(Player1, Player2);
                        Player2.AddRange(TempCards.GetRange(0, TempCards.Count));
                        TempCards.Clear();
                        Console.WriteLine($"I take your card. There are {Player1.Count} cards in your deck, and {Player2.Count} in mine.");
                    }
                }

                else
                {
                    EqualCards(Player1, Player2);
                    Console.WriteLine("We have equal cards.These cards will be taken by the player who wins the next turn.");
                }

                if (Player1.Count == 0)
                {
                    Console.WriteLine("You won!");
                }
                else if (Player2.Count == 0)
                {
                    Console.WriteLine("I won!");
                }

                count++;
                if (count > 500)
                {
                    Console.WriteLine("It's too boring. Let's drink better");
                    break;
                }
            }
        }