/// <summary> /// Takes an EndResult value and shows the resulting game ending in the UI /// </summary> /// <param name="endState"></param> private void EndGame(EndResult endState) { switch (endState) { case EndResult.DealerBust: gameOverTextBox.Text = "Dealer Bust!"; game.PlayerWin(); break; case EndResult.DealerBlackJack: gameOverTextBox.Text = "Dealer BlackJack!"; game.PlayerLose(); break; case EndResult.DealerWin: gameOverTextBox.Text = "Dealer Won!"; game.PlayerLose(); break; case EndResult.PlayerBlackJack: gameOverTextBox.Text = "BlackJack!"; game.CurrentPlayer.Balance += (game.CurrentPlayer.Bet * (decimal)2.5); game.CurrentPlayer.Wins += 1; break; case EndResult.PlayerBust: gameOverTextBox.Text = "You Bust!"; game.PlayerLose(); break; case EndResult.PlayerWin: gameOverTextBox.Text = "You Won!"; game.PlayerWin(); break; case EndResult.Push: gameOverTextBox.Text = "Push"; game.CurrentPlayer.Push += 1; game.CurrentPlayer.Balance += game.CurrentPlayer.Bet; break; } // Update the "My Record" values winTextBox.Text = game.CurrentPlayer.Wins.ToString(); lossTextBox.Text = game.CurrentPlayer.Losses.ToString(); tiesTextBox.Text = game.CurrentPlayer.Push.ToString(); SetUpNewGame(); ShowBankValue(); gameOverTextBox.Show(); // Check if the current player is out of money if (game.CurrentPlayer.Balance == 0) { MessageBox.Show("Out of Money. Please create a new game to play again."); this.Close(); } }
// Takes an EndResult value and shows the resulting game ending in the UI public void EndGame(EndResult endState) { String res = refPlayer.Name + ": "; switch (endState) { case EndResult.DealerBust: res += "Dealer Bust!"; game.PlayerWin(refPlayer); break; case EndResult.DealerBlackJack: res += "Dealer BlackJack!"; break; case EndResult.DealerWin: res += "Dealer Won!"; break; case EndResult.PlayerBlackJack: res += "Player BlackJack!"; refPlayer.Balance += (refPlayer.Bet * (decimal)2.5); break; case EndResult.PlayerBust: res += "Player Bust!"; break; case EndResult.PlayerWin: res += "Player Won!"; game.PlayerWin(refPlayer); break; case EndResult.Push: res += "Push"; refPlayer.Balance += refPlayer.Bet; break; } game.PlayerEndGame(res); SetUpNewGame(); Tb_status.Show(); // Check if the current player is out of money if (refPlayer.Balance == 0) { MessageBox.Show("Out of Money. Please create a new game to play again."); this.Close(); } }