Example #1
0
        private Expression <Func <Playerstatistic, bool> > GetBoardCardItemsPredicate()
        {
            Expression <Func <Playerstatistic, bool> > resultPredicate = null;
            var analyzer = new ExactCardsTextureAnalyzer();

            if (FlopCardItemsCollection.Any(x => x.Suit != RangeCardSuit.None))
            {
                var collection = FlopCardItemsCollection.Where(x => x.Suit != RangeCardSuit.None);
                if (resultPredicate == null)
                {
                    resultPredicate = PredicateBuilder.Create <Playerstatistic>(x => analyzer.Analyze(x.Board, collection));
                }
                else
                {
                    resultPredicate = resultPredicate.Or(x => analyzer.Analyze(x.Board, collection));
                }
            }

            if (TurnCardItemsCollection.Any(x => x.Suit != RangeCardSuit.None))
            {
                var collection = TurnCardItemsCollection.Where(x => x.Suit != RangeCardSuit.None);
                if (resultPredicate == null)
                {
                    resultPredicate = PredicateBuilder.Create <Playerstatistic>(x => analyzer.Analyze(x.Board, collection));
                }
                else
                {
                    resultPredicate = resultPredicate.Or(x => analyzer.Analyze(x.Board, collection));
                }
            }

            if (RiverCardItemsCollection.Any(x => x.Suit != RangeCardSuit.None))
            {
                var collection = RiverCardItemsCollection.Where(x => x.Suit != RangeCardSuit.None);
                if (resultPredicate == null)
                {
                    resultPredicate = PredicateBuilder.Create <Playerstatistic>(x => analyzer.Analyze(x.Board, collection));
                }
                else
                {
                    resultPredicate = resultPredicate.Or(x => analyzer.Analyze(x.Board, collection));
                }
            }

            return(resultPredicate);
        }
Example #2
0
        public void TestExactCardsTextureAnalyzer()
        {
            var analyzer    = new ExactCardsTextureAnalyzer();
            var boardCards  = "4s 5h 7s";
            var targetCards = new List <BoardCardItem>()
            { //4s 5h 7s
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Four, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Seven, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                }
            };

            var targetCards2 = new List <BoardCardItem>()
            { //4d 5h 7s
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Four, Suit = Model.Enums.RangeCardSuit.Diamonds, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Seven, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                }
            };
            var targetCards3 = new List <BoardCardItem>()
            { //4s 5h Xh
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Four, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.None, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                }
            };
            var targetCards4 = new List <BoardCardItem>()
            { //Xs 5h 7s
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.None, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Seven, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                }
            };

            var targetCards5 = new List <BoardCardItem>()
            { //Xs 5h
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.None, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                },
            };

            var targetCards6 = new List <BoardCardItem>()
            { //4s 5h
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Five, Suit = Model.Enums.RangeCardSuit.Hearts, TargetStreet = Street.Flop
                },
                new BoardCardItem {
                    Rank = Model.Enums.RangeCardRank.Four, Suit = Model.Enums.RangeCardSuit.Spades, TargetStreet = Street.Flop
                },
            };

            Assert.That(analyzer.Analyze(boardCards, targetCards), Is.True);
            Assert.That(analyzer.Analyze(boardCards, targetCards2), Is.False);
            Assert.That(analyzer.Analyze(boardCards, targetCards3), Is.False);
            Assert.That(analyzer.Analyze(boardCards, targetCards4), Is.True);
            Assert.That(analyzer.Analyze(boardCards, targetCards5), Is.True);
            Assert.That(analyzer.Analyze(boardCards, targetCards6), Is.True);
        }