Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Dim Player1Dice(2) As Byte
- 'Dim Player2Dice(2) As Byte
- 'Private Sub btnP1D0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D0.Click
- ' Player1Dice(0) = Math.Ceiling(6 * Rnd())
- ' lblP1Die0.Text = Player1Dice(0).ToString
- ' If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
- ' ' Three of a kind
- ' If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' End If
- 'End Sub
- 'Private Sub btnP1D1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D1.Click
- ' Player1Dice(1) = Math.Ceiling(6 * Rnd())
- ' lblP1Die1.Text = Player1Dice(1).ToString
- ' If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
- ' ' Three of a kind
- ' If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' End If
- 'End Sub
- 'Private Sub btnP1D2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D2.Click
- ' Player1Dice(2) = Math.Ceiling(6 * Rnd())
- ' lblP1Die2.Text = Player1Dice(2).ToString
- ' If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
- ' ' Three of a kind
- ' If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
- ' If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
- ' End If
- 'End Sub
- 'Private Sub btnP2D0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D0.Click
- ' Player2Dice(0) = Math.Ceiling(6 * Rnd())
- ' lblP2Die0.Text = Player2Dice(0).ToString
- ' If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
- ' ' Three of a kind
- ' If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' End If
- 'End Sub
- 'Private Sub btnP2D1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D1.Click
- ' Player2Dice(1) = Math.Ceiling(6 * Rnd())
- ' lblP2Die1.Text = Player2Dice(1).ToString
- ' If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
- ' ' Three of a kind
- ' If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' End If
- 'End Sub
- 'Private Sub btnP2D2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D2.Click
- ' Player2Dice(2) = Math.Ceiling(6 * Rnd())
- ' lblP2Die2.Text = Player2Dice(2).ToString
- ' If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
- ' ' Two of a kind
- ' If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
- ' ' Three of a kind
- ' If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
- ' ' Straight (three in a row)
- ' If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
- ' If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
- ' End If
- 'End Sub
- ''Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
- '' Player1Dice(0) = 0
- '' lblP1Die0.Text = Player1Dice(0).ToString
- '' Player1Dice(1) = 0
- '' lblP1Die1.Text = Player1Dice(0).ToString
- '' Player1Dice(2) = 0
- '' lblP1Die2.Text = Player1Dice(0).ToString
- '' Player2Dice(0) = 0
- '' lblP2Die0.Text = Player1Dice(0).ToString
- '' Player2Dice(1) = 0
- '' lblP2Die1.Text = Player1Dice(0).ToString
- '' Player2Dice(2) = 0
- '' lblP2Die2.Text = Player1Dice(0).ToString
- '' lblP1Score.Text = "0"
- '' lblP2Score.Text = "0"
- ''End Sub
- ''End Class
- Public Class frmMain
- Dim Dicelbls As Label() = {lblP1Die0, lblP1Die1, lblP1Die2, lblP2Die0, lblP2Die1, lblP2Die2, lblP1Score, lblP2Score}
- Dim DiceInts(7) As Byte ' 0-2 is Player 1's Dice, 3-5 is Player 2's Dice, 6 is the counter used in the Score function, 7 is the result returned in the score function
- Private Function Score(ByVal dice As Integer, ByVal playerlbl As Integer) As Integer
- DiceInts(dice) = Math.Ceiling(6 * Rnd())
- Dicelbls(playerlbl).Text = "joe"
- DiceInts(dice).ToString()
- If (playerlbl = 7) Then DiceInts(6) = 3
- If (playerlbl = 6) Then DiceInts(6) = 0
- If DiceInts(DiceInts(6)) > 0 And DiceInts(DiceInts(6) + 1) > 0 And DiceInts(DiceInts(6) + 2) > 0 Then
- If DiceInts(DiceInts(6)) = DiceInts(DiceInts(6) + 1) Or DiceInts(DiceInts(6) + 1) = DiceInts(DiceInts(6) + 2) Or DiceInts(DiceInts(6)) = DiceInts(DiceInts(6) + 2) Then DiceInts(7) = 3 ' Two of a kind
- If DiceInts(DiceInts(6)) = DiceInts(DiceInts(6) + 1) And DiceInts(DiceInts(6) + 1) = DiceInts(DiceInts(6) + 2) Then DiceInts(7) = 10 ' Three of a kind
- If DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 1) And DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6) + 2) Then DiceInts(7) = 6 ' Straight (three in a row)
- If DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6) + 2) And DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6)) Then DiceInts(7) = 6
- If DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6)) And DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 1) Then DiceInts(7) = 6
- If DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 2) And DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6) + 1) Then DiceInts(7) = 6
- If DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6)) And DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 2) Then DiceInts(7) = 6
- If DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6) + 1) And DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6)) Then DiceInts(7) = 6
- End If
- Return DiceInts(7)
- End Function
- Private Sub ButtonHandler(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D0.Click, btnP1D1.Click, btnP1D2.Click, btnP2D0.Click, btnP2D1.Click, btnP2D2.Click, btnReset.Click
- If sender.Name = "btnP1D0" Then Me.lblP1Score.Text = Score(0, 6).ToString
- If sender.Name = "btnP1D1" Then Me.lblP1Score.Text = Score(1, 6).ToString
- If sender.Name = "btnP1D2" Then Me.lblP1Score.Text = Score(2, 6).ToString
- If sender.Name = "btnP2D0" Then Me.lblP2Score.Text = Score(3, 7).ToString
- If sender.Name = "btnP2D1" Then Me.lblP2Score.Text = Score(4, 7).ToString
- If sender.Name = "btnP2D2" Then Me.lblP2Score.Text = Score(5, 7).ToString
- If sender.Name = "btnReset" Then
- For i As Integer = 0 To 7
- Dicelbls(i).Text = "0"
- DiceInts(i) = 0
- Next
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement