Ejemplo n.º 1
0
        // Bool is whether or not game is still going on.
        public bool play()
        {
            Player currentP = turnQueue.Dequeue();

            turnQueue.Enqueue(currentP);
            printGame(currentP);
            Console.WriteLine("Pick the card you wish to play:");
            Console.WriteLine();
            Console.WriteLine("0) Don't Play");
            for (int b = 0; b < currentP.hand.Count; b++)
            {
                Console.WriteLine($"{b+1}) {currentP.hand[b].toString()}");
            }
            if (lastCard != null)
            {
                Console.WriteLine("******************************");
                assignColor();
                Console.WriteLine("Last card played is " + lastCard.toString());
                if (lastCard.type.Equals("Wild") || lastCard.type.Equals("Draw 4 Wild"))
                {
                    Console.WriteLine("Color Chosen for Wild was " + lastColor);
                }
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("******************************");
            }
            int  input   = 0;
            bool CanPlay = false;

            while (!CanPlay)
            {
                input = Convert.ToInt32(Console.ReadLine());
                if (input <= 0 || input > currentP.hand.Count)
                {
                    CanPlay = true;
                }
                else if (lastCard == null)
                {
                    CanPlay = true;
                }
                else
                {
                    CanPlay = ValidPlay(currentP.hand[input - 1]);
                }
                if (!CanPlay)
                {
                    Console.WriteLine("Invalid play, please choose another card.");
                }
            }
            if (input <= 0 || input > currentP.hand.Count)
            {
                currentP.draw(deck);
            }
            else
            {
                UnoCard card = currentP.play(input - 1);
                processCard(card);
            }
            if (currentP.hand.Count == 0)
            {
                Console.WriteLine($"{currentP.name} wins!!!!!!!!!!");
                return(false);
            }
            if (deck.cards.Count == 0)
            {
                Console.WriteLine("You all suck, game was a draw.");
                return(false);
            }
            return(true);
        }