예제 #1
0
        static void TestCanDefendMethod()
        {
            Deck d = new Deck();

            d.Shuffle();
            Card c2 = d.DetermineTrump();

            //just for testing display trump card
            Console.WriteLine("The trump card is: " + d.DisplayTrumpCard());
            FoolHand fh = new FoolHand();
            PlayHand ph = new PlayHand();

            fh.DrawUpToSixCards(fh, d);

            Console.WriteLine("Current Fool Hand.  Expecting 6 cards.\n" + fh);

            Card c = fh.Attack(1, fh, ph);

            Console.WriteLine("Test AttackDefendPlay method");
            Console.WriteLine("Attacking with a card at index '0'.\n" + c);

            Card c3 = fh.Defend(fh, c, c2);

            Console.WriteLine("Defending with a card from the deck.\n" + c3);
            Console.WriteLine("Current Fool Hand.  Expecting 4 cards left in a hand:\n" + fh);

            bool canDefend = fh.CanDefend(fh, c, c2);

            Console.WriteLine("Checking if a player can defend.\n" + canDefend);
            Console.WriteLine("Current Fool Hand.  Expecting 4 cards left in a hand:\n" + fh);

            ph.AddCardToPlayHand(ph, fh, c);
            ph.AddCardToPlayHand(ph, fh, c3);
            Console.WriteLine("Current Play Hand.  Expecting 2 cards in a hand:\n" + ph);
            Console.WriteLine("Number of cards in the PlayHand.  Expecting 2 cards:\n" + ph.NumCards);

            DiscardHand dh = new DiscardHand();

            Console.WriteLine("Number of cards in the DiscardHand.  Expecting 2 cards:\n" + dh.AddToDiscardPile(dh, ph));
            ph.DiscardAll();
            Console.WriteLine("Number of cards in the PlayHand.  Expecting 0 cards after DiscardAll():\n" + ph.NumCards);
            dh.DiscardAll();
            Console.WriteLine("Number of cards in the DiscardHand.  Expecting 0 cards after DiscardAll():\n" + dh.NumCards);
        }