Example #1
0
        public void Move(int currentHand, Card croupierOpenCard, Shoes shoes)
        {
            Hand hand = Hands[currentHand];

            while (hand.Cards.Count < 2)
            {
                hand.Cards.Add(shoes.GetCard());
            }

            if (hand.Cards.Count == 2)
            {
                if (SplitCondition(hand, croupierOpenCard))
                {
                    splitCount += 2;
                    Split(currentHand);
                    return;
                }
                if (DoubleDownCondition(hand, croupierOpenCard))
                {
                    DoubleDown(shoes, currentHand);
                    return;
                }
            }

            while (TakingCardCondition(hand, croupierOpenCard))
            {
                hand.Cards.Add(shoes.GetCard());
            }
        }
        private static void Draw(Shoes shoes, Croupier croupier, IBot bot)
        {
            croupier.OpenCard = shoes.GetCard();
            croupier.Hand.Add(croupier.OpenCard);
            croupier.Hand.Add(shoes.GetCard());

            bot.Play(croupier.OpenCard, shoes);
            croupier.Play(shoes);
        }
Example #3
0
        public void GetCardTest()
        {
            var shoes    = new Shoes();
            var cardList = new List <Card>();

            for (int i = 0; i < 416; i++)
            {
                cardList.Add(shoes.GetCard());
            }

            Assert.AreEqual(cardList.Count, 416);
            Assert.AreEqual(cardList.Count(c => c.Rank == CardRank.Ace), 32);
            Assert.AreEqual(shoes.AllCardsCount, 0);
        }
Example #4
0
        public void Play(Shoes shoes)
        {
            HandValue = 0;

            foreach (var card in Hand)
            {
                HandValue += card.GetCardRank();
            }

            while (HandValue < 17)
            {
                Card newCard = shoes.GetCard();
                Hand.Add(newCard);
                HandValue += newCard.GetCardRank();
                foreach (var card in Hand)
                {
                    if (card.Rank == CardRank.Ace && HandValue > 21)
                    {
                        HandValue -= 10;
                    }
                }
            }
        }
Example #5
0
 private void DoubleDown(Shoes shoes, int currentHand)
 {
     Hands[currentHand].Cards.Add(shoes.GetCard());
     Hands[currentHand].Bet *= 2;
 }