Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 11.70 KB | None | 0 0
  1. 'Dim Player1Dice(2) As Byte
  2. 'Dim Player2Dice(2) As Byte
  3.  
  4. 'Private Sub btnP1D0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D0.Click
  5. '    Player1Dice(0) = Math.Ceiling(6 * Rnd())
  6. '    lblP1Die0.Text = Player1Dice(0).ToString
  7. '    If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
  8. '        ' Two of a kind
  9. '        If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
  10. '        ' Three of a kind
  11. '        If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
  12. '        ' Straight (three in a row)
  13. '        If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  14. '        If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  15. '        If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  16. '        If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  17. '        If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  18. '        If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  19. '    End If
  20. 'End Sub
  21.  
  22.  
  23. 'Private Sub btnP1D1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D1.Click
  24. '    Player1Dice(1) = Math.Ceiling(6 * Rnd())
  25. '    lblP1Die1.Text = Player1Dice(1).ToString
  26. '    If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
  27. '        ' Two of a kind
  28. '        If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
  29. '        ' Three of a kind
  30. '        If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
  31. '        ' Straight (three in a row)
  32. '        If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  33. '        If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  34. '        If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  35. '        If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  36. '        If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  37. '        If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  38. '    End If
  39. 'End Sub
  40.  
  41. 'Private Sub btnP1D2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP1D2.Click
  42. '    Player1Dice(2) = Math.Ceiling(6 * Rnd())
  43. '    lblP1Die2.Text = Player1Dice(2).ToString
  44. '    If Player1Dice(0) > 0 And Player1Dice(1) > 0 And Player1Dice(2) > 0 Then
  45. '        ' Two of a kind
  46. '        If Player1Dice(0) = Player1Dice(1) Or Player1Dice(1) = Player1Dice(2) Or Player1Dice(0) = Player1Dice(2) Then Me.lblP1Score.Text = "3"
  47. '        ' Three of a kind
  48. '        If Player1Dice(0) = Player1Dice(1) And Player1Dice(1) = Player1Dice(2) Then Me.lblP1Score.Text = "10"
  49. '        ' Straight (three in a row)
  50. '        If Player1Dice(0) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  51. '        If Player1Dice(1) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  52. '        If Player1Dice(2) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  53. '        If Player1Dice(0) + 1 = Player1Dice(2) And Player1Dice(2) + 1 = Player1Dice(1) Then Me.lblP1Score.Text = "6"
  54. '        If Player1Dice(1) + 1 = Player1Dice(0) And Player1Dice(0) + 1 = Player1Dice(2) Then Me.lblP1Score.Text = "6"
  55. '        If Player1Dice(2) + 1 = Player1Dice(1) And Player1Dice(1) + 1 = Player1Dice(0) Then Me.lblP1Score.Text = "6"
  56. '    End If
  57. 'End Sub
  58.  
  59. 'Private Sub btnP2D0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D0.Click
  60. '    Player2Dice(0) = Math.Ceiling(6 * Rnd())
  61. '    lblP2Die0.Text = Player2Dice(0).ToString
  62. '    If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
  63. '        ' Two of a kind
  64. '        If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
  65. '        ' Three of a kind
  66. '        If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
  67. '        ' Straight (three in a row)
  68. '        If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  69. '        If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  70. '        If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  71. '        If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  72. '        If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  73. '        If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  74. '    End If
  75. 'End Sub
  76.  
  77. 'Private Sub btnP2D1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D1.Click
  78. '    Player2Dice(1) = Math.Ceiling(6 * Rnd())
  79. '    lblP2Die1.Text = Player2Dice(1).ToString
  80. '    If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
  81. '        ' Two of a kind
  82. '        If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
  83. '        ' Three of a kind
  84. '        If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
  85. '        ' Straight (three in a row)
  86. '        If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  87. '        If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  88. '        If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  89. '        If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  90. '        If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  91. '        If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  92. '    End If
  93. 'End Sub
  94.  
  95. 'Private Sub btnP2D2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnP2D2.Click
  96. '    Player2Dice(2) = Math.Ceiling(6 * Rnd())
  97. '    lblP2Die2.Text = Player2Dice(2).ToString
  98. '    If Player2Dice(0) > 0 And Player2Dice(1) > 0 And Player2Dice(2) > 0 Then
  99. '        ' Two of a kind
  100. '        If Player2Dice(0) = Player2Dice(1) Or Player2Dice(1) = Player2Dice(2) Or Player2Dice(0) = Player2Dice(2) Then Me.lblP2Score.Text = "3"
  101. '        ' Three of a kind
  102. '        If Player2Dice(0) = Player2Dice(1) And Player2Dice(1) = Player2Dice(2) Then Me.lblP2Score.Text = "10"
  103. '        ' Straight (three in a row)
  104. '        If Player2Dice(0) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  105. '        If Player2Dice(1) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  106. '        If Player2Dice(2) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  107. '        If Player2Dice(0) + 1 = Player2Dice(2) And Player2Dice(2) + 1 = Player2Dice(1) Then Me.lblP2Score.Text = "6"
  108. '        If Player2Dice(1) + 1 = Player2Dice(0) And Player2Dice(0) + 1 = Player2Dice(2) Then Me.lblP2Score.Text = "6"
  109. '        If Player2Dice(2) + 1 = Player2Dice(1) And Player2Dice(1) + 1 = Player2Dice(0) Then Me.lblP2Score.Text = "6"
  110. '    End If
  111. 'End Sub
  112.  
  113.  
  114.  
  115. ''Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
  116. ''    Player1Dice(0) = 0
  117. ''    lblP1Die0.Text = Player1Dice(0).ToString
  118. ''    Player1Dice(1) = 0
  119. ''    lblP1Die1.Text = Player1Dice(0).ToString
  120. ''    Player1Dice(2) = 0
  121. ''    lblP1Die2.Text = Player1Dice(0).ToString
  122. ''    Player2Dice(0) = 0
  123. ''    lblP2Die0.Text = Player1Dice(0).ToString
  124. ''    Player2Dice(1) = 0
  125. ''    lblP2Die1.Text = Player1Dice(0).ToString
  126. ''    Player2Dice(2) = 0
  127. ''    lblP2Die2.Text = Player1Dice(0).ToString
  128. ''    lblP1Score.Text = "0"
  129. ''    lblP2Score.Text = "0"
  130. ''End Sub
  131.  
  132. ''End Class
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. Public Class frmMain
  143.     Dim Dicelbls As Label() = {lblP1Die0, lblP1Die1, lblP1Die2, lblP2Die0, lblP2Die1, lblP2Die2, lblP1Score, lblP2Score}
  144.     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
  145.     Private Function Score(ByVal dice As Integer, ByVal playerlbl As Integer) As Integer
  146.         DiceInts(dice) = Math.Ceiling(6 * Rnd())
  147.         Dicelbls(playerlbl).Text = "joe"
  148.  
  149.         DiceInts(dice).ToString()
  150.         If (playerlbl = 7) Then DiceInts(6) = 3
  151.         If (playerlbl = 6) Then DiceInts(6) = 0
  152.         If DiceInts(DiceInts(6)) > 0 And DiceInts(DiceInts(6) + 1) > 0 And DiceInts(DiceInts(6) + 2) > 0 Then
  153.             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
  154.             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
  155.             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)
  156.             If DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6) + 2) And DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6)) Then DiceInts(7) = 6
  157.             If DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6)) And DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 1) Then DiceInts(7) = 6
  158.             If DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 2) And DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6) + 1) Then DiceInts(7) = 6
  159.             If DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6)) And DiceInts(DiceInts(6)) + 1 = DiceInts(DiceInts(6) + 2) Then DiceInts(7) = 6
  160.             If DiceInts(DiceInts(6) + 2) + 1 = DiceInts(DiceInts(6) + 1) And DiceInts(DiceInts(6) + 1) + 1 = DiceInts(DiceInts(6)) Then DiceInts(7) = 6
  161.         End If
  162.         Return DiceInts(7)
  163.     End Function
  164.     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
  165.         If sender.Name = "btnP1D0" Then Me.lblP1Score.Text = Score(0, 6).ToString
  166.         If sender.Name = "btnP1D1" Then Me.lblP1Score.Text = Score(1, 6).ToString
  167.         If sender.Name = "btnP1D2" Then Me.lblP1Score.Text = Score(2, 6).ToString
  168.         If sender.Name = "btnP2D0" Then Me.lblP2Score.Text = Score(3, 7).ToString
  169.         If sender.Name = "btnP2D1" Then Me.lblP2Score.Text = Score(4, 7).ToString
  170.         If sender.Name = "btnP2D2" Then Me.lblP2Score.Text = Score(5, 7).ToString
  171.         If sender.Name = "btnReset" Then
  172.             For i As Integer = 0 To 7
  173.                 Dicelbls(i).Text = "0"
  174.                 DiceInts(i) = 0
  175.             Next
  176.         End If
  177.     End Sub
  178. End Class
  179.  
  180.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement