Example #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);
        }
Example #2
0
        static void TestCanAttackAgainMethod()
        {
            Deck d = new Deck();

            d.Shuffle();

            FoolHand fh = new FoolHand();
            CompHand ch = new CompHand();
            PlayHand ph = new PlayHand();

            Card tc = d.DetermineTrump();

            ch.DrawUpToSixCards(ch, d);
            ch.CompSortCards(ch, tc);
            fh.DrawUpToSixCards(fh, d);
            fh.SortCards(fh, tc);

            Card lastCard = d.GetCard(d.NumCards - 1);

            Console.WriteLine("Test CanAttackAgain method");
            Console.WriteLine("Determining a trump card.  The trump card (Suit) is: " + tc);
            Console.WriteLine("Last card in the deck - should be the same as the trump card: " + lastCard);
            Console.WriteLine("Current FoolHand.  Expecting 6 cards.\n" + fh);
            Console.WriteLine("Current CompHand.  Expecting 6 cards.\n" + ch);
            Card attkCard = ch.Attack(0, ch, ph);

            Console.WriteLine("Computer attacking a player with: " + attkCard);
            ph.AddCardToPlayHand(ph, fh, attkCard);

            Card defCard = fh.Defend(fh, attkCard, tc);

            Console.WriteLine("Player is defending with the following card: " + defCard);
            ph.AddCardToPlayHand(ph, fh, defCard);

            Console.WriteLine("Current FoolHand.  Expecting 5 cards.\n" + fh);
            Console.WriteLine("Current CompHand.  Expecting 5 cards.\n" + ch);

            Console.WriteLine("Current PlayHand:\n" + ph);
            Console.WriteLine("Checking if compuetr can attack again: " + ch.CanAttackAgain(ch, ph));
        }