public void ChoiceOptionIfPlayerFirst(Dealer dealer, Player player) { bool play = true; do { Console.WriteLine("Your whant one more card ?"); Console.WriteLine(); Console.WriteLine("1. Take"); Console.WriteLine("2. Stay"); string decision = Console.ReadLine(); switch (decision) { case "1": Console.WriteLine("Your take one more card :"); player.playerHand = player.OneMoreCardToPlayer(playingDeck, --cardIndex); if (Deck.DeckValueCalculating(dealer.dealerHand) <= 16) { Console.WriteLine("Dealer take one mor card :"); dealer.dealerHand = dealer.OneMoreCardToDealer(playingDeck, --cardIndex); if (Deck.DeckValueCalculating(player.playerHand) > 21) { play = false; break; } } else { Console.WriteLine("Dealer decides to stay!"); if (Deck.DeckValueCalculating(player.playerHand) > 21) { play = false; break; } } Console.WriteLine(); Console.WriteLine($"Dealer have {dealer.dealerCounter} cards"); Console.WriteLine(); Console.WriteLine("Your have next cards :"); Deck.PrintDeck(player.playerHand); Console.WriteLine($"Your total score {Deck.DeckValueCalculating(player.playerHand)}"); Console.WriteLine(); Console.WriteLine("press any key to continue...."); break; case "2": do { Console.Clear(); Console.WriteLine("You stay !!!"); if (Deck.DeckValueCalculating(dealer.dealerHand) <= 17) { Console.WriteLine("Dealer take one more card "); dealer.dealerHand = dealer.OneMoreCardToDealer(playingDeck, --cardIndex); } else { Console.WriteLine("Dealer decides to stay !!!"); play = false; break; } }while (play); Console.WriteLine(); Console.WriteLine($"Dealer have {dealer.dealerCounter} cards"); Console.WriteLine("You have next cards :"); Deck.PrintDeck(player.playerHand); Console.WriteLine($"Your totatl score {Deck.DeckValueCalculating(player.playerHand)}"); Console.WriteLine(); Console.WriteLine("press any key to continue...."); break; default: Console.WriteLine("Incorrect input..."); break; } }while (play); }
static void Main(string[] args) { Card[] cards = new Card[52]; Game game = new Game(); bool play = true; while (play) { game.Initialize(cards); Console.WriteLine("Choise who draws the card first"); Console.WriteLine("1. Dealer"); Console.WriteLine("2. Player"); string decision = Console.ReadLine(); if (decision == "1") { Console.WriteLine("Dealer first take a card :"); Console.WriteLine("Shaffle deck........."); Deck.Shuffle(game.playingDeck); Thread.Sleep(1000); Console.Clear(); Dealer dealer = new Dealer(game.playingDeck, --Game.cardIndex); Console.WriteLine($"Dealer take a {dealer.dealerCounter} cards"); Player player = new Player(game.playingDeck, --Game.cardIndex); Console.WriteLine($"Player take {player.playerCounter} cards"); Console.WriteLine("You are holding cards"); Deck.PrintDeck(player.playerHand); Console.WriteLine($"Value of your hand {Deck.DeckValueCalculating(player.playerHand)}"); Console.WriteLine("Press any key for continue...."); Console.ReadKey(); if (!game.CheckAces(dealer, player)) { game.ChoiceOptionIfDealerFirst(dealer, player); game.CalculaitingPoints(dealer, player); } play = game.GameResult(); } else if (decision == "2") { Console.WriteLine("Your first take a card"); Deck.Shuffle(game.playingDeck); Player player = new Player(game.playingDeck, --Game.cardIndex); Console.WriteLine($"Your take a {player.playerCounter} cards"); Dealer dealer = new Dealer(game.playingDeck, --Game.cardIndex); Console.WriteLine($"Dealer take a {dealer.dealerCounter} cards"); Console.WriteLine($"Value of your hand : {Deck.DeckValueCalculating(player.playerHand)}"); Console.WriteLine("Press ane key for continue..."); Console.ReadKey(); if (!game.CheckAces(dealer, player)) { game.ChoiceOptionIfPlayerFirst(dealer, player); game.CalculaitingPoints(dealer, player); } play = game.GameResult(); } else { Console.WriteLine("Incorrect input."); Console.WriteLine("try againe"); } } Console.ReadKey(); }