Hi,
currently making a game for school and need some help,the game is a shorter version of blackjack, the card values are in an array, and they are 1 to 11,the dealer and the player get dealt two cards each at the start and then a third later, you can only use each card value four times and thats where i'm stuck,how do i keep count of which cards are used already.
Dim deck() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
Dim num As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
Dim num6 As Integer
Dim dh As Integer
Dim dh2 As Integer
Dim dh3 As Integer
Dim ph As Integer
Dim ph2 As Integer
Dim ph3 As Integer
Dim ptotal As Integer
Dim dtotal As Integer
Dim dealscore As Integer = 0
Dim playscore As Integer = 0
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
btndeal.Enabled = False
btnExit.Enabled = False
num = (Int(Rnd() * 10) + 1)
num2 = (Int(Rnd() * 10) + 1)
num3 = (Int(Rnd() * 10) + 1)
num4 = (Int(Rnd() * 10) + 1)
ph = deck(num)
ph2 = deck(num2)
dh = deck(num3)
dh2 = deck(num4)
ptotal = ph + ph2
dtotal = dh + dh2
txtDealer.Text = dtotal
txtPlayer.Text = ptotal
If (dtotal = 21) Then
Label3.Text = "Dealer wins"
ElseIf (ptotal = 21) Then
Label3.Text = "Player wins"
End If
Label3.Text = "Hit or Stick Sir/Madam"
End Sub
Private Sub btnHit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHit.Click
txtDealer.Text = dtotal
txtPlayer.Text = ptotal
num5 = (Int(Rnd() * 10) + 1)
ph3 = deck(num5)
ptotal = ptotal + ph3
txtPlayer.Text = ptotal
If ptotal > 21 Then
Label3.Text = " Bust,Dealer Wins"
dealscore = dealscore + 1
txtdealwon.Text = dealscore
btndeal.Enabled = True
btnExit.Enabled = True
btnHit.Enabled = False
btnStick.Enabled = False
ElseIf ptotal = 21 Then
Label3.Text = " Well done 21 "
playscore = playscore + 1
txtplaywon.Text = playscore
btndeal.Enabled = True
btnHit.Enabled = False
btnStick.Enabled = False
btnExit.Enabled = True
End If
End Sub
Private Sub btnStick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStick.Click
While dtotal < 17
num6 = (Int(Rnd() * 10) + 1)
dh3 = deck(num6)
dtotal = dtotal + dh3
End While
txtDealer.Text = dtotal
If dtotal > 21 Then
Label3.Text = " Dealer Bust"
playscore = playscore + 1
txtplaywon.Text = playscore
btnHit.Enabled = False
btnStick.Enabled = False
btndeal.Enabled = True
btnExit.Enabled = True
ElseIf dtotal = 21 Then
Label3.Text = " Dealer Wins 21"
dealscore = dealscore + 1
btndeal.Enabled = True
btnStick.Enabled = False
btnHit.Enabled = False
txtdealwon.Text = dealscore
btnExit.Enabled = True
End If
If dtotal > ptotal And dtotal < 21 Then
Label3.Text = " Dealer wins"
dealscore = dealscore + 1
txtdealwon.Text = dealscore
btndeal.Enabled = True
btnHit.Enabled = False
btnStick.Enabled = False
btnExit.Enabled = True
ElseIf ptotal > dtotal And ptotal < 21 Then
Label3.Text = " Player Wins"
playscore = playscore + 1
txtplaywon.Text = playscore
btnHit.Enabled = False
btnStick.Enabled = False
btndeal.Enabled = True
btnExit.Enabled = True
ElseIf dtotal = ptotal Then
Label3.Text = " It's a Draw"
btndeal.Enabled = True
btnExit.Enabled = True
End If
End Sub
Private Sub btndeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeal.Click
btnExit.Enabled = False
btnHit.Enabled = True
btnStick.Enabled = True
txtDealer.Clear()
txtPlayer.Clear()
btndeal.Enabled = False
Label3.Text = ""
num = (Int(Rnd() * 10) + 1)
num2 = (Int(Rnd() * 10) + 1)
num3 = (Int(Rnd() * 10) + 1)
num4 = (Int(Rnd() * 10) + 1)
ph = deck(num)
ph2 = deck(num2)
dh = deck(num3)
dh2 = deck(num4)
ptotal = ph + ph2
dtotal = dh + dh2
txtDealer.Text = dtotal
txtPlayer.Text = ptotal
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
MessageBox.Show("Are You Sure You Want To Exit")
End
End Sub
Private Sub btnHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHelp.Click
End Sub