private void EndPlayerTurn() { if (gameHelper.GameOver) { betMade = false; var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) }; RenderItem.RevealHiddenCard(dealerGrid); dealerText.Text = gameHelper.EndGame(); File.Save(players); timer.Start(); timer.Tick += (sender, args) => { timer.Stop(); if (gameHelper.GameOver) { NewHand(); } }; if (gameHelper.GetBank() <= 0) { System.Windows.MessageBox.Show("You must borrow from the bank to continue.", "Out Of Money", System.Windows.MessageBoxButton.OK); gameHelper.Borrow(); UpdateBank(); } } }
private void Stand_Button(object sender, RoutedEventArgs e) { RenderItem.RevealHiddenCard(dealerGrid); gameHelper.Stand(); hideFirstTurnFunctions = true; EndPlayerTurn(); SetButtons(); }
public void Reset() { gameHelper = new GameHelper( new DealerCardEvent((Card card, bool hidden) => { RenderItem.Card(card, dealerGrid, hidden); return(card); }), new PlayerCardEvent((Card card, int hands) => { RenderItem.Card(card, playerGrid); return(card); }), players[selectedPlayer] ); NewHand(); SetButtons(); }
//Prepares to play a new hand private void NewHand() { betMade = false; RenderItem.InitGrid(playerGrid); RenderItem.InitGrid(dealerGrid); canDoubleDown = false; betGrid.Visibility = Visibility.Visible; ToggleBetDouble(); UpdateBank(); currentBetAmount.Content = ""; gameHelper.OnNewHand(); File.Save(players); SetButtons(); }