Beispiel #1
0
        private void InitializeGame()
        {
            int amountOfPlayers = ConsoleIO.PromptForInt("Enter How Many Players", 1, 5);

            c         = new BlackJackController();
            c.Winner += (winner, winCondition) =>
            {
                Console.WriteLine($"{winner} has won.");
                Console.ReadKey();
            };

            c.Bust += (busted) =>
            {
                if (currentPlayer == busted)
                {
                    turnActive = false;
                }
                Console.WriteLine($"{busted} has busted");
            };

            c.StartGame <ConsoleCardPlayer>(amountOfPlayers);
            players = c.Players.Cast <ConsoleCardPlayer>().ToList();

            foreach (var player in players)
            {
                player.Name = ConsoleIO.PromptForInput("Enter A Name", allowEmpty: false);
            }
        }
Beispiel #2
0
        private void RunBusterMoves(BlackJackController blackJackController)
        {
            blackJackController.StartGame <CardPlayer>();
            var player = blackJackController.Players[0];

            blackJackController.TakeInitialBet(player, 100);

            for (int i = 0; i < 30; i++)
            {
                blackJackController.HitPlayer(player);
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        private void StartGame(List <string> names)
        {
            switch (game)
            {
            case Game.BlackJack:
                BlackJackController.StartGame(names.ToArray());
                AddUserControl(new BlackjackUC(names), true);
                break;

            case Game.Poker:
                AddUserControl(new PokerUC(names), true);
                break;
            }
        }