Esempio n. 1
0
        private void RunTurn()
        {
            turnActive = true;
            string[] menuSelection = { "Hit", "Pass" };
            do
            {
                Console.WriteLine($"{currentPlayer}'s Turn ");
                currentPlayer.Hand.ForEach(c => Console.Write($"{c}, "));
                Console.WriteLine();
                int choice = ConsoleIO.PromptForMenuSelection(menuSelection, false);
                switch (choice)
                {
                case 1:
                    c.HitPlayer(currentPlayer);
                    break;

                case 2:
                    turnActive = false;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(choice), "You gotta select a value between one and two.");
                }

                Console.WriteLine($"{c.CountHand(currentPlayer.Hand)}");
            } while (turnActive);
        }
Esempio n. 2
0
        public void KeepHittingHouseHandWhileUnder17()
        {
            //arrange
            var blackJackController = new BlackJackController();

            blackJackController.StartGame <CardPlayer>();

            //act
            blackJackController.RunHouseTurn();
            List <Card> houseHand = blackJackController.House.Hand;

            //assert
            Assert.IsTrue(blackJackController.CountHand(houseHand) >= 17);
        }
        public void TheResultFromAddingAJackAndAnAceIs21()
        {
            var controller = new BlackJackController();
            var cards      = new List <Card>()
            {
                new Card(Rank.Ace, Suit.Club),
                new Card(Rank.Jack, Suit.Diamond)
            };
            var expected = 21;
            int actual;

            actual = controller.CountHand(cards);

            Assert.AreEqual(expected, actual);
        }
        public void TheResultForTwoAcesAndaJackIsEleven()
        {
            var controller = new BlackJackController();
            var cards      = new List <Card>()
            {
                new Card(Rank.Ace, Suit.Club),
                new Card(Rank.Ace, Suit.Diamond),
                new Card(Rank.Jack, Suit.Spade),
            };
            var expected = 12;
            int actual;

            actual = controller.CountHand(cards);

            Assert.AreEqual(expected, actual);
        }
        public void TheResultAFourAcesIsFourteen()
        {
            var controller = new BlackJackController();
            var cards      = new List <Card>()
            {
                new Card(Rank.Ace, Suit.Club),
                new Card(Rank.Ace, Suit.Diamond),
                new Card(Rank.Ace, Suit.Spade),
                new Card(Rank.Ace, Suit.Heart)
            };
            var expected = 14;
            int actual;

            actual = controller.CountHand(cards);

            Assert.AreEqual(expected, actual);
        }
        public void TheResultFor3TwosAFourAndAnAce()
        {
            var controller = new BlackJackController();
            var cards      = new List <Card>()
            {
                new Card(Rank.Ace, Suit.Club),
                new Card(Rank.Four, Suit.Spade),
                new Card(Rank.Two, Suit.Spade),
                new Card(Rank.Two, Suit.Diamond),
                new Card(Rank.Two, Suit.Diamond)
            };
            var expected = 21;
            int actual;

            actual = controller.CountHand(cards);

            Assert.AreEqual(expected, actual);
        }