private void EndGame() { int dealerTotal = BlackJackController.GetTotal("", false, true); DealerTotal.Content = $":{dealerTotal}"; for (int i = 0; i < NumPlayers; i++) { string name = PlayerNameDisplays[i].Content.ToString(); int bank = BlackJackController.PayoutForBankOnAPlayer(name); PlayerBankDisplays[i].Content = $"${bank}"; } }
private void HitButton_Click(object sender, RoutedEventArgs e) { DoubleDownButton.Visibility = Visibility.Hidden; SplitButton.Visibility = Visibility.Hidden; string playerName = GetCurrentPlayerName(); BlackJackController.HitMe(playerName, false); if (BlackJackController.IsBusted(playerName, false)) { HitButton.Visibility = Visibility.Hidden; PlayerBustDisplays[playerTurn].Content = "Busted"; } //UpdateHands(); DisplayCurrentHand(); PlayerTotalDisplays[playerTurn].Content = $":{BlackJackController.GetTotal(GetCurrentPlayerName(), false)}"; }
public void UpdateHands() { for (int i = 0; i < NumPlayers; i++) { PlayerHandDisplays[i].Children.Clear(); string name = PlayerNameDisplays[i].Content.ToString(); int total = BlackJackController.GetTotal(name, false); PlayerTotalDisplays[i].Content = $":{total}"; if (BlackJackController.IsBusted(name, false)) { PlayerBustDisplays[i].Content = "Busted"; } var hand = BlackJackController.blackjack.GetPlayer(PlayerNameDisplays[i].Content.ToString()).Hand; PlayerHandDisplays[i].Children.Clear(); PlayerContinuedHandDisplays[i].Children.Clear(); int count = 0; foreach (var card in hand) { count++; var pic = ConvertToPicture(card); if (count <= 3) { PlayerHandDisplays[i].Children.Add(pic); } else { PlayerContinuedHandDisplays[i].Children.Add(pic); } } } var dealerHand = BlackJackController.house.Hand; DealerHand.Children.Clear(); foreach (var card in dealerHand) { var pic = ConvertToPicture(card); DealerHand.Children.Add(pic); } }
private void BetButton_Click(object sender, RoutedEventArgs e) { int bet = 0; if (((Button)sender).Content.ToString() == "$1") { bet = 1; } else if (((Button)sender).Content.ToString() == "$5") { bet = 5; } else if (((Button)sender).Content.ToString() == "$10") { bet = 10; } string playerName = GetCurrentPlayerName(); PlayerBankDisplays[playerTurn].Content = $"${BlackJackController.PlayerBet(playerName, bet)}"; HitButton.Visibility = Visibility.Visible; StandButton.Visibility = Visibility.Visible; if (BlackJackController.CanDoubleDown(playerName)) { DoubleDownButton.Visibility = Visibility.Visible; } SplitButton.Visibility = Visibility.Hidden; HitButton.IsEnabled = true; DoubleDownButton.IsEnabled = true; StandButton.IsEnabled = true; SplitButton.IsEnabled = true; D1Button.Visibility = Visibility.Hidden; D5Button.Visibility = Visibility.Hidden; D10Button.Visibility = Visibility.Hidden; DisplayCurrentHand(); PlayerTotalDisplays[playerTurn].Content = $":{BlackJackController.GetTotal(GetCurrentPlayerName(), false)}"; }