Beispiel #1
0
        public ShowingCardsValidationResult ValidateDumpingCards(List <int> selectedCards, string playerId)
        {
            var result = TractorRules.IsLeadingCardsValid(this.CurrentHandState.PlayerHoldingCards, selectedCards,
                                                          playerId);

            result.PlayerId = playerId;

            if (result.ResultType == ShowingCardsValidationResultType.DumpingFail)
            {
                foreach (var player in PlayersProxy)
                {
                    if (player.Key != playerId)
                    {
                        player.Value.NotifyDumpingValidationResult(result);
                    }
                }
            }
            var cardString = "";

            foreach (var card in selectedCards)
            {
                cardString += card.ToString() + " ";
            }
            log.Debug(playerId + " tried to dump cards: " + cardString + " Result: " + result.ResultType.ToString());
            return(result);
        }
        public void IsLeadingCardsValidTestTractor2()
        {
            Dictionary <string, CurrentPoker> playerHoldingCards = new Dictionary <string, CurrentPoker>();

            playerHoldingCards["p2"] = new CurrentPoker(new List <int>()
            {
                8, 8, 7, 7
            }, Suit.Spade, 0);
            List <int> selectedCards = new List <int> {
                3, 3, 4, 4, 5, 5, 12
            };
            string player = "p1";

            ShowingCardsValidationResult result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);

            Assert.AreEqual(ShowingCardsValidationResultType.DumpingSuccess, result.ResultType);

            selectedCards = new List <int> {
                3, 3, 4, 4, 5, 5
            };
            player = "p1";

            result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);
            Assert.AreEqual(ShowingCardsValidationResultType.Valid, result.ResultType);
        }
        public void IsLeadingCardsValidDumpSingles()
        {
            Dictionary <string, CurrentPoker> playerHoldingCards = new Dictionary <string, CurrentPoker>();

            playerHoldingCards["p2"] = new CurrentPoker(new List <int>()
            {
                35, 7, 9, 22, 52
            }, Suit.Spade, 0);
            playerHoldingCards["p3"] = new CurrentPoker(new List <int>()
            {
                30, 35, 36, 9, 10
            }, Suit.Spade, 0);
            playerHoldingCards["p4"] = new CurrentPoker(new List <int>()
            {
                27, 31, 37, 36, 16
            }, Suit.Spade, 0);
            List <int> selectedCards = new List <int> {
                42, 45, 47, 48, 49
            };
            string player = "p1";

            ShowingCardsValidationResult result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);

            Assert.AreEqual(ShowingCardsValidationResultType.DumpingSuccess, result.ResultType);
        }
        public void IsLeadingCardsValidTestTractor()
        {
            Dictionary <string, CurrentPoker> playerHoldingCards = new Dictionary <string, CurrentPoker>();

            playerHoldingCards["p2"] = new CurrentPoker(new List <int>()
            {
                8, 8, 7, 7
            }, Suit.Spade, 0);
            List <int> selectedCards = new List <int> {
                4, 4, 5, 5, 12
            };
            string player = "p1";

            ShowingCardsValidationResult result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);

            Assert.AreEqual(ShowingCardsValidationResultType.DumpingFail, result.ResultType);
            Assert.AreEqual(4, result.MustShowCardsForDumpingFail.Count);
            Assert.IsTrue(result.MustShowCardsForDumpingFail.Contains(4));
            Assert.IsTrue(result.MustShowCardsForDumpingFail.Contains(5));

            selectedCards = new List <int> {
                12, 10, 10, 9, 9
            };
            result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);
            Assert.AreEqual(ShowingCardsValidationResultType.DumpingSuccess, result.ResultType);
        }
        public void IsLeadingCardsValidDump2Pairs()
        {
            Dictionary <string, CurrentPoker> playerHoldingCards = new Dictionary <string, CurrentPoker>();

            playerHoldingCards["p2"] = new CurrentPoker(new List <int>()
            {
                18, 15, 22, 19, 21
            }, Suit.Spade, 0);
            playerHoldingCards["p3"] = new CurrentPoker(new List <int>()
            {
                25, 25, 24, 24, 22
            }, Suit.Spade, 0);
            List <int> selectedCards = new List <int> {
                10, 10, 6, 6
            };
            string player = "p1";

            ShowingCardsValidationResult result = TractorRules.IsLeadingCardsValid(playerHoldingCards, selectedCards, player);

            Assert.AreEqual(ShowingCardsValidationResultType.DumpingSuccess, result.ResultType);
        }