protected void btnStart_Click(object sender, EventArgs e) { int st; if (int.TryParse(txtAmountToBet.Text, out st) && int.Parse(txtAmountToBet.Text) < 101 && int.Parse(txtAmountToBet.Text) > 0) { deck.LoadDeck(); bet = double.Parse(txtAmountToBet.Text); Application["bet"] = bet; dealerCards = new List <Card>(); playerCards = new List <Card>(); dealerCards.Add(deck.GetCard()); playerCards.Add(deck.GetCard()); playerCardIndex = 1; Application["playerCardIndex"] = playerCardIndex; dealerCards.Add(deck.GetCard()); playerCards.Add(deck.GetCard()); Application["dealerCards"] = dealerCards; Application["playerCards"] = playerCards; Application["totalCardsDealer"] = dealerCards[0].CardValue + dealerCards[1].CardValue; AceValuePlayer(playerCards); AceValueDealer(dealerCards); playerPlace.InnerHtml = playerCards[0].CardImage; playerPlace.InnerHtml += playerCards[1].CardImage; dealerPlace.InnerHtml = dealerCards[0].CardImage; dealerPlace.InnerHtml = dealerCards[1].CardImage; dealerPlace.InnerHtml += dealerCards[1].faceDown(); btnHit.Enabled = true; btnStand.Enabled = true; if (totalCardsPlayer == 21) { playerMoney += (bet * 1.5); Application["playerMoney"] = playerMoney; lblPlayerMoney.Text = playerMoney.ToString(); txtAmountToBet.Text = 0.ToString(); lblInfo.Text = $"You win! You got {totalCardsPlayer}."; } if (totalCardsDealer == 21) { playerMoney -= (bet * 1.5); Application["playerMoney"] = playerMoney; lblPlayerMoney.Text = playerMoney.ToString(); txtAmountToBet.Text = 0.ToString(); lblInfo.Text = $"You lose! Dealer got {totalCardsDealer}."; } } }