Beispiel #1
0
        public void ShouldBuildCardsFromAndToStringWithoutAnyLoss()
        {
            var str = "7C KC 4H QH QD AS TC";

            var cards  = CardsBuilder.BuildCardsFromString(str);
            var newStr = CardsBuilder.BuildStringFromCards(cards);

            Assert.AreEqual(str, newStr);
        }
        public void ShouldEvalStraight(string str, string expectedCombination)
        {
            var cards = CardsBuilder.BuildCardsFromString(str);

            var combination       = _combinationEvaluator.EvaluateCards(cards);
            var combinationString = CardsBuilder.BuildStringFromCards(combination.Cards);

            Assert.AreEqual(CombinationType.Straight, combination.Type);
            Assert.AreEqual(expectedCombination, combinationString);
        }
        public void ShouldEvalThreeOfAKindWithLessThan5Cards(string str, string expectedCombination)
        {
            var cards = CardsBuilder.BuildCardsFromString(str);

            var combination       = _combinationEvaluator.EvaluateCards(cards);
            var combinationString = CardsBuilder.BuildStringFromCards(combination.Cards);

            Assert.AreEqual(CombinationType.ThreeOfAKind, combination.Type);
            Assert.AreEqual(expectedCombination, combinationString);
        }
Beispiel #4
0
        public void ShouldBuildStringFromCard()
        {
            var cards = new List <Card>();

            cards.Add(new Card(6, 1));
            cards.Add(new Card(14, 3));
            cards.Add(new Card(10, 2));
            cards.Add(new Card(3, 3));
            cards.Add(new Card(12, 2));
            cards.Add(new Card(8, 3));
            cards.Add(new Card(11, 1));

            var str = CardsBuilder.BuildStringFromCards(cards);

            Assert.AreEqual("6H AS TC 3S QC 8S JH", str);
        }
Beispiel #5
0
        private void DrawTable(Table table)
        {
            if (table.CurrentGame != null)
            {
                Draw($"Cards : {CardsBuilder.BuildStringFromCards(_spinAndGoGame.Table.CurrentGame.Cards.Cards)}");

                if (table.CurrentGame.Pots != null && table.CurrentGame.Pots.Count > 0)
                {
                    foreach (var pot in table.CurrentGame.Pots)
                    {
                        DrawPot(pot);
                    }
                }
                else
                {
                    Draw("Pot : 0");
                }
            }
        }
        public void Statistics_Score_Hands()
        {
            int simulationCount  = 1000000;
            var cardCombinations = new List <CardCombination>();

            var deck  = new Deck();
            var cards = new List <Card>();

            for (int i = 0; i < simulationCount; i++)
            {
                deck.Regroup();
                deck.Shuffle();

                cards.Clear();
                for (int j = 0; j < 7; j++)
                {
                    cards.Add(deck.Draw());
                }

                var cardCombination = _combinationEvaluator.EvaluateCards(cards);
                cardCombinations.Add(cardCombination);
            }

            cardCombinations = cardCombinations.OrderByDescending(combination => combination.Score).ToList();
            var             previousCombinationType = (int)CombinationType.RoyalFlush;
            CardCombination previousCombination     = null;

            foreach (var cardCombination in cardCombinations)
            {
                if ((int)cardCombination.Type > previousCombinationType)
                {
                    var cardsString         = CardsBuilder.BuildStringFromCards(cardCombination.Cards);
                    var previousCardsString = CardsBuilder.BuildStringFromCards(cardCombination.Cards);
                    throw new Exception(
                              $"{cardsString} is a {cardCombination.Type} with {cardCombination.Score} that is lower in score than {previousCardsString}-{previousCombination.Type}-{previousCombination.Score}");
                }

                previousCombination     = cardCombination;
                previousCombinationType = (int)cardCombination.Type;
            }
        }
Beispiel #7
0
 public void PlayersWinPots(IList <KeyValuePair <Player, CardCombination> > winners, Pot pot)
 {
     if (winners.Count == 1 && winners[0].Value == null)
     {
         _eventManager.RaiseEvent($"{winners[0].Key.Name} won {pot.Amount / winners.Count} from the pot because every one else fold");
     }
     else
     {
         for (int i = 0; i < winners.Count; i++)
         {
             _eventManager.RaiseEvent($"{winners[i].Key.Name} won {pot.Amount / winners.Count} from the pot with a {winners[i].Value.Type} : {CardsBuilder.BuildStringFromCards(winners[i].Value.Cards)}");
         }
     }
 }