Exemplo n.º 1
0
        public void GameLoop(Dealer dealer, Deck deck)
        {
            bool allStay = false;

            while (!allStay)
            {
                foreach (Player currentPlayer in playerList)
                {
                    if (!currentPlayer.lost)
                    {
                        while (!currentPlayer.staying)
                        {
                            currentPlayer.DisplayHand();
                            Console.WriteLine("{0}, your current score is {1}, choose look, hit, or stay.", currentPlayer.Name, currentPlayer.AddCards());
                            string playerChoice = Console.ReadLine().ToLower();
                            switch (playerChoice)
                            {
                            case "hit":
                                currentPlayer.Hit(this, dealer, deck);
                                break;

                            case "stay":
                                currentPlayer.Stay();
                                break;

                            case "look":
                                dealer.DisplayHiddenHand();
                                break;

                            default:
                                Console.WriteLine("Please enter hit or stay.");
                                break;
                            }
                            bool busted = currentPlayer.CheckForBust(this);
                            if (busted)
                            {
                                currentPlayer.staying = true;
                            }
                            allStay = true;
                        }
                    }
                }
            }
        }