public static string PlaceBet(int value, BlackJackPlayer player, BlackJackDealer dealer, bool inGame) { currentMenu = new Menu(new string[] { "Hit", "Stand", "Surrender" }, Draw.gameMenu, new Style(ConsoleColor.White, ConsoleColor.Black)); BJDealer.Wager = value; BJDealer.HandleMoney(-value, BJPlayer); player.IsGaming = true; PutInBetBox(value); // display the bet in the top right box dealer.ShuffleCards(); // the dealer shuffeles the card deck // display the current status inGame = player.CanBet(value); // chec to see if player has that amount of cache if (inGame) { dealer.DealCardToPlayer(player); // dealer gives card to the player first card dealer.DealCardToPlayer(player); // dealer gives card to the player second card BJDealer.DealCardHimself(false, BJPlayer.CountScore()); // dealer deals himselfe one card Draw.ClearFrame(Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.DrawTextInFrame(new string[] { "Money:" + BJPlayer.Money }, Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); // update the status //Draw.DrawHandResult(); // TODO: must be done int startScore = player.CountScore(); if (startScore == int.MaxValue) // TODO fix bug when 21 on first hand { BJDealer.DealCardHimself(true, BJPlayer.CountScore()); Control = dealer.CheckScore(BJPlayer); if (Control == "Player win") { currentMenu.Position = 0; currentMenu = new Menu(new string[] { "Play Again", "To Main" }, Draw.gameMenu, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.ClearFrame(currentMenu.MenuFrame, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.ClearFrame(Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.DrawTextInFrame(new string[] { "Money:" + BJPlayer.Money }, Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.DrawMenu(currentMenu); BJPlayer.ClearHand(); BJDealer.ClearHand(); Draw.DrawTextInFrame(Draw.youWon, Draw.table, new Style(ConsoleColor.Red, ConsoleColor.Black)); } } inGame = player.CountScore() != -1; // check for valid score if (inGame) { Draw.ClearFrame(currentMenu.MenuFrame, new Style(ConsoleColor.Black, ConsoleColor.Black)); Draw.DrawMenu(currentMenu); return(currentMenu.CheckInput()); } else { //TODO: clear the game player.ClearHand(); dealer.ClearHand(); Draw.ClearFrame(Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.DrawTextInFrame(new string[] { "Money:" + BJPlayer.Money }, Draw.statusDisplay, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.ClearFrame(Draw.betBox, new Style(ConsoleColor.Black, ConsoleColor.Black)); Draw.DrawTextInFrame(Draw.youWon, Draw.betBox, new Style(ConsoleColor.White, ConsoleColor.Black)); Draw.ClearFrame(currentMenu.MenuFrame, new Style(ConsoleColor.Black, ConsoleColor.Black)); player.IsGaming = false; Draw.DrawMenu(currentMenu); return(currentMenu.CheckInput()); } } else // here is a bug if wager is bigger than curent money, the game must clear and return to betting menu again to choose smaller bet, currently it draws the ingame menu. { Draw.ClearFrame(currentMenu.MenuFrame, new Style(ConsoleColor.Black, ConsoleColor.Black)); Draw.DrawMenu(currentMenu); return(currentMenu.CheckInput()); // get control string from betting menu } }
public DealerView(BJDealer dealer) { InitializeComponent(); DataContext = dealer; }