private static void PlayGame(List <Card> shuffeledDeck, List <Player> players, int lowestBet, int highestBet)
        {
            BlackJack game = new BlackJack();

            PrintBoard.AskForBets(players);

            game.PlaceBet(players, lowestBet, highestBet);

            foreach (var player in players)
            {
                var(playersCard, ShuffelCards) = game.DealCards(shuffeledDeck, 2);
                player.PlayerCards             = playersCard;
                shuffeledDeck = ShuffelCards;
            }

            PrintBoard.ShowCardsFirstTime(players);

            game.CalculateDeals(players);

            game.GetNextCard(players, shuffeledDeck);

            game.CalculateDeals(players);

            game.DealersCards(players, shuffeledDeck);

            PrintBoard.ShowAllPlayersCards(players);

            game.PayOrTakeMoney(players);
        }
Exemple #2
0
        internal void GetNextCard(List <Player> players, List <Card> shuffeledCards)
        {
            foreach (var player in players)
            {
                if (player.PlayerName != "Dealer")
                {
                    while (true)
                    {
                        string getCard = "";
                        if (player.CardPoints < 21 && player.Satisfied == false)
                        {
                            while (true)
                            {
                                Console.Write($"{player.PlayerName} do you want one more card or do you stay ((P)LAY or (S)TAY)?: ");
                                getCard = Console.ReadLine();

                                if (getCard.ToLower() == "p")
                                {
                                    var(playerCards, newShuffelCards) = DealCards(shuffeledCards, 1);
                                    player.PlayerCards.Add(playerCards[0]);
                                    shuffeledCards = newShuffelCards;
                                    CalculateDeals(players);
                                    PrintBoard.ShowCardsFirstTime(players);
                                    break;
                                }
                                else if (getCard.ToLower() == "s")
                                {
                                    PrintBoard.ShowCardsFirstTime(players);
                                    player.Satisfied = true;
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Enter 'P' for one more card or 'S' to stay.");
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            Console.Title          = "Balck Jack";

            PrintBoard.Intro();

            var(players, lowestBet, highestBet) = GetPlayers();

            while (true)
            {
                try
                {
                    List <Card> shuffeledDeckList = StartGame();

                    PlayGame(shuffeledDeckList, players, lowestBet, highestBet);

                    BlackJack.CheckIfPlayerHasMoney(players, lowestBet);

                    RemovePlayers(players);

                    if (players.Where(x => x.Satisfied == false).Count() < 2)
                    {
                        break;
                    }
                }
                catch (ArgumentException exp)
                {
                    Console.WriteLine($"Ooops... Something went wrong.");
                }
                catch
                {
                    Console.WriteLine("Something went wrong, Please try again.");
                }
            }

            EndGame();
        }