public void ShouldCheckIfIsNotAStraight()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Oito
                },
                new Carta()
                {
                    NumCarta = NumCarta.Nove
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Valete
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama
                },
            };

            var cartasIguais = HandChecker.IsStraight(cartas);

            Assert.False(cartasIguais);
        }
Ejemplo n.º 2
0
    public Hand ChooseBestHand(List <Card> dealerCards)
    {
        List <Card> allCards = new List <Card>(hand);

        allCards.AddRange(dealerCards);
        return(HandChecker.BestHand(allCards));
    }
Ejemplo n.º 3
0
        public void GetBestRankHandAndDeckTest()
        {
            IReadOnlyList <Card> hand = CardUtil.GetCards("2H 2S 3H 3S 3C");
            IReadOnlyList <Card> deck = CardUtil.GetCards("2D 3D 6C 9C TH");

            Assert.AreEqual(HandRank.FourOfAKind, HandChecker.GetBestRank(hand, deck));
        }
        public void ShouldCheckIfIsNotAStraightFlush()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Dez, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Valete, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Rei, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.As, Naipe = Naipes.Ouro
                },
            };

            var cartasIguais = HandChecker.IsStraightFlush(cartas);

            Assert.IsFalse(cartasIguais);
        }
        public void ShouldCheckIfIsAPair()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Oito
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dez
                },
                new Carta()
                {
                    NumCarta = NumCarta.Valete
                },
                new Carta()
                {
                    NumCarta = NumCarta.Oito
                },
            };

            var cartasIguais = HandChecker.IsPair(cartas);

            Assert.IsTrue(cartasIguais);
        }
        public void ShouldCheckIfIsNotAARoyalFlushByNumCard()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Dez, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Cinco, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Rei, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.As, Naipe = Naipes.Ouro
                },
            };

            var cartasIguais = HandChecker.IsRoyalFlush(cartas);

            Assert.False(cartasIguais);
        }
        public void ShouldCheckIfIsAStraightFlush()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Dois, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Tres, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Quatro, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Cinco, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Seis, Naipe = Naipes.Ouro
                },
            };

            var cartasIguais = HandChecker.IsStraightFlush(cartas);

            Assert.IsTrue(cartasIguais);
        }
        public void ShouldCheckIfIsNotAQuadra()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
            };

            var cartasIguais = HandChecker.IsQuadra(cartas);

            Assert.IsFalse(cartasIguais);
        }
        public void ShouldCheckIfIsARoyalFlush()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Dez, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Valete, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.Rei, Naipe = Naipes.Ouro
                },
                new Carta()
                {
                    NumCarta = NumCarta.As, Naipe = Naipes.Ouro
                },
            };

            var cartasIguais = HandChecker.IsRoyalFlush(cartas);

            Assert.True(cartasIguais);
        }
        public void ShouldCheckIfIsNotAFullHouse()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dois
                },
                new Carta()
                {
                    NumCarta = NumCarta.Dama
                },
            };

            var cartasIguais = HandChecker.IsFullHouse(cartas);

            Assert.IsFalse(cartasIguais);
        }
        public void ShouldCheckIfIsAFlush()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                }
            };

            var cartasIguais = HandChecker.IsFlush(cartas);

            Assert.IsTrue(cartasIguais);
        }
        public void ShouldCheckIfItIsNotAFlush()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    Naipe = Naipes.Espadas
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                },
                new Carta()
                {
                    Naipe = Naipes.Copa
                }
            };

            var cartasIguais = HandChecker.IsFlush(cartas);

            Assert.IsFalse(cartasIguais);
        }
        public void ShouldCheckIfIsNotATrinca()
        {
            var cartas = new List <Carta>
            {
                new Carta()
                {
                    NumCarta = NumCarta.Oito
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Tres
                },
                new Carta()
                {
                    NumCarta = NumCarta.As
                },
                new Carta()
                {
                    NumCarta = NumCarta.Oito
                },
            };

            var cartasIguais = HandChecker.IsTrinca(cartas);

            Assert.IsFalse(cartasIguais);
        }
Ejemplo n.º 14
0
        public void IsFourOfAKindTest()
        {
            Assert.True(HandChecker.IsFourOfAKind(CardUtil.GetCards("5H 5S 5C 5D 8H")));
            Assert.True(HandChecker.IsFourOfAKind(CardUtil.GetCards("AH AS AC AD 8H")));

            Assert.False(HandChecker.IsFourOfAKind(CardUtil.GetCards("5H 5S 5C 4D 8H")));
            Assert.False(HandChecker.IsFourOfAKind(CardUtil.GetCards("3H AS AC AD 8H")));
        }
Ejemplo n.º 15
0
        public void IsFullHouseTest()
        {
            Assert.True(HandChecker.IsFullHouse(CardUtil.GetCards("5H 5S 8C 8D 8H")));
            Assert.True(HandChecker.IsFullHouse(CardUtil.GetCards("AH AS 6C 6D 6H")));

            Assert.False(HandChecker.IsFullHouse(CardUtil.GetCards("5H 5S 5C 4D 8H")));
            Assert.False(HandChecker.IsFullHouse(CardUtil.GetCards("3H AS AC AD 8H")));
        }
Ejemplo n.º 16
0
        public void IsTwoPairTest()
        {
            Assert.True(HandChecker.IsTwoPair(CardUtil.GetCards("5H 5S 6C 6D 8H")));
            Assert.True(HandChecker.IsTwoPair(CardUtil.GetCards("AH AS 5C 5D 8H")));

            Assert.False(HandChecker.IsTwoPair(CardUtil.GetCards("5H 5S 5C 4D 8H")));
            Assert.False(HandChecker.IsTwoPair(CardUtil.GetCards("3H 3S AC 2D 8H")));
        }
Ejemplo n.º 17
0
        public void IsThreeOfAKindTest()
        {
            Assert.True(HandChecker.IsThreeOfAKind(CardUtil.GetCards("5H 5S 5C 6D 8H")));
            Assert.True(HandChecker.IsThreeOfAKind(CardUtil.GetCards("AH AS AC 4D 8H")));

            Assert.False(HandChecker.IsThreeOfAKind(CardUtil.GetCards("5H 2S 5C 4D 8H")));
            Assert.False(HandChecker.IsThreeOfAKind(CardUtil.GetCards("3H AS AC 2D 8H")));
        }
Ejemplo n.º 18
0
    void Awake()
    {
        cards         = new List <Card>();
        selectedCards = new List <Card>();
        ifInTurn      = false;

        handChecker = GetComponent <HandChecker>();
        hand        = GetComponentsInChildren <Hand>()[0];
    }
Ejemplo n.º 19
0
        public KinectHandler(PlayWindow owner)
        {
            game = owner;
            game.StartingNewGame += OnNewGame;
            //kinectStrategy = (KinectStrategy)game.Player.Strategy;
            leftHandChecker  = new HandChecker(Arm.Left, JointType.HandLeft);
            rightHandChecker = new HandChecker(Arm.Right, JointType.HandRight);

            FindSensor();
        }
Ejemplo n.º 20
0
        public KinectHandler(PlayWindow owner)
        {
            game = owner;
            game.StartingNewGame += OnNewGame;
            //kinectStrategy = (KinectStrategy)game.Player.Strategy;
            leftHandChecker = new HandChecker(Arm.Left, JointType.HandLeft);
            rightHandChecker = new HandChecker(Arm.Right, JointType.HandRight);

            FindSensor();
        }
Ejemplo n.º 21
0
        public void TestCheckHands_AllSevenCardsDifferentWithoutMatchingSecondCardHigher_ShouldReturnHighCardType()
        {
            IPlayer player      = new FakePlayerAllCardsDifferentWithoutMatchingSecondHandCardHigher();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.HighCard, 10);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor, "Rank factor does not match, should be factor 10 -> Jack.");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should return HighCard Type (-1).");
        }
Ejemplo n.º 22
0
 public void GetBestRankForHandTest()
 {
     Assert.AreEqual(HandRank.StraightFlush, HandChecker.GetBestRank(CardUtil.GetCards("AH KH QH JH TH")));
     Assert.AreEqual(HandRank.FourOfAKind, HandChecker.GetBestRank(CardUtil.GetCards("5H 5S 5C 5D 8H")));
     Assert.AreEqual(HandRank.FullHouse, HandChecker.GetBestRank(CardUtil.GetCards("5H 5S 8C 8D 8H")));
     Assert.AreEqual(HandRank.Flush, HandChecker.GetBestRank(CardUtil.GetCards("AH JH TH 9H 8H")));
     Assert.AreEqual(HandRank.Straight, HandChecker.GetBestRank(CardUtil.GetCards("AD KH QH JH TH")));
     Assert.AreEqual(HandRank.ThreeOfAKind, HandChecker.GetBestRank(CardUtil.GetCards("5H 5S 5C 6D 8H")));
     Assert.AreEqual(HandRank.TwoPairs, HandChecker.GetBestRank(CardUtil.GetCards("5H 5S 6C 6D 8H")));
     Assert.AreEqual(HandRank.OnePair, HandChecker.GetBestRank(CardUtil.GetCards("2H 2S 1H 4H 3H")));
     Assert.AreEqual(HandRank.HighestCard, HandChecker.GetBestRank(CardUtil.GetCards("5H 7S 6C KD 8H")));
 }
Ejemplo n.º 23
0
        public void IsStraightTest()
        {
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("AD KH QH JH TH")));
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("KH QD JH TH 9H")));
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("QH JH TD 9H 8H")));
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("8H 7H 6H 5D 4H")));
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("6H 5S 2H 3H 4D")));
            Assert.True(HandChecker.IsStraight(CardUtil.GetCards("AH 5H 4H 3D 2H")));

            Assert.False(HandChecker.IsStraight(CardUtil.GetCards("AH JH TH 9H 8H")));
            Assert.False(HandChecker.IsStraight(CardUtil.GetCards("QH JH TS 9H 7H")));
        }
Ejemplo n.º 24
0
        public void IsStraightFlushTest()
        {
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("AH KH QH JH TH")));
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("KH QH JH TH 9H")));
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("QH JH TH 9H 8H")));
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("8H 7H 6H 5H 4H")));
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("6H 5H 2H 3H 4H")));
            Assert.True(HandChecker.IsStraightFlush(CardUtil.GetCards("AH 5H 4H 3H 2H")));

            Assert.False(HandChecker.IsStraightFlush(CardUtil.GetCards("AH JH TH 9H 8H")));
            Assert.False(HandChecker.IsStraightFlush(CardUtil.GetCards("QH JH TS 9H 8H")));
        }
Ejemplo n.º 25
0
        public void TestCheckHands_SevenCardsThreeOfAKind_ShouldReturnThreeOfAKindHandType()
        {
            IPlayer player      = new FakePlayerThreeOfAKind();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.ThreeOfAKind, 340);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 340 -> 4*10(Jack) + 3*100(ThreeOfAKind).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be ThreeOfAKinf (3).");
        }
Ejemplo n.º 26
0
        public void TestCheckHands_SevenCardsTwoPairs_SouldReturnTwoPairsHandType()
        {
            IPlayer player      = new FakePlayerTwoPairs();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.TwoPairs, 230);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 230 -> 2*10(Jack) + 2*5(Six) + 2*100(TwoPairs).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be TwoPairs (2).");
        }
Ejemplo n.º 27
0
        public void TestCheckHands_SevenCardsOnePairFromHand_SouldRerurnPairHandType()
        {
            IPlayer player      = new FakePlayerOnePairFromHand();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.Pair, 140);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 140 -> 4*10(Jack) + 1*100(Pair).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be Pair (1).");
        }
Ejemplo n.º 28
0
        public void TestCheckHands_TwoCardsHighCard_ShouldReturnHighCardHandType()
        {
            IPlayer player     = new FakePlayerTwoCardsHighCard();
            var     handhecker = new HandChecker();

            handhecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.HighCard, 11);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 11 -> 11(Queen).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be HighCard (-1).");
        }
Ejemplo n.º 29
0
        public void TestCheckHands_TwoCardsPairFromHand_ShouldReturnPairHandType()
        {
            IPlayer player      = new FakePlayerTwoCardsPairFromHand();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.Pair, 128);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 128 -> 4*7(Eight) + 1*100(Pair).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be Pair (1).");
        }
Ejemplo n.º 30
0
        public void TestCheckHands_SevenCardsFullHouse_ShouldReturnFullHouseHandType()
        {
            IPlayer player      = new FakePlayerFullHouse();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.FullHouse, 620);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 620 -> 2*10(Jack) + 6*100(FullHouse).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be FullHouse (6).");
        }
Ejemplo n.º 31
0
        public void TestCheckHands_SevenCardsRoyalFlush_ShouldReturnRoyalFlushHandType()
        {
            IPlayer player      = new FakePlayerRoyalFlush();
            var     handChecker = new HandChecker();

            handChecker.CheckHands(player);
            var result         = player.Hand;
            var expectedResult = new Hand(HandType.RoyalFlush, 913);

            Assert.AreEqual(expectedResult.RankFactor, result.RankFactor,
                            "Rank factor does not match, should be factor 913 -> 13(Ace) + 9*100(RoyalFlush).");
            Assert.AreEqual(expectedResult.Type, result.Type, "Hand type does not match, should be RoyalFlush (9).");
        }