示例#1
0
        /// <summary>
        /// Sets the Chain of responsibility for the combination checkers
        /// </summary>
        protected virtual void SetupCheckers()
        {
            RoyalStraightFlushChecker royalStraightFlushChecker = new RoyalStraightFlushChecker();
            StraightFlushChecker      straightFlushChecker      = new StraightFlushChecker();
            FourOfKindChecker         fourOfKindChecker         = new FourOfKindChecker();
            FullHouseChecker          fullHouseChecker          = new FullHouseChecker();
            FlushChecker       flushChecker       = new FlushChecker();
            StraightChecker    straightChecker    = new StraightChecker();
            ThreeOfKindChecker threeOfKindChecker = new ThreeOfKindChecker();
            TwoPairsChecker    twoPairsChecker    = new TwoPairsChecker();
            OnePairChecker     onePairChecker     = new OnePairChecker();
            TopCardChecker     topCardChecker     = new TopCardChecker();

            royalStraightFlushChecker.SetNext(straightFlushChecker);
            straightFlushChecker.SetNext(fourOfKindChecker);
            fourOfKindChecker.SetNext(fullHouseChecker);
            fullHouseChecker.SetNext(flushChecker);
            flushChecker.SetNext(straightChecker);
            straightChecker.SetNext(threeOfKindChecker);
            threeOfKindChecker.SetNext(twoPairsChecker);
            twoPairsChecker.SetNext(onePairChecker);
            onePairChecker.SetNext(topCardChecker);

            _firstChecker = royalStraightFlushChecker;
        }
示例#2
0
        static void Main()
        {
            PokerHand straightFlush = new PokerHand(new List <Card>()
            {
                new Card(Suit.Clubs, Face.Ace),
                new Card(Suit.Clubs, Face.Ten),
                new Card(Suit.Clubs, Face.King),
                new Card(Suit.Clubs, Face.Jack),
                new Card(Suit.Clubs, Face.Queen),
            });

            PokerHand straight = new PokerHand(new List <Card>()
            {
                new Card(Suit.Spades, Face.Ace),
                new Card(Suit.Clubs, Face.Ten),
                new Card(Suit.Clubs, Face.King),
                new Card(Suit.Diamonds, Face.Jack),
                new Card(Suit.Clubs, Face.Queen),
            });

            PokerHand flush = new PokerHand(new List <Card>()
            {
                new Card(Suit.Clubs, Face.Ace),
                new Card(Suit.Clubs, Face.Ten),
                new Card(Suit.Clubs, Face.Four),
                new Card(Suit.Clubs, Face.Six),
                new Card(Suit.Clubs, Face.Queen),
            });

            PokerHand nothing = new PokerHand(new List <Card>()
            {
                new Card(Suit.Spades, Face.Ace),
                new Card(Suit.Spades, Face.One),
                new Card(Suit.Clubs, Face.Four),
                new Card(Suit.Clubs, Face.Six),
                new Card(Suit.Diamonds, Face.Queen),
            });

            StraightFlushChecker straightFlushChecker = new StraightFlushChecker();
            StraightChecker      straightChecker      = new StraightChecker();
            FlushChecker         flushCkecker         = new FlushChecker();

            straightChecker.SetChecker(flushCkecker);
            straightFlushChecker.SetChecker(straightChecker);

            straightFlushChecker.CheckHand(straightFlush);
            straightFlushChecker.CheckHand(straight);
            straightFlushChecker.CheckHand(flush);
            straightFlushChecker.CheckHand(nothing);
        }
        public static PokerCombinationChecker GetChecker()
        {
            var highCard = new HighCardChecker();
            var onePair  = new OnePairChecker()
                           .SuccessiveHand(highCard);
            var twoPair = new TwoPairChecker()
                          .SuccessiveHand(onePair);
            var threeOfAKind = new ThreeOfAKindChecker()
                               .SuccessiveHand(twoPair);
            var straight = new StraightChecker()
                           .SuccessiveHand(threeOfAKind);
            var flush = new FlushChecker()
                        .SuccessiveHand(straight);
            var fullHouse = new FullHouseChecker()
                            .SuccessiveHand(flush);
            var fourOfAKind = new FourOfAKindChecker()
                              .SuccessiveHand(fullHouse);
            var straightFlush = new StraightFlushChecker()
                                .SuccessiveHand(fourOfAKind);

            return(straightFlush);
        }
示例#4
0
        static PokerCombinationChecker GetChecker()
        {
            var highCard = new HighCardChecker();
            var onePair = new OnePairChecker()
                .SuccessiveHand(highCard);
            var twoPair = new TwoPairChecker()
                .SuccessiveHand(onePair);
            var threeOfAKind = new ThreeOfAKindChecker()
                .SuccessiveHand(twoPair);
            var straight = new StraightChecker()
                .SuccessiveHand(threeOfAKind);
            var flush = new FlushChecker()
                .SuccessiveHand(straight);
            var fullHouse = new FullHouseChecker()
                .SuccessiveHand(flush);
            var fourOfAKind = new FourOfAKindChecker()
                .SuccessiveHand(fullHouse);
            var straightFlush = new StraightFlushChecker()
                .SuccessiveHand(fourOfAKind);

            return straightFlush;
        }