示例#1
0
        static void Main(string[] args)
        {
            //Needed to show suit symbols
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Game game = new Game();

            while (true)
            {
                //Cards to start game (Dealer has one hidden)
                game.DealerDraw();
                game.DealerDraw(true); //Hidden card
                game.PlayerDraw();
                game.PlayerDraw();

                //Play turns
                PlayerTurn(game);
                DealerTurn(game);

                //Write out to show hands
                Console.Clear();
                WriteHands(game);

                //Show result
                switch (game.Status)
                {
                case GameStatus.Blackjack:
                    Console.WriteLine("You won (Blackjack)");
                    break;

                case GameStatus.Won:
                    Console.WriteLine("You won");
                    break;

                case GameStatus.Tie:
                    Console.WriteLine("You tied");
                    break;

                case GameStatus.Lost:
                    Console.WriteLine("You lost");
                    break;
                }

                //Play again?
                Console.WriteLine("Press ENTER to play again. Any other key to quit.");
                ConsoleKeyInfo input = Console.ReadKey();
                if (input.Key == ConsoleKey.Enter)
                {
                    game.Reset(); //Reset game
                }
                else
                {
                    Environment.Exit(0); //Exit successfully
                }
            }
        }
示例#2
0
 private static void DealerTurn(Game game)
 {
     game.Dealer.UnHideCard(1); //Hidden card is at index 1
     while (game.Status == GameStatus.Playing)
     {
         Console.Clear();
         Console.WriteLine("...");
         Console.WriteLine("Dealer shows: " + game.Dealer.LastDrawnCard.ToString());
         WriteHands(game);
         Thread.Sleep(2000); //Wait 2000ms between draws
         game.DealerDraw();
     }
 }