void CalcU(int card1, int card2) // Calculates user score after drawing first two cards. { if ((card1 > 0 & card1 < 5) & (card2 > 0 & card2 < 5)) // If both cards are aces. { userScore = 12; // One ace has value of 11, and other a value of 1. } else if ((card1 > 0 & card1 < 5) | (card2 > 0 & card2 < 5)) // If one card is an ace. { userScore = cardVal[card1] + cardVal[card2] + 11; // No possibility of busting with 2 cards, so ace gets a value of 11. } else // If there are no aces. { userScore = cardVal[card1] + cardVal[card2]; } UserScoreLbl.Text = userScore.ToString(); if (userScore == 21) { UserBlackjackText(); UserResultLbl.Show(); } else if (userScore > 21) { UserBustedText(); UserResultLbl.Show(); } }
void HideScore() // Hides the user and dealer scores. { DealerLbl.Hide(); DealerScoreLbl.Hide(); DealerResultLbl.Hide(); UserLbl.Hide(); UserScoreLbl.Hide(); UserResultLbl.Hide(); }
void UserBustedText() // Updates lable saying that user busted. { UserResultLbl.Text = "Busted!"; UserResultLbl.Show(); }
void UserBlackjackText() // Updates lable saying that user got a blackjack. { UserResultLbl.Text = "Blackjack!"; UserResultLbl.Show(); }