Exemplo n.º 1
0
        public void CanEvaluateFourOfAKind([Values(0, 1, 2, 3, 4)] int irellevantCard,
                                           [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int rank)
        {
            Player player = new Poker.Lib.Player("", 1);

            for (int i = 0; i < 5; ++i)
            {
                if (i == irellevantCard)
                {
                    if (rank == 2)
                    {
                        player.Hand[i] = new Card((Suite)0, (Rank)(rank + 1));
                    }
                    else
                    {
                        player.Hand[i] = new Card((Suite)0, (Rank)(rank - 1));
                    }

                    continue;
                }

                player.Hand[i] = new Card((Suite)0, (Rank)(rank));
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.FourOfAKind);
        }
Exemplo n.º 2
0
        public void CanEvaluateTwoPair([Values(0, 1, 2, 3, 4)] int irellevantCard, [Values(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int irellevantCardRank,
                                       [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int rank, [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int rank2)
        {
            Assume.That(rank != rank2);
            Assume.That(irellevantCardRank != rank);
            Assume.That(irellevantCardRank != rank2);

            Player player = new Poker.Lib.Player("", 1);

            int counter = 0;

            for (int i = 0; i < 5; ++i)
            {
                if (i == irellevantCard)
                {
                    player.Hand[i] = new Card((Suite)1, (Rank)(irellevantCardRank));
                    continue;
                }

                if (counter < 2)
                {
                    player.Hand[i] = new Card((Suite)0, (Rank)(rank));
                    counter++;
                }
                else
                {
                    player.Hand[i] = new Card((Suite)0, (Rank)(rank2));
                }
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.TwoPairs);
        }
Exemplo n.º 3
0
        public void CanEvaluateStraightFlush([Values(0, 1, 2, 3)] int suite, [Values(2, 3, 4, 5, 6, 7, 8, 9)] int rank)
        {
            //A royal straight flush is a hand that contains five cards of sequential rank, all of the same suit
            Player player = new Poker.Lib.Player("", 1);

            for (int i = 0; i < 5; ++i)
            {
                player.Hand[i] = new Card((Suite)suite, (Rank)(i + rank));
            }
            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.StraightFlush);
        }
Exemplo n.º 4
0
        public void CanEvaluateHighCard()
        {
            Player player = new Poker.Lib.Player("", 1);

            Card[] cards = new Card[] { new Card(Suite.Spades, Rank.Ace), new Card(Suite.Clubs, Rank.Two),
                                        new Card(Suite.Diamonds, Rank.King), new Card(Suite.Hearts, Rank.Four), new Card(Suite.Clubs, Rank.Ten) };

            for (int i = 0; i < 5; i++)
            {
                player.Hand[i] = cards[i];
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.HighCard);
        }
Exemplo n.º 5
0
        public void CanEvaluateFlush([Values(0, 1, 2, 3)] int suite)
        {
            //A flush is a hand that contains five cards all of the same suit
            Player player = new Poker.Lib.Player("", 1);

            Card[] cards = new Card[5] {
                new Card((Suite)suite, Rank.Two), new Card((Suite)suite, Rank.Four),
                new Card((Suite)suite, Rank.Six), new Card((Suite)suite, Rank.Eight), new Card((Suite)suite, Rank.Ace)
            };

            for (int i = 0; i < 5; i++)
            {
                player.Hand[i] = cards[i];
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.Flush);
        }
Exemplo n.º 6
0
        public void CanEvaluateStraight([Values(2, 3, 4, 5, 6, 7, 8, 9)] int rank, [Values(0, 1, 2, 3, 4)] int oddColor)
        {
            //A straight is a hand that contains five cards of sequential rank
            Player player = new Poker.Lib.Player("", 1);

            for (int i = 0; i < 5; ++i)
            {
                if (i == oddColor)
                {
                    player.Hand[i] = new Card((Suite)1, (Rank)(i + rank));
                    continue;
                }

                player.Hand[i] = new Card((Suite)0, (Rank)(i + rank));
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.Straight);
        }
Exemplo n.º 7
0
        public void CanEvaluatePair([Values(0, 1, 2, 3, 4)] int rellevantCard1, [Values(0, 1, 2, 3, 4)] int rellevantCard2,
                                    [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int rank)
        {
            Assume.That(rellevantCard1 != rellevantCard2);
            Player player = new Poker.Lib.Player("", 1);

            for (int i = 0; i < 5; i++)
            {
                if (i == rellevantCard1 || i == rellevantCard2)
                {
                    player.Hand[i] = new Card((Suite)0, (Rank)rank);
                    continue;
                }

                //fyller resten av handem med kort som inte skapar några andra handtyper
                player.Hand[i] = generateCard(rank);
            }

            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.Pair);
        }
Exemplo n.º 8
0
        public void CanEvaluateTwoPairs([Values(2, 3, 4)] int irellevantCard, [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int firstRank,
                                        [Values(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)] int secondRank)
        {
            Card[] cards  = new Card[5];
            Player player = new Poker.Lib.Player("", 1);

            for (int i = 0; i < 5; ++i)
            {
                Assume.That(firstRank != secondRank);

                if (i == 0 || i == 1)
                {
                    cards[i] = new Card((Suite)0, (Rank)(firstRank));
                }
                else if (i == 2 || i == 3)
                {
                    cards[i] = new Card((Suite)1, (Rank)(secondRank));
                }
                else
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (irellevantCard != firstRank && irellevantCard != secondRank)
                        {
                            cards[i] = new Card((Suite)1, (Rank)(irellevantCard));
                            break;
                        }
                        irellevantCard++;
                    }
                }
                player.Hand[i] = cards[i];
            }
            player.graveyard = new Graveyard(); //kommer returna en error om spelaren inte har en graveyard;
            player.BeforeShowHand();
            Assert.IsTrue(player.HandType == Poker.HandType.TwoPairs);
        }