private static void PlayPlayerHands(Game game, int amount) { var firstHand = true; foreach (var playerHand in game.Player.Hands) { if (firstHand) { playerHand.IncreaseBet(amount); playerHand.PlaceBet(); } PlayHand(playerHand); firstHand = false; } }
private static void DisplayResults(Game game) { foreach (var playerHand in game.Player.Hands) { DisplayHand(playerHand, "Player"); Console.WriteLine(); Console.WriteLine(game.GetHandResult(playerHand)); } Console.WriteLine(); Console.WriteLine("Balance: {0}", game.Player.Balance); Console.WriteLine(); }
private static void PlayGame(Game game) { gameCount++; game.DealNewGame(); var amount = GetBetAmount(); var dealerHand = game.Dealer.Hands[0]; DisplayHand(dealerHand, "Dealer"); PlayPlayerHands(game, amount); game.DealerPlay(); DisplayHand(dealerHand, "Dealer"); Console.Write(" Total: {0}", dealerHand.GetSumOfHand()); Console.WriteLine(); DisplayResults(game); if (gameCount == 4) { game.Shoe.RecycleUsedCards(); gameCount = 0; } Console.WriteLine("Wins: {0} Losses: {1} Percentage: {2}", game.Player.Wins, game.Player.Losses, (decimal)game.Player.Wins / ((decimal)game.Player.Wins + (decimal)game.Player.Losses)); Console.WriteLine("Play again?"); var playKey = Console.ReadKey(); Console.WriteLine(); switch (playKey.Key) { case ConsoleKey.Y: Console.WriteLine(); PlayGame(game); break; } }
public Player(Game game, Shoe shoe, int initialBalance) { Balance = initialBalance; Game = game; Shoe = shoe; }
public Player(Game game, Shoe shoe) : this(game, shoe, -1) { Hands = new List<Hand>(); }
static void Main(string[] args) { var game = new Game(100); PlayGame(game); }