public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            var board = boardCards.GetBoardOnStreet(boardTexture.TargetStreet).OrderBy(x => x.RankNumericValue).ToList();

            if (board.Any(x => x.RankNumericValue == Cards.Card.GetRankNumericValue("A")) &&
                board.Any(x => x.RankNumericValue == Cards.Card.GetRankNumericValue("4")))
            {
                return(true);
            }

            for (int i = 1; i < board.Count; i++)
            {
                if (Math.Abs(board[i - 1].RankNumericValue - board[i].RankNumericValue) == 3)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            var board         = boardCards.GetBoardOnStreet(boardTexture.TargetStreet);
            var lastCard      = board.Last();
            var grouppedBoard = board.Take(board.Count - 1).GroupBy(x => x.Rank);

            if (grouppedBoard.Count(x => x.Count() > 1) > 1)
            {
                return(false);
            }

            var pair = grouppedBoard.FirstOrDefault(x => x.Count() == 2);

            if (pair == null)
            {
                return(false);
            }

            return(pair.Key == lastCard.Rank);
        }
Exemplo n.º 3
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            return(HandAnalyzerHelpers.IsNofKind(boardCards, 2) && HandAnalyzerHelpers.IsNofKind(boardCards, 3));
        }
Exemplo n.º 4
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            return(HandAnalyzerHelpers.IsFlush(boardCards.GetBoardOnStreet(boardTexture.TargetStreet)));
        }
Exemplo n.º 5
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            return(boardCards.GetBoardOnStreet(boardTexture.TargetStreet).GroupBy(x => x.Suit).Count() == 3);
        }
Exemplo n.º 6
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet) || !(boardTexture is HighCardBoardTextureItem))
            {
                return(false);
            }

            var highCardItem = boardTexture as HighCardBoardTextureItem;
            var board        = boardCards.GetBoardOnStreet(highCardItem.TargetStreet);

            return(board.Aggregate((i1, i2) => i1.RankNumericValue > i2.RankNumericValue ? i1 : i2).Rank == highCardItem.SelectedRank);
        }
Exemplo n.º 7
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            var board    = boardCards.GetBoardOnStreet(boardTexture.TargetStreet);
            var lastCard = board.Last();

            return(board.Take(board.Count - 1).GroupBy(x => x.Rank).All(x => x.Count() == 1) && board.Take(board.Count - 1).Any(x => x.Rank == lastCard.Rank));
        }
Exemplo n.º 8
0
        public void TestFlushOnBoardTextureAnalyzer()
        {
            var analyzer = new FlushOnBoardTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s 7s 8s");
            var boardCards2 = BoardCards.FromCards("4s 5s 7d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
        }
Exemplo n.º 9
0
        public void TestThreeToneTextureAnalyzer()
        {
            var analyzer = new ThreeToneTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Flop
            };
            var boardCards  = BoardCards.FromCards("4s 5c 6d");
            var boardCards2 = BoardCards.FromCards("4s 5d 7d");
            var boardCards3 = BoardCards.FromCards("4s 6c 7d 8c");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
Exemplo n.º 10
0
        public void TestMonotoneTextureAnalyzer()
        {
            var analyzer = new MonotoneTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Flop
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s");
            var boardCards2 = BoardCards.FromCards("4s 5s 7c");
            var boardCards3 = BoardCards.FromCards("4s 6s 7s 6d");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
Exemplo n.º 11
0
        public void TestNoPairTextureAnalyzer()
        {
            var analyzer = new NoPairTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s 7s 7d");
            var boardCards2 = BoardCards.FromCards("4s 7s 7d 7c 9s");
            var boardCards3 = BoardCards.FromCards("4s 7s 7d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
Exemplo n.º 12
0
        public void TestTwoFlushDrawsTextureAnalyzer()
        {
            var analyzer = new TwoFlushDrawsTextureAnalyzer();

            var item = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var boardCards  = BoardCards.FromCards("4d 5s 6d 7s");
            var boardCards2 = BoardCards.FromCards("4s 5d 7c 8c");
            var boardCards3 = BoardCards.FromCards("4s 6s 7d 6c 8c");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.False);
        }
Exemplo n.º 13
0
        public void TestFullHouseTextureAnalyzer()
        {
            var analyzer = new FullHouseTextureAnalyzer();

            var itemRiver = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };

            var boardCards  = BoardCards.FromCards("5c 5s 7s 7d 5h");
            var boardCards2 = BoardCards.FromCards("7h 7s 7d 7c 4c");
            var boardCards3 = BoardCards.FromCards("4s 8h 8d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, itemRiver), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, itemRiver), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemRiver), Is.False);
        }
Exemplo n.º 14
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            var boardTextureItem = boardTexture as StraightBoardTextureItem;

            if (boardTextureItem == null || !CardHelper.IsStreetAvailable(boardCards.ToString(), boardTextureItem.TargetStreet))
            {
                return(false);
            }

            int numberOfOpenEndedStraights = 0;

            var orderedRanks = BoardTextureAnalyzerHelpers.GetOrderedBoardNumericRanks(boardCards, boardTextureItem);

            if (orderedRanks.Count < 2)
            {
                return(false);
            }

            int firstRank = orderedRanks.Max() + 2;

            while (firstRank > orderedRanks.Min() - 2)
            {
                firstRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, firstRank);
                var secondRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, firstRank - 1);
                if (secondRank <= 0)
                {
                    break;
                }

                var connectedList = new List <int>(orderedRanks);
                connectedList.Add(secondRank);
                connectedList = HandAnalyzerHelpers.GetConnectedCards(firstRank, connectedList);

                if (connectedList.Count > 4)
                {
                    numberOfOpenEndedStraights += HandAnalyzerHelpers.IsStraight(connectedList.OrderByDescending(x => x).Take(5)) ? 1 : 0;
                }
                firstRank--;
            }

            return(BoardTextureAnalyzerHelpers.CheckEquality(boardTextureItem.SelectedSign.Key, numberOfOpenEndedStraights, boardTextureItem.SelectedNumber));
        }
Exemplo n.º 15
0
        public void TestFourOfAKindTextureAnalyzer()
        {
            var analyzer = new FourOfAKindTextureAnalyzer();

            var itemTurn = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var itemRiver = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };

            var boardCards  = BoardCards.FromCards("5c 5s 7s 5d 5h");
            var boardCards2 = BoardCards.FromCards("7h 7s 7d 7c 4c");
            var boardCards3 = BoardCards.FromCards("4s 8h 8d 8s 9s");
            var boardCards4 = BoardCards.FromCards("7s 7d 7h 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, itemRiver), Is.True);
            Assert.That(analyzer.Analyze(boardCards, itemTurn), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, itemRiver), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemTurn), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, itemRiver), Is.False);
        }
Exemplo n.º 16
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            if (!CardHelper.IsStreetAvailable(boardCards.ToString(), boardTexture.TargetStreet))
            {
                return(false);
            }

            var board        = boardCards.GetBoardOnStreet(boardTexture.TargetStreet).OrderBy(x => x.RankNumericValue).ToList();
            var orderedRanks = board.Select(x => x.RankNumericValue).ToList();

            if (board.Any(x => x.RankNumericValue == Cards.Card.GetRankNumericValue("A")) &&
                board.Any(x => x.RankNumericValue == Cards.Card.GetRankNumericValue("2")))
            {
                orderedRanks.Insert(0, 1);
            }

            int count = 0;

            for (int i = 1; i < orderedRanks.Count; i++)
            {
                if (Math.Abs(orderedRanks[i - 1] - orderedRanks[i]) == 1)
                {
                    count++;
                }
                else if (count == 3)
                {
                    return(true);
                }
                else
                {
                    count = 0;
                }
            }

            return(count == 3);
        }
Exemplo n.º 17
0
        public void TestTwoPairTextureAnalyzer()
        {
            var analyzer = new TwoPairTextureAnalyzer();

            var itemTurn = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var itemRiver = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };

            var boardCards  = BoardCards.FromCards("5c 5s 7s 7c 7d");
            var boardCards2 = BoardCards.FromCards("3s 4s 7d 7c 4c");
            var boardCards3 = BoardCards.FromCards("4s 7s 7d 8s 9s");
            var boardCards4 = BoardCards.FromCards("7s 7d 8d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, itemTurn), Is.True);
            Assert.That(analyzer.Analyze(boardCards, itemRiver), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, itemTurn), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemTurn), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, itemRiver), Is.False);
        }
Exemplo n.º 18
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            var boardTextureItem = boardTexture as StraightBoardTextureItem;

            if (boardTextureItem == null || !CardHelper.IsStreetAvailable(boardCards.ToString(), boardTextureItem.TargetStreet))
            {
                return(false);
            }

            int numberOfOpenEndedStraights = 0;

            var orderedRanks = BoardTextureAnalyzerHelpers.GetOrderedBoardNumericRanks(boardCards, boardTextureItem);

            if (orderedRanks.Count < 2)
            {
                return(false);
            }

            int nutRank = GetNutHighCard(orderedRanks);

            if (nutRank <= 0)
            {
                return(false);
            }

            int firstRank  = orderedRanks.Max() + 3;
            int secondRank = firstRank - 1;

            while (firstRank > nutRank)
            {
                firstRank  = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, firstRank);
                secondRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, secondRank);

                if (firstRank == secondRank)
                {
                    secondRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, secondRank - 1);
                }

                if (secondRank <= 0 || secondRank < orderedRanks.Min() - 3)
                {
                    firstRank--;
                    secondRank = firstRank;
                    continue;
                }

                var tempList = new List <int>(orderedRanks);
                tempList.Add(firstRank);
                tempList.Add(secondRank);
                tempList = tempList.Where(x => x <= firstRank).ToList();
                if (tempList.Count > 3)
                {
                    var hand      = tempList.OrderByDescending(x => x).Take(4);
                    var isGutShot = hand.Max() - hand.Min() == 4;
                    if (isGutShot)
                    {
                        numberOfOpenEndedStraights++;
                    }
                }
                secondRank--;
            }

            return(BoardTextureAnalyzerHelpers.CheckEquality(boardTextureItem.SelectedSign.Key, numberOfOpenEndedStraights, boardTextureItem.SelectedNumber));
        }
Exemplo n.º 19
0
        public bool Analyze(BoardCards boardCards, BoardTextureItem boardTexture)
        {
            var boardTextureItem = boardTexture as StraightBoardTextureItem;

            if (boardTextureItem == null || !CardHelper.IsStreetAvailable(boardCards.ToString(), boardTextureItem.TargetStreet))
            {
                return(false);
            }

            int numberOfOpenEndedStraights = 0;

            var orderedRanks = BoardTextureAnalyzerHelpers.GetOrderedBoardNumericRanks(boardCards, boardTextureItem);

            if (orderedRanks.Count < 2)
            {
                return(false);
            }

            int  firstRank     = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, orderedRanks.Max() + 2);
            int  initFirstRank = firstRank;
            int  nutRank       = 0;
            bool isNutFound    = false;

            while (firstRank > orderedRanks.Min() - 2)
            {
                firstRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, firstRank);
                if (isNutFound && firstRank <= nutRank)
                {
                    break;
                }

                var secondRank = BoardTextureAnalyzerHelpers.GetHighestUniqueRankNumberForList(orderedRanks, firstRank - 1);
                if (secondRank <= 0)
                {
                    break;
                }

                var connectedList = new List <int>(orderedRanks);
                connectedList.Add(secondRank);
                connectedList = HandAnalyzerHelpers.GetConnectedCards(firstRank, connectedList);

                if (connectedList.Count > (isNutFound ? 3 : 4))
                {
                    var  hand       = connectedList.OrderByDescending(x => x).Take(isNutFound ? 4 : 5);
                    bool isStraight = HandAnalyzerHelpers.IsStraight(hand);
                    if (isStraight)
                    {
                        if (!isNutFound)
                        {
                            isNutFound = true;
                            firstRank  = initFirstRank;
                            nutRank    = hand.Max();
                            continue;
                        }
                        else
                        {
                            numberOfOpenEndedStraights++;
                        }
                    }
                }
                firstRank--;
            }

            return(BoardTextureAnalyzerHelpers.CheckEquality(boardTextureItem.SelectedSign.Key, numberOfOpenEndedStraights, boardTextureItem.SelectedNumber));
        }