public async void UserDrawsCard(Messages gameMessages, bool firstCard = false) { if (UserWon | ComputerWon) return; Card drawnCard = Deck.DrawCard(); this.NumberOfCardsDrawnByUser++; this.UserScore += drawnCard.GetValue(); mainWin.TxbUserScore.Text = this.UserScore.ToString(); mainWin.GrdMyDeck.Children.Add(drawnCard.ProvideCardCoverImage(firstCard, NumberOfCardsDrawnByUser)); await Task.Delay(150); mainWin.GrdMyDeck.Children.Add(drawnCard.GetCardImage(firstCard, NumberOfCardsDrawnByUser)); if (UserScore == 21) { mainWin.TxtBlGameMessages.Text = (gameMessages.BlackJackBanner); this.UserWon = true; GameOver(UserWon); } if (UserScore > 21) { mainWin.TxtBlGameMessages.Text = (gameMessages.BustBanner); this.ComputerWon = true; GameOver(UserWon); } }
public void ComputerDrawDecision(Messages gameMessages) { if (UserWon | ComputerWon) { return; } mainWin.TxtBlGameMessages.Text = ("\nBAE BOT is making his move."); int randomNumber = Deck.RandomGenerator.Next(0, 2); if (UserScore == 20) this.ComputerDrawsCard(gameMessages); else if (ComputerScore < 18) this.ComputerDrawsCard(gameMessages); else if (ComputerScore < 18 && ComputerScore > 15 && randomNumber == 1) this.ComputerDrawsCard(gameMessages); else if (ComputerScore == UserScore) this.ComputerDrawsCard(gameMessages); else this.ComputerStands(gameMessages); }
public void CheckIfComputerIsCloserTo21(Messages gameMessages) { if (ComputerScore > UserScore) { GameOver(UserWon); } if (ComputerScore == UserScore) { mainWin.TxtBlGameMessages.Text = (gameMessages.DrawBanner); this.GameOverByDraw = true; GameOver(UserWon, GameOverByDraw); } }
public void CheckIfUserIsCloserTo21(Messages gameMessages) { if (UserScore > ComputerScore) { this.UserWon = true; GameOver(UserWon); } }
public void ComputerStands(Messages gameMessages) { mainWin.TxtBlGameMessages.Text = (gameMessages.ComputerStandsMessage); this.CheckIfComputerIsCloserTo21(gameMessages); }
public MainWindow() { InitializeComponent(); gameMessages = new Messages(); }