![]() / Randomize the order of the cards in the Deck. / Pick top card and remove it from the deck Create a temporary list of cards and give it the top two cards of the deck. / Remove top 2 cards of Deck and turn it into a list. / Returns a Cold Deck- a deck organized by Suit and Face. / Write Dealer's RevealedCards to Console.Ĭonsole.WriteLine("Dealer's Hand (" + GetHandValue() + "):") / Take the top card from HiddenCards, remove it, and add it to RevealedCards. / Reset Console Colors to DarkGray on BlackĬonsole.ForegroundColor = ConsoleColor.DarkGray Ĭonsole.BackgroundColor = ConsoleColor.Black If (hand.Face = Face.Ace & hand.Value = 10) return true Įlse if (hand.Face = Face.Ace & hand.Value = 10) return true Public static bool IsHandBlackjack(List hand) / Returns true if the hand is blackjack / Perform action based on result of round and start next round.Ĭonsole.ForegroundColor = ConsoleColor.Gray Ĭonsole.WriteLine("Player and Dealer Push.") Ĭonsole.ForegroundColor = ConsoleColor.Yellow Ĭonsole.WriteLine("Player Wins " + player.WinBet(false) + " chips") Ĭonsole.WriteLine("Player Wins " + player.WinBet(true) + " chips with Blackjack.") Ĭonsole.WriteLine("Player Surrenders " + (player.Bet / 2) + " chips") If (Int32.TryParse(s, out int bet) & bet >= Casino.MinimumBet & player.Chips >= bet) & !action.ToUpper().Equals("SURRENDER") & player.GetHandValue() Ĭonsole.ForegroundColor = ConsoleColor.Green Ĭonsole.ForegroundColor = ConsoleColor.Red Ĭonsole.Write("Enter bet to begin hand " + player.HandsCompleted + ": ") Ĭonsole.ForegroundColor = ConsoleColor.Magenta ![]() } while (!action.ToUpper().Equals("STAND") & !action.ToUpper().Equals("DOUBLE") If (card.Value = 11) // Only a soft ace can have a value of 11 / Ask user for action and perform that action until they stand, double, or bust.Ĭonsole.Write("Enter Action (? for help): ") Ĭonsole.ForegroundColor = ConsoleColor.Cyan While (Dealer.GetHandValue() Dealer.GetHandValue())Įlse if (Dealer.GetHandValue() > player.GetHandValue()) If hand contains two aces, make one Hard. / Initialize Deck, deal the player and dealer hands, and display them. Private static Player player = new Player() You should have received a copy of the GNU General Public License GNU General Public License for more details. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program is distributed in the hope that it will be useful,īut WITHOUT ANY WARRANTY without even the implied warranty of The Free Software Foundation, either version 3 of the License, or ![]() It under the terms of the GNU General Public License as published by This program is free software: you can redistribute it and/or modify There are 4 files: Program.cs /* Blackjack Game Copyright (C) 2018 I am wondering how I can better organize or simplify my code. I recently finished a simple Blackjack game that I made to get better at C#. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |