Example #1
0
        public void TestReset()
        {
            var trick = new Trick();

            trick.AddCard(new Card("J", Suit.DIAMONDS, 1, 0));
            trick.AddCard(new Card("Q", Suit.CLUBS, 10, 1));
            trick.AddCard(new Card("10", Suit.SPADES, 100, 2));
            trick.AddCard(new Card("7", Suit.DIAMONDS, 1000, 3));
            trick.AddValue(42);
            trick.ResetDeck();
            Assert.Equal(0, trick.GetDeck().Count);
            Assert.Equal(0, trick.GetValue());
        }
Example #2
0
        public void TestValue()
        {
            var        player = new Player(0, "PlayerTest", null);
            const Suit trump  = Suit.DIAMONDS;

            Card[] cards =
            {
                new Card("10", Suit.DIAMONDS,    1, 0),
                new Card("A",  Suit.DIAMONDS,   10, 1),
                new Card("9",  Suit.DIAMONDS,  100, 2),
                new Card("J",  Suit.DIAMONDS, 1000, 3)
            };
            foreach (var card in cards)
            {
                player.GetDeck().AddCard(card);
            }
            var trick     = new Trick();
            var firstCard = new Card("8", Suit.SPADES, 0, 8);

            trick.AddCard(firstCard);
            trick.SetLeadingCard(firstCard);
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(0).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(1).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(2).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(3).GetId(), trump));
            Assert.Equal(1111, trick.GetValue());
        }
Example #3
0
        public void TestPutCardCuttingNonTrumpTrick()
        {
            var        player = new Player(0, "PlayerTest", null);
            const Suit trump  = Suit.DIAMONDS;

            Card[] cards =
            {
                new Card("J",  Suit.DIAMONDS, 0, 0),
                new Card("9",  Suit.DIAMONDS, 0, 1),
                new Card("Q",  Suit.CLUBS,    0, 2),
                new Card("J",  Suit.CLUBS,    0, 3),
                new Card("Q",  Suit.CLUBS,    0, 4),
                new Card("K",  Suit.HEARTS,   0, 5),
                new Card("7",  Suit.HEARTS,   0, 6),
                new Card("10", Suit.SPADES,   0, 7)
            };
            foreach (var card in cards)
            {
                player.GetDeck().AddCard(card);
            }

            var trick     = new Trick();
            var firstCard = new Card("8", Suit.SPADES, 0, 8);

            trick.AddCard(firstCard);
            trick.SetLeadingCard(firstCard);
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(7).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(1).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(0).GetId(), trump));
        }
Example #4
0
        private Trick NextCardInTrick(int pIndex, Trick currentTrick)
        {
            Console.WriteLine("Player " + (pIndex + 1) + ":");
            if (CanConvertBidSuitToCardSuit(this.auction.FinalContract().Suit()))
            {
                currentTrick.AddCard(this.players[pIndex].PlayCard(currentTrick.FirstCardPlayed()), ConvertBidSuitToCardSuit(this.auction.FinalContract().Suit()), pIndex);
            }
            else
            {
                // NO TRUMP
                currentTrick.AddCard(this.players[pIndex].PlayCard(currentTrick.FirstCardPlayed()), pIndex);
            }

            Console.WriteLine("Player " + (pIndex + 1) + " played: " + this.players[pIndex].LastCardPlayed().ToString());
            Console.WriteLine("Player " + (currentTrick.TrickWinner() + 1) + " will get the trick at the end with: " + currentTrick.WinningTrick().ToString());

            return(currentTrick);
        }