private void DealToPlayer(BlackjackPlayer player, Card card, bool turned) { card.Turned = turned; Thread.Sleep(DealingDurationMilliseconds); player.Hand.Add(card); //PrintHand(player); }
public static PlayerChoice?AskPlayerChoice(BlackjackPlayer player) { var choices = new List <PlayerChoice>(); if (player.Choice == null) { choices.Add(PlayerChoice.Hit); choices.Add(PlayerChoice.Stand); choices.Add(PlayerChoice.DoubleDown); } else if (player.Choice == PlayerChoice.Hit) { choices.Add(PlayerChoice.Hit); choices.Add(PlayerChoice.Stand); } // Stand = no further actions allowed // Double down = no further actions allowed var question = string.Join('/', choices); Program.Ask(question); Console.Write($"[{player.Name}] H/S/D: "); var response = Console.ReadKey(); Console.WriteLine(Environment.NewLine); return(response.Key switch { ConsoleKey.H => PlayerChoice.Hit, ConsoleKey.S => PlayerChoice.Stand, ConsoleKey.D => PlayerChoice.DoubleDown, _ => PlayerChoice.Invalid, });
public BlackjackPlayer AddPlayer(string name) { var player = new BlackjackPlayer(name, false); // derive new player's position using old player's position var position = new Position(playerPosition.X, playerPosition.Y + CardHelper.CardHeight + 2); playerPosition = position; var tuple = new PlayerData(player, position); Players.Enqueue(tuple); return(player); }
private void PrintHand(BlackjackPlayer player) { //Console.SetCursorPosition(player.Position.X, player.Position.Y); int valueOffset = 0; if (player.Dealer) { foreach (var card in player.Hand.Cards) { if (card.Turned) { valueOffset += card.Value; } } } Console.WriteLine($"{Environment.NewLine}{(!player.Dealer ? $"[{player.Balance}] " : "")}{player.Name} ({player.Hand.Value - valueOffset}):"); CardHelper.PrintCards(player.Hand.Cards, CardHelper.SpacedCardOffset); }
internal PlayerData(BlackjackPlayer player, Position position) { Player = player; Position = position; }