static void Main(string[] args) { Console.Title = "BlackJack Game"; Player player = new Player(); Dealer dealer = new Dealer(); Deck deck = new Deck(); Console.WriteLine("A new deck has been opened...Let's Play BlackJack!"); deck.Shuffle(); Console.WriteLine("\nDeck Shuffled"); player.AddACard(deck.DealCard()); player.AddACard(deck.DealCard()); Console.WriteLine("\nPlayer Hand is " + player.GetValue()); player.PrintHand(); var dcard2 = deck.DealCard(); dealer.AddACard(deck.DealCard()); dealer.AddACard(dcard2); Console.WriteLine("\nDealer is showing: " + dcard2.Value + "\n" + dcard2.FaceValue + " of " + dcard2.Suit + "\n"); Dealer.EvaluateScores(player.GetValue(), dealer.GetValue()); if (dealer.GetValue() != 21 && player.GetValue() != 21) { Player.PHitOrStay(player, dealer, deck); Dealer.DHitOrStay(player, dealer, deck); } Console.ReadLine(); }
public static void PHitOrStay(Player p, Dealer d, Deck k) { if (p.GetValue() < 21 && d.GetValue() != 21) { Console.Write("\nHit or Stay? "); string phitorStay = ""; phitorStay = (Console.ReadLine()); if (phitorStay.Equals("Stay", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("\nPlayer stays, the game has ended."); Console.WriteLine("\nPlayer's hand was: " + p.GetValue()); Dealer.DHitOrStay(p, d, k); Console.WriteLine("Dealer's hand was: " + d.GetValue()); if (d.GetValue() > 21) { Console.WriteLine("Dealer Busts...\nPlayer Wins"); } else if (p.GetValue() > d.GetValue()) { Console.WriteLine("Player Wins"); } else if (p.GetValue() < d.GetValue()) { Console.WriteLine("Dealer Wins"); } else { Console.WriteLine("The game is a push"); } } else if (phitorStay.Equals("Hit", StringComparison.CurrentCultureIgnoreCase)) { p.AddACard(k.DealCard()); p.CheckForAce(); Console.WriteLine("\nPlayer hit, the hand is now: " + p.GetValue()); p.PrintHand(); //Console.WriteLine("\nThe card total is now: " + p.GetValue()); if (p.GetValue() < 21) { Player.PHitOrStay(p, d, k); { Dealer.EvaluateScores(p.GetValue(), d.GetValue()); } } else { Console.WriteLine("\nPlayer Busted!!!"); } } } }