private static void Main(string[] args) { // Configure console window settings Console.Title = "♠ Blackjack Game" + new string(' ', 11) + "...by Konstantin Tarkus ([email protected])"; Console.BufferWidth = Console.WindowWidth = 70; Console.BufferHeight = Console.WindowHeight = 26; Console.CursorVisible = false; // Initialize and configure a new game var game = new Game(); game.Player.BalanceChanged += OnBalanceChanged; game.LastStateChanged += OnLastStateChanged; game.AllowedActionsChanged += OnAllowedActionsChanged; game.Dealer.Hand.Changed += OnHandChanged; game.Player.Hand.Changed += OnHandChanged; game.Play(balance: 500, bet: 5); while (true) { var key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.Add: case ConsoleKey.UpArrow: game.Player.Bet += 5; break; case ConsoleKey.Subtract: case ConsoleKey.DownArrow: game.Player.Bet -= 5; break; case ConsoleKey.Enter: if ((game.AllowedActions & GameAction.Deal) == GameAction.Deal) { game.Deal(); } else { game.Stand(); } break; case ConsoleKey.Spacebar: if ((game.AllowedActions & GameAction.Deal) == GameAction.Deal) { game.Deal(); } else { game.Hit(); } break; } } }
static void Main(string[] args) { Game game = new Game(); game.GameStart(); game.Play(); if (game.Lost) Console.WriteLine("You lose! Too bad!"); if (game.Won) Console.WriteLine("You win! Nice going!"); if (game.Draw) Console.WriteLine("It's a draw! Oh well."); Console.ReadLine(); }
static void Main(string[] args) { string playerName = GetPlayerName(); double playerMoney = GetPlayerMoney(); Output.AbstractOutput output = AlertOrConsole(); do { Console.OutputEncoding = System.Text.Encoding.UTF8; Console.Clear(); Game game = new Game(output); game.Play(playerName, playerMoney); Console.WriteLine("Play again? (Y/N)"); } while (Console.ReadLine().ToUpper() == "Y"); }
static void Main(string[] args) { char c = 's'; int numPlayers = 0; //initial defualt number of players List <string> names = new List <string>(); string name; Console.WriteLine("-----------------------------"); Console.WriteLine("BIENVENIDO AL BLACKJACK MIEDO"); Console.WriteLine("-----------------------------"); Console.WriteLine(); while (numPlayers < 1 || numPlayers > 7) { Console.Write("Type the number of players (1 - 7): "); string nPlayers = Console.ReadLine(); if (!int.TryParse(nPlayers, out numPlayers)) { PrintColorMessage(ConsoleColor.Red, "Error, please enter a number. "); continue; } numPlayers = Int32.Parse(nPlayers); } Console.WriteLine(); for (int i = 0; i < numPlayers; i++) { Console.Write("Type the player {0} name: ", i); name = Console.ReadLine(); names.Add(name); Console.WriteLine(); } Console.WriteLine(); Game Blackjack = new Game(names); while (c != 'n' && c != 'N') { Blackjack.Play(); Console.WriteLine(); Console.Write("Would you like to play again? [ y/n ] "); c = Convert.ToChar(Console.Read()); } }
static void Main() { Console.WriteLine("----------| WELCOME TO BLACKJACK |----------"); string quit = ""; // do // { var game = new Game(); while (true) { game.Play(); game.Reset(); } // Console.WriteLine("\nYou are out of chips. Bye bye."); // Console.WriteLine("\nPress any key to exit. Press enter to play again."); // quit = Console.ReadLine(); }
static void Main(string[] args) { var playerWantsToKeepGoing = true; while (playerWantsToKeepGoing) { var theGame = new Game(); theGame.Play(); Console.Write("Want more? [Y]/[N] "); var answer = Console.ReadLine().ToLower(); playerWantsToKeepGoing = (answer == "y"); // if (answer == "y") // { // playerWantsToKeepGoing = true; // } // else // { // playerWantsToKeepGoing = false; // } } }
static void Main(string[] args) { Game g = new Game(); while (!g.GameOver && g.ContinuePlay) { g.Play(); Console.WriteLine("\n\n Game ended."); Console.ReadKey(true); Console.Clear(); } switch (g.State) { case Game.GameState.CasinoOwner: Console.WriteLine("\n GET OUT. GET OUT OF THIS PLACE. LEAVE, YOU DIRTY," + "\n ROTTEN, CHEATER. Probably hiding cards under your sleeve," + "\n or something else equally evil. You expect US to believe" + "\n that someone can get this 'lucky'? Bull." + "\n\n\n\n Bull."); break; case Game.GameState.CardCounter: Console.WriteLine("\n [You get up from the table, and all eyes are on you.]\n" + "\n \"What?\" you say, as jealous men and women stare down" + "\n the cause of their demise. The dealer makes a phone call" + "\n and you decide it's better to leave sooner rather than later."); break; case Game.GameState.Rich: Console.WriteLine("\n Wow. Just wow.\n" + "\n Good for you, buddy. Buy your friend a drink?" + "\n Hell, buy everyone drinks. Right?"); break; case Game.GameState.Over: Console.WriteLine("\n Well done! You came out with more money" + "\n than you put in! Good thinking to quit" + "\n while you're ahead."); break; case Game.GameState.Even: Console.WriteLine("\n Well, you managed to break even.\n" + "\n Go home to your wife and kids, and try" + "\n not to gamble anymore with grocery money" + "\n unless you can actually play Blackjack."); break; case Game.GameState.Under: Console.WriteLine("\n You lost money! Quick! - to the slots!\n" + "\n On second thought, don't. Baby Billy needs" + "\n groceries, you selfish bum."); break; case Game.GameState.Broke: Console.WriteLine("\n You ran out of cash. You should feel bad.\n" + "\n Now you have to go back home to your wife" + "\n and explain why she can't buy groceries" + "\n for your family for TWO MONTHS because" + "\n you just HAD to go out gambling.\n" + "\n Asshole."); break; default: break; } Console.WriteLine("\n\n"); Console.WriteLine(" Wins:Losses => {0}:{1}", g.NumWins, g.NumLosses); Console.WriteLine(" Largest win => {0}", g.LargestWin); Console.WriteLine(" Largest loss => {0}", g.LargestLoss); Console.ReadKey(true); }