예제 #1
0
        /// <summary>
        /// Ask user for action and perform that action until they stand, double, or bust.
        /// </summary>
        static void TakeActions()
        {
            string action;

            do
            {
                Console.Clear();
                player.WriteHand();
                Dealer.WriteHand();

                Console.Write("Enter Action (? for help): ");
                Console.ForegroundColor = ConsoleColor.Cyan;
                action = Console.ReadLine();
                Casino.ResetColor();

                switch (action.ToUpper())
                {
                case "HIT":
                    player.Hand.Add(deck.DrawCard());
                    break;

                case "STAND":
                    break;

                case "SURRENDER":
                    player.Hand.Clear();
                    break;

                case "DOUBLE":
                    if (player.Chips <= player.Bet)
                    {
                        player.AddBet(player.Chips);
                    }
                    else
                    {
                        player.AddBet(player.Bet);
                    }
                    player.Hand.Add(deck.DrawCard());
                    break;

                default:
                    Console.WriteLine("Valid Moves:");
                    Console.WriteLine("Hit, Stand, Surrender, Double");
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadKey();
                    break;
                }

                if (player.GetHandValue() > 21)
                {
                    foreach (Card card in player.Hand)
                    {
                        if (card.Value == 11) // Only a soft ace can have a value of 11
                        {
                            card.Value = 1;
                            break;
                        }
                    }
                }
            } while (!action.ToUpper().Equals("STAND") && !action.ToUpper().Equals("DOUBLE") &&
                     !action.ToUpper().Equals("SURRENDER") && player.GetHandValue() <= 21);
        }
예제 #2
0
        // Ask user for action and perform that action until they stay, double, or bust
        static void Actions()
        {
            string action;

            do
            {
                Clear();
                player.WriteHand();
                Dealer.WriteHand();

                Write("Enter Action (? for help): ");
                action = ReadLine();
                Casino.ColorReset();


                switch (action.ToUpper())
                {
                case "HIT":
                    player.Hand.Add(deck.DrawCard());
                    break;

                case "STAY":
                    break;

                case "FOLD":
                    player.Hand.Clear();
                    break;

                case "DOUBLE":
                    if (player.Chips <= player.Bet)
                    {
                        player.AddBet(player.Chips);
                    }
                    else
                    {
                        player.AddBet(player.Bet);
                    }
                    player.Hand.Add(deck.DrawCard());
                    break;

                default:
                    WriteLine("Valid Moves:");
                    WriteLine("Hit, Stay, Fold, Double");
                    WriteLine("Press any key to continue.");
                    ReadKey();
                    break;
                }

                if (player.GetHandValue() > 21)
                {
                    foreach (Card card in player.Hand)
                    {
                        if (card.Value == 11) // Only a soft ace can have a value of 11
                        {
                            card.Value = 1;
                            break;
                        }
                    }
                }
            } while (!action.ToUpper().Equals("STAY") && !action.ToUpper().Equals("DOUBLE") &&
                     !action.ToUpper().Equals("FOLD") && player.GetHandValue() <= 21);
        }