home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 February
/
PCWK0297.iso
/
envelop
/
envelop.5
/
Tools
/
Arsenal
/
apps
/
gamedice
/
gamedice.eto
< prev
next >
Wrap
Text File
|
1996-07-08
|
47KB
|
1,594 lines
Type DiceOptionMenu From PopupMenu
End Type
Type OptionsPlayersMenu From PopupMenu
End Type
Type DiceMasterForm From SampleMasterForm
Dim btnRoll As New Button
Dim chkKeep1 As New CheckBox
Dim chkKeep2 As New CheckBox
Dim chkKeep3 As New CheckBox
Dim chkKeep4 As New CheckBox
Dim chkKeep5 As New CheckBox
Dim imgDice1 As New Image
Dim imgDice2 As New Image
Dim imgDice3 As New Image
Dim imgDice4 As New Image
Dim imgDice5 As New Image
Dim bmpDice1 As New Bitmap
Dim bmpDice2 As New Bitmap
Dim bmpDice3 As New Bitmap
Dim bmpDice4 As New Bitmap
Dim bmpDice5 As New Bitmap
Dim bmpDice6 As New Bitmap
Dim bmpDice0 As New Bitmap
Dim Label1 As New Label
Dim btnKeep As New Button
Dim Label2 As New Label
Dim lblTotalScore As New Label
Dim Label3 As New Label
Dim lblMatchDice As New Label
Dim DiceRolled As String
Dim DiceCount As Integer
Dim DiceMatched As Integer
Dim ClickFlag As Integer
Dim KeepFlag As Integer
Dim Label4 As New Label
Dim btnPlayer1 As New Button
Dim btnPlayer2 As New Button
Dim btnPlayer3 As New Button
Dim btnPlayer4 As New Button
Dim lblScore1 As New Label
Dim lblScore2 As New Label
Dim lblScore3 As New Label
Dim lblScore4 As New Label
Dim Label9 As New Label
Dim btnPlayer5 As New Button
Dim btnPlayer6 As New Button
Dim lblScore5 As New Label
Dim lblScore6 As New Label
Dim lblLostAmount As New Label
Dim PlayerNumber As Integer
Dim CurrentTurn As Integer
' METHODS for object: DiceMasterForm
Sub ActivatePlayer(count As Integer)
' Deactivate all player buttons
btnPlayer1.Enabled = False
btnPlayer2.Enabled = False
btnPlayer3.Enabled = False
btnPlayer4.Enabled = False
btnPlayer5.Enabled = False
btnPlayer6.Enabled = False
' Enable the currently active turn
Select Case count
Case 1
btnPlayer1.Enabled = True
Case 2
btnPlayer2.Enabled = True
Case 3
btnPlayer3.Enabled = True
Case 4
btnPlayer4.Enabled = True
Case 5
btnPlayer5.Enabled = True
Case 6
btnPlayer6.Enabled = True
End Select
End Sub
Sub AnalyzeCheckBoxes()
' Check to see if all checkboxes are clicked on
If chkKeep1.Value = 1 Then
If chkKeep2.Value = 1 Then
If chkKeep3.Value = 1 Then
If chkKeep4.Value = 1 Then
If chkKeep5.Value = 1 Then
ClickFlag = 1
InitImages
ClickFlag = 0
btnRoll.Enabled = "True"
KeepFlag = 1
End If
End If
End If
End If
End If
End Sub
Sub btnKeep_Click()
Dim i As Integer
Dim dice_number As Integer
' Must add score to total
' Must automatically check checkboxes
' Must disable checkboxes
lblTotalScore.Caption = lblTotalScore.Caption + lblMatchDice.Caption
' Clear the matching dice label
lblMatchDice.Caption = ""
' Set the clickflag to true - this prevents checkboxes from running when this routine
' automatically updates checkboxes
ClickFlag = 1
' check each checkbox to see if it is off, if it is, then check for matching number
For i = 1 To 5
Select Case i
Case 1 ' Image 1
If chkKeep1.Value = 0 Then
dice_number = ReturnDiceNumber(1)
If dice_number = DiceMatched Then
chkKeep1.Value = 1
chkKeep1.Enabled = "False"
End If
End If
Case 2 ' Image 2
If chkKeep2.Value = 0 Then
dice_number = ReturnDiceNumber(2)
If dice_number = DiceMatched Then
chkKeep2.Value = 1
chkKeep2.Enabled = "False"
End If
End If
Case 3
If chkKeep3.Value = 0 Then
dice_number = ReturnDiceNumber(3)
If dice_number = DiceMatched Then
chkKeep3.Value = 1
chkKeep3.Enabled = "False"
End If
End If
Case 4
If chkKeep4.Value = 0 Then
dice_number = ReturnDiceNumber(4)
If dice_number = DiceMatched Then
chkKeep4.Value = 1
chkKeep4.Enabled = "False"
End If
End If
Case 5
If chkKeep5.Value = 0 Then
dice_number = ReturnDiceNumber(5)
If dice_number = DiceMatched Then
chkKeep5.Value = 1
chkKeep5.Enabled = "False"
End If
End If
End Select
Next i
' clear the clickflag
ClickFlag = 0
btnKeep.Enabled = "False"
' Check to make sure all boxes are checked
AnalyzeCheckBoxes
' Set the keep flag
KeepFlag = 1
End Sub
Sub btnPlayer1_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore1.Caption = lblScore1.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore1.Caption >= 10000 Then
InfoBox.Message("", "Player 1 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnPlayer2_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore2.Caption = lblScore2.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore2.Caption >= 10000 Then
InfoBox.Message("", "Player 2 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnPlayer3_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore3.Caption = lblScore3.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore3.Caption >= 10000 Then
InfoBox.Message("", "Player 1 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnPlayer4_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore4.Caption = lblScore4.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore4.Caption >= 10000 Then
InfoBox.Message("", "Player 4 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnPlayer5_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore5.Caption = lblScore5.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore5.Caption >= 10000 Then
InfoBox.Message("", "Player 5 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnPlayer6_Click()
If btnRoll.Enabled = "True" Then
If lblTotalScore.Caption <> "" Then
lblScore6.Caption = lblScore6.Caption + lblTotalScore.Caption
' Reset the turn
ResetTurn
IncrementPlayer
End If
' Check to see if the player has won
If lblScore6.Caption >= 10000 Then
InfoBox.Message("", "Player 6 is the winner!")
NewGame_Click
End If
End If
End Sub
Sub btnRoll_Click()
Dim i, j, r as Integer
Dim rolled_length As Integer
Dim dice_number As Integer
Dim dice_valid As Integer
Dim dice_value
' If the end of the turn is over, reset new
If lblLostAmount.Caption <> "" Then
ResetTurn
IncrementPlayer
lblLostAmount.Caption = ""
End If
' Clear DiceRolled string
DiceRolled = ""
DiceCount = 0
' This guy makes sure something got saved
If KeepFlag = 0 Then
InfoBox.Message("", "You must keep at least one dice.")
Exit Sub
End If
' Disable all checked boxes
DisableCheckedBoxes
lblMatchDice.Caption = ""
btnKeep.Enabled = "False"
btnRoll.Enabled = "False"
For i = 1 To 5
Select Case i
Case 1 ' Image 1
If chkKeep1.Value = 0 Then
r = RollDice(1, 6, 1)
Select Case r
Case 1
imgDice1.Picture = bmpDice1
DiceRolled = DiceRolled & 1
Case 2
imgDice1.Picture = bmpDice2
DiceRolled = DiceRolled & 2
Case 3
imgDice1.Picture = bmpDice3
DiceRolled = DiceRolled & 3
Case 4
imgDice1.Picture = bmpDice4
DiceRolled = DiceRolled & 4
Case 5
imgDice1.Picture = bmpDice5
DiceRolled = DiceRolled & 5
Case 6
imgDice1.Picture = bmpDice6
DiceRolled = DiceRolled & 6
End Select
imgDice1.Refresh
End If
Case 2 ' Image 2
If chkKeep2.Value = 0 Then
r = RollDice(1, 6, 1)
Select Case r
Case 1
imgDice2.Picture = bmpDice1
DiceRolled = DiceRolled & 1
Case 2
imgDice2.Picture = bmpDice2
DiceRolled = DiceRolled & 2
Case 3
imgDice2.Picture = bmpDice3
DiceRolled = DiceRolled & 3
Case 4
imgDice2.Picture = bmpDice4
DiceRolled = DiceRolled & 4
Case 5
imgDice2.Picture = bmpDice5
DiceRolled = DiceRolled & 5
Case 6
imgDice2.Picture = bmpDice6
DiceRolled = DiceRolled & 6
End Select
imgDice2.Refresh
End If
Case 3 ' Image 3
If chkKeep3.Value = 0 Then
r = RollDice(1, 6, 1)
Select Case r
Case 1
imgDice3.Picture = bmpDice1
DiceRolled = DiceRolled & 1
Case 2
imgDice3.Picture = bmpDice2
DiceRolled = DiceRolled & 2
Case 3
imgDice3.Picture = bmpDice3
DiceRolled = DiceRolled & 3
Case 4
imgDice3.Picture = bmpDice4
DiceRolled = DiceRolled & 4
Case 5
imgDice3.Picture = bmpDice5
DiceRolled = DiceRolled & 5
Case 6
imgDice3.Picture = bmpDice6
DiceRolled = DiceRolled & 6
End Select
imgDice3.Refresh
End If
Case 4 ' Image 4
If chkKeep4.Value = 0 Then
r = RollDice(1, 6, 1)
Select Case r
Case 1
imgDice4.Picture = bmpDice1
DiceRolled = DiceRolled & 1
Case 2
imgDice4.Picture = bmpDice2
DiceRolled = DiceRolled & 2
Case 3
imgDice4.Picture = bmpDice3
DiceRolled = DiceRolled & 3
Case 4
imgDice4.Picture = bmpDice4
DiceRolled = DiceRolled & 4
Case 5
imgDice4.Picture = bmpDice5
DiceRolled = DiceRolled & 5
Case 6
imgDice4.Picture = bmpDice6
DiceRolled = DiceRolled & 6
End Select
imgDice4.Refresh
End If
Case 5 ' Image 5
If chkKeep5.Value = 0 Then
r = RollDice(1, 6, 1)
Select Case r
Case 1
imgDice5.Picture = bmpDice1
DiceRolled = DiceRolled & 1
Case 2
imgDice5.Picture = bmpDice2
DiceRolled = DiceRolled & 2
Case 3
imgDice5.Picture = bmpDice3
DiceRolled = DiceRolled & 3
Case 4
imgDice5.Picture = bmpDice4
DiceRolled = DiceRolled & 4
Case 5
imgDice5.Picture = bmpDice5
DiceRolled = DiceRolled & 5
Case 6
imgDice5.Picture = bmpDice6
DiceRolled = DiceRolled & 6
End Select
imgDice1.Refresh
End If
End Select
Next i
btnRoll.Enabled = "True"
DiceCount = Len(DiceRolled)
' Check for duplicate dice
If DiceCount > 2 Then
CheckForDuplicates
End If
' set variable to false initially
dice_valid = 0
' If there was matching dice, Keep button to check valid next turn
If lblMatchDice.Caption = "" Then
' Check for end of turn by no valid dice being rolled
rolled_length = Len(DiceRolled)
For i = 1 To rolled_length
dice_number = Mid(DiceRolled, i, 1)
If dice_number = 1 Or dice_number = 5 Then
dice_valid = 1
Exit For
End If
Next i
If dice_valid = 0 Then
' End of turn, no valid dice rolled, clear everything
If lblTotalScore.Caption = "" Then
lblLostAmount.Caption = "LOST AMOUNT = 0"
Else
lblLostAmount.Caption = "LOST AMOUNT = " & lblTotalScore.Caption
End If
chkKeep1.Enabled = "False"
chkKeep2.Enabled = "False"
chkKeep3.Enabled = "False"
chkKeep4.Enabled = "False"
chkKeep4.Enabled = "False"
End If
Else
' The Keep button is enabled so we have to disable the corresponding checkboxes
' so a clever user don't click them and then the Keep button
' The DiceMatched flag should contain the dice we're interested in protecting
' check each checkbox to see if it is off, if it is, then check for matching number
For j = 1 To 5
Select Case j
Case 1 ' Image 1
If chkKeep1.Value = 0 Then
dice_value = ReturnDiceNumber(1)
If dice_value = DiceMatched Then
chkKeep1.Enabled = "False"
End If
End If
Case 2 ' Image 2
If chkKeep2.Value = 0 Then
dice_value = ReturnDiceNumber(2)
If dice_value = DiceMatched Then
chkKeep2.Enabled = "False"
End If
End If
Case 3
If chkKeep3.Value = 0 Then
dice_value = ReturnDiceNumber(3)
If dice_value = DiceMatched Then
chkKeep3.Enabled = "False"
End If
End If
Case 4
If chkKeep4.Value = 0 Then
dice_value = ReturnDiceNumber(4)
If dice_value = DiceMatched Then
chkKeep4.Enabled = "False"
End If
End If
Case 5
If chkKeep5.Value = 0 Then
dice_value = ReturnDiceNumber(5)
If dice_value = DiceMatched Then
chkKeep5.Enabled = "False"
End If
End If
End Select
Next j
End If
' This flag determines if a checkbox was clicked
KeepFlag = 0
End Sub
Sub CheckForDuplicates()
Dim i, j, match_count, target_number, check_number, matched_number As Integer
' target_number is the number being checked for duplicates
' check_number is each of the other numbers to the right of the target_number
' match_count will track number of matches for target_number
' matched_number is the number in which a duplicate was found
For i = 1 To DiceCount
match_count = 1
target_number = Mid(DiceRolled, i, 1)
For j = (i + 1) To DiceCount
check_number = Mid(DiceRolled, j, 1)
If check_number = target_number Then
matched_number = target_number
match_count = match_count + 1
End If
Next j
If match_count >= 3 Then Exit For
Next i
If match_count >= 3 Then
ComputeDiceScore(matched_number, match_count)
End If
End Sub
Sub chkKeep1_Click()
Dim dice_value As Integer
Dim dice_number
' If this guy is set to true, then the checkbox is being updated automatically
If ClickFlag = 1 Then Exit Sub
' Check to make sure the value is 1 or 5 - if it is add to score if turned on
' Otherwise subtract it from the total
If imgDice1.Picture = bmpDice1 Then
dice_number = 1
dice_value = 100
ElseIf imgDice1.Picture = bmpDice5 Then
dice_number = 5
dice_value = 50
Else
dice_number = 0
End If
' If there is no valid dice on the click, then we don't keep the checkbox true
If dice_number = 0 Then
chkKeep1.Value = 0
Exit Sub
End If
If chkKeep1.Value = 0 Then
' Subtract from score
lblTotalScore.Caption = lblTotalScore.Caption - dice_value
KeepFlag = KeepFlag - 1
Else
' Add to score
lblTotalScore.Caption = lblTotalScore.Caption + dice_value
' Set the keep flag to true
KeepFlag = KeepFlag + 1
End If
' Check to see if all checkboxes are clicked on
AnalyzeCheckBoxes
End Sub
Sub chkKeep2_Click()
Dim dice_value As Integer
Dim dice_number
' If this guy is set to true, then the checkbox is being updated automatically
If ClickFlag = 1 Then Exit Sub
' Check to make sure the value is 1 or 5 - if it is add to score if turned on
' Otherwise subtract it from the total
If imgDice2.Picture = bmpDice1 Then
dice_number = 1
dice_value = 100
ElseIf imgDice2.Picture = bmpDice5 Then
dice_number = 5
dice_value = 50
Else
dice_number = 0
End If
' If there is no valid dice on the click, then we don't keep the checkbox true
If dice_number = 0 Then
chkKeep2.Value = 0
Exit Sub
End If
If chkKeep2.Value = 0 Then
' Subtract from score
lblTotalScore.Caption = lblTotalScore.Caption - dice_value
KeepFlag = KeepFlag - 1
Else
' Add to score
lblTotalScore.Caption = lblTotalScore.Caption + dice_value
KeepFlag = KeepFlag + 1
End If
' Check to see if all checkboxes are clicked on
AnalyzeCheckBoxes
End Sub
Sub chkKeep3_Click()
Dim dice_value As Integer
Dim dice_number
' If this guy is set to true, then the checkbox is being updated automatically
If ClickFlag = 1 Then Exit Sub
' Check to make sure the value is 1 or 5 - if it is add to score if turned on
' Otherwise subtract it from the total
If imgDice3.Picture = bmpDice1 Then
dice_number = 1
dice_value = 100
ElseIf imgDice3.Picture = bmpDice5 Then
dice_number = 5
dice_value = 50
Else
dice_number = 0
End If
' If there is no valid dice on the click, then we don't keep the checkbox true
If dice_number = 0 Then
chkKeep3.Value = 0
Exit Sub
End If
If chkKeep3.Value = 0 Then
' Subtract from score
lblTotalScore.Caption = lblTotalScore.Caption - dice_value
KeepFlag = KeepFlag - 1
Else
' Add to score
lblTotalScore.Caption = lblTotalScore.Caption + dice_value
KeepFlag = KeepFlag + 1
End If
' Check to see if all checkboxes are clicked on
AnalyzeCheckBoxes
End Sub
Sub chkKeep4_Click()
Dim dice_value As Integer
Dim dice_number
' If this guy is set to true, then the checkbox is being updated automatically
If ClickFlag = 1 Then Exit Sub
' Check to make sure the value is 1 or 5 - if it is add to score if turned on
' Otherwise subtract it from the total
If imgDice4.Picture = bmpDice1 Then
dice_number = 1
dice_value = 100
ElseIf imgDice4.Picture = bmpDice5 Then
dice_number = 5
dice_value = 50
Else
dice_number = 0
End If
' If there is no valid dice on the click, then we don't keep the checkbox true
If dice_number = 0 Then
chkKeep4.Value = 0
Exit Sub
End If
If chkKeep4.Value = 0 Then
' Subtract from score
lblTotalScore.Caption = lblTotalScore.Caption - dice_value
KeepFlag = KeepFlag - 1
Else
' Add to score
lblTotalScore.Caption = lblTotalScore.Caption + dice_value
KeepFlag = KeepFlag + 1
End If
' Check to see if all checkboxes are clicked on
AnalyzeCheckBoxes
End Sub
Sub chkKeep5_Click()
Dim dice_value As Integer
Dim dice_number
' If this guy is set to true, then the checkbox is being updated automatically
If ClickFlag = 1 Then Exit Sub
' Check to make sure the value is 1 or 5 - if it is add to score if turned on
' Otherwise subtract it from the total
If imgDice5.Picture = bmpDice1 Then
dice_number = 1
dice_value = 100
ElseIf imgDice5.Picture = bmpDice5 Then
dice_number = 5
dice_value = 50
Else
dice_number = 0
End If
' If there is no valid dice on the click, then we don't keep the checkbox true
If dice_number = 0 Then
chkKeep5.Value = 0
Exit Sub
End If
If chkKeep5.Value = 0 Then
' Subtract from score
lblTotalScore.Caption = lblTotalScore.Caption - dice_value
KeepFlag = KeepFlag - 1
Else
' Add to score
lblTotalScore.Caption = lblTotalScore.Caption + dice_value
KeepFlag = KeepFlag + 1
End If
' Check to see if all checkboxes are clicked on
AnalyzeCheckBoxes
End Sub
Sub ClearPlayerCheckmarks()
OptionsPlayersMenu.CheckItem("PlayerNumber1", 0)
OptionsPlayersMenu.CheckItem("PlayerNumber2", 0)
OptionsPlayersMenu.CheckItem("PlayerNumber3", 0)
OptionsPlayersMenu.CheckItem("PlayerNumber4", 0)
OptionsPlayersMenu.CheckItem("PlayerNumber5", 0)
OptionsPlayersMenu.CheckItem("PlayerNumber6", 0)
End Sub
Sub ComputeDiceScore(dice_number As Integer, dice_count As Integer)
Dim score As Integer
' Compute the score of the dice
Select Case dice_number
Case 1
If dice_count = 3 Then
score = 1000
ElseIf dice_count = 4 Then
score = 2000
Else
score = 4000
End If
Case 2
If dice_count = 3 Then
score = 200
ElseIf dice_count = 4 Then
score = 400
Else
score = 800
End If
Case 3
If dice_count = 3 Then
score = 300
ElseIf dice_count = 4 Then
score = 600
Else
score = 1200
End If
Case 4
If dice_count = 3 Then
score = 400
ElseIf dice_count = 4 Then
score = 800
Else
score = 1600
End If
Case 5
If dice_count = 3 Then
score = 500
ElseIf dice_count = 4 Then
score = 1000
Else
score = 2000
End If
Case 6
If dice_count = 3 Then
score = 600
ElseIf dice_count = 4 Then
score = 1200
Else
score = 2400
End If
End Select
lblMatchDice.Caption = Str(score)
btnKeep.Enabled = "True"
' Store the matching dice number
DiceMatched = dice_number
End Sub
Sub DiceAbout_Click()
DiceAboutForm.Show
End Sub
Sub DisableCheckedBoxes()
' We want to disable all boxes that have been previously clicked
If chkKeep1.Value = 1 Then chkKeep1.Enabled = "False"
If chkKeep2.Value = 1 Then chkKeep2.Enabled = "False"
If chkKeep3.Value = 1 Then chkKeep3.Enabled = "False"
If chkKeep4.Value = 1 Then chkKeep4.Enabled = "False"
If chkKeep5.Value = 1 Then chkKeep5.Enabled = "False"
' We want to enable all disabled checkboxes that are not checked
' in the event the user didn't click keep button
If chkKeep1.Enabled = "False" Then
If chkKeep1.Value = 0 Then chkKeep1.Enabled = "True"
End If
If chkKeep2.Enabled = "False" Then
If chkKeep2.Value = 0 Then chkKeep2.Enabled = "True"
End If
If chkKeep3.Enabled = "False" Then
If chkKeep3.Value = 0 Then chkKeep3.Enabled = "True"
End If
If chkKeep4.Enabled = "False" Then
If chkKeep4.Value = 0 Then chkKeep4.Enabled = "True"
End If
If chkKeep5.Enabled = "False" Then
If chkKeep5.Value = 0 Then chkKeep5.Enabled = "True"
End If
End Sub
Sub EnsureBitmaps
bmpDice0.FileName = SampleDir & "dice0.bmp"
bmpDice1.FileName = SampleDir & "dice1.bmp"
bmpDice2.FileName = SampleDir & "dice2.bmp"
bmpDice3.FileName = SampleDir & "dice3.bmp"
bmpDice4.FileName = SampleDir & "dice4.bmp"
bmpDice5.FileName = SampleDir & "dice5.bmp"
bmpDice6.FileName = SampleDir & "dice6.bmp"
End Sub
Sub ExitDice_Click()
' Clear the form before leaving
NewGame_Click
Hide
End Sub
Sub imgDice1_Click()
chkKeep1.Value = 1 - chkKeep1.Value
End Sub
Sub imgDice2_Click()
chkKeep2.Value = 1 - chkKeep2.Value
End Sub
Sub imgDice3_Click()
chkKeep3.Value = 1 - chkKeep3.Value
End Sub
Sub imgDice4_Click()
chkKeep4.Value = 1 - chkKeep4.Value
End Sub
Sub imgDice5_Click()
chkKeep5.Value = 1 - chkKeep5.Value
End Sub
Sub IncrementPlayer()
If CurrentTurn = PlayerNumber Then
CurrentTurn = 1
Else
CurrentTurn = CurrentTurn + 1
End If
' Activate the current players turn
Select Case CurrentTurn
Case 1
ActivatePlayer(1)
Case 2
ActivatePlayer(2)
Case 3
ActivatePlayer(3)
Case 4
ActivatePlayer(4)
Case 5
ActivatePlayer(5)
Case 6
ActivatePlayer(6)
End Select
End Sub
Sub InitImages()
' Don't allow checkbox methods to run
ClickFlag = 1
' Clear the dice counter flags
DiceMatched = 0
DiceRolled = ""
DiceCount = ""
EnsureBitmaps
' Sets all dice pictures to blank dice
imgDice1.Picture = bmpDice0
imgDice2.Picture = bmpDice0
imgDice3.Picture = bmpDice0
imgDice4.Picture = bmpDice0
imgDice5.Picture = bmpDice0
' Turn off all checkboxes - this will set the NumRolls to 5
chkKeep1.Value = 0
chkKeep2.Value = 0
chkKeep3.Value = 0
chkKeep4.Value = 0
chkKeep5.Value = 0
' Enable the checkboxes
chkKeep1.Enabled = "True"
chkKeep2.Enabled = "True"
chkKeep3.Enabled = "True"
chkKeep4.Enabled = "True"
chkKeep5.Enabled = "True"
ClickFlag = 0
End Sub
Sub NewGame_Click()
' Reset the game
ResetTurn
' Clear all scores
lblScore1.Caption = ""
lblScore2.Caption = ""
lblScore3.Caption = ""
lblScore4.Caption = ""
lblScore5.Caption = ""
lblScore6.Caption = ""
CurrentTurn = 1
ActivatePlayer(1)
End Sub
Sub PlayerNumber1_Click()
ClearPlayerCheckmarks
SetPlayerNumber(1)
OptionsPlayersMenu.CheckItem("PlayerNumber1", 1)
End Sub
Sub PlayerNumber2_Click()
ClearPlayerCheckmarks
SetPlayerNumber(2)
OptionsPlayersMenu.CheckItem("PlayerNumber2", 1)
End Sub
Sub PlayerNumber3_Click()
ClearPlayerCheckmarks
SetPlayerNumber(3)
OptionsPlayersMenu.CheckItem("PlayerNumber3", 1)
End Sub
Sub PlayerNumber4_Click()
ClearPlayerCheckmarks
SetPlayerNumber(4)
OptionsPlayersMenu.CheckItem("PlayerNumber4", 1)
End Sub
Sub PlayerNumber5_Click()
ClearPlayerCheckmarks
SetPlayerNumber(5)
OptionsPlayersMenu.CheckItem("PlayerNumber5", 1)
End Sub
Sub PlayerNumber6_Click()
ClearPlayerCheckmarks
SetPlayerNumber(6)
OptionsPlayersMenu.CheckItem("PlayerNumber6", 1)
End Sub
Sub ResetApplication_Click ()
' Initialize bitmaps to image controls
InitImages
ResetTurn
lblLostAmount.Caption = ""
' Set the default number of players
ClearPlayerCheckmarks
SetPlayerNumber(6)
OptionsPlayersMenu.CheckItem("PlayerNumber6", 1)
End Sub
Sub ResetTurn()
' Initialize all images
InitImages
' Enable the roll button
btnRoll.Enabled = "True"
btnKeep.Enabled = "False"
lblMatchDice.Caption = ""
lblTotalScore.Caption = ""
' Allow the user to roll dice the first time without a previous save
KeepFlag = 1
End Sub
Function ReturnDiceNumber(dice_column As Integer) As Integer
' In the event the requested checkbox is true
ReturnDiceNumber = 0
' determine which dice is present and return that value
Select Case dice_column
Case 1 ' Image 1
Select Case imgDice1.Picture
Case bmpDice0
ReturnDiceNumber = 0
Case bmpDice1
ReturnDiceNumber = 1
Case bmpDice2
ReturnDiceNumber = 2
Case bmpDice3
ReturnDiceNumber = 3
Case bmpDice4
ReturnDiceNumber = 4
Case bmpDice5
ReturnDiceNumber = 5
Case bmpDice6
ReturnDiceNumber = 6
End Select
Case 2 ' Image 2
Select Case imgDice2.Picture
Case bmpDice0
ReturnDiceNumber = 0
Case bmpDice1
ReturnDiceNumber = 1
Case bmpDice2
ReturnDiceNumber = 2
Case bmpDice3
ReturnDiceNumber = 3
Case bmpDice4
ReturnDiceNumber = 4
Case bmpDice5
ReturnDiceNumber = 5
Case bmpDice6
ReturnDiceNumber = 6
End Select
Case 3
Select Case imgDice3.Picture
Case bmpDice0
ReturnDiceNumber = 0
Case bmpDice1
ReturnDiceNumber = 1
Case bmpDice2
ReturnDiceNumber = 2
Case bmpDice3
ReturnDiceNumber = 3
Case bmpDice4
ReturnDiceNumber = 4
Case bmpDice5
ReturnDiceNumber = 5
Case bmpDice6
ReturnDiceNumber = 6
End Select
Case 4
Select Case imgDice4.Picture
Case bmpDice0
ReturnDiceNumber = 0
Case bmpDice1
ReturnDiceNumber = 1
Case bmpDice2
ReturnDiceNumber = 2
Case bmpDice3
ReturnDiceNumber = 3
Case bmpDice4
ReturnDiceNumber = 4
Case bmpDice5
ReturnDiceNumber = 5
Case bmpDice6
ReturnDiceNumber = 6
End Select
Case 5
Select Case imgDice5.Picture
Case bmpDice0
ReturnDiceNumber = 0
Case bmpDice1
ReturnDiceNumber = 1
Case bmpDice2
ReturnDiceNumber = 2
Case bmpDice3
ReturnDiceNumber = 3
Case bmpDice4
ReturnDiceNumber = 4
Case bmpDice5
ReturnDiceNumber = 5
Case bmpDice6
ReturnDiceNumber = 6
End Select
End Select
End Function
Function RollDice(low as integer, high as integer, n as integer) as integer
dim range, sum, i as integer
range = high - low + 1
sum = 0
For i = 1 To n
sum = sum + rnd() * range + low
Next i
RollDice = sum
End Function
Sub SetPlayerNumber(count As Integer)
DiceMasterForm.PlayerNumber = count
' Hide all player entries
btnPlayer1.Visible = False : lblScore1.Visible = False
btnPlayer2.Visible = False : lblScore2.Visible = False
btnPlayer3.Visible = False : lblScore3.Visible = False
btnPlayer4.Visible = False : lblScore4.Visible = False
btnPlayer5.Visible = False : lblScore5.Visible = False
btnPlayer6.Visible = False : lblScore6.Visible = False
Select Case count
Case 1
btnPlayer1.Visible = True : lblScore1.Visible = True
Case 2
btnPlayer1.Visible = True : lblScore1.Visible = True
btnPlayer2.Visible = True : lblScore2.Visible = True
Case 3
btnPlayer1.Visible = True : lblScore1.Visible = True
btnPlayer2.Visible = True : lblScore2.Visible = True
btnPlayer3.Visible = True : lblScore3.Visible = True
Case 4
btnPlayer1.Visible = True : lblScore1.Visible = True
btnPlayer2.Visible = True : lblScore2.Visible = True
btnPlayer3.Visible = True : lblScore3.Visible = True
btnPlayer4.Visible = True : lblScore4.Visible = True
Case 5
btnPlayer1.Visible = True : lblScore1.Visible = True
btnPlayer2.Visible = True : lblScore2.Visible = True
btnPlayer3.Visible = True : lblScore3.Visible = True
btnPlayer4.Visible = True : lblScore4.Visible = True
btnPlayer5.Visible = True : lblScore5.Visible = True
Case 6
btnPlayer1.Visible = True : lblScore1.Visible = True
btnPlayer2.Visible = True : lblScore2.Visible = True
btnPlayer3.Visible = True : lblScore3.Visible = True
btnPlayer4.Visible = True : lblScore4.Visible = True
btnPlayer5.Visible = True : lblScore5.Visible = True
btnPlayer6.Visible = True : lblScore6.Visible = True
End Select
' Since the players have been changed, reset the game
NewGame_Click
End Sub
End Type
Type DiceAboutForm From Form
Dim btnClose As New Button
Dim Label1 As New Label
Dim Label2 As New Label
Dim Label3 As New Label
Dim Label4 As New Label
Dim Label5 As New Label
Dim Label6 As New Label
Dim Label7 As New Label
Dim Label8 As New Label
Dim Label9 As New Label
Dim Label10 As New Label
Dim Label11 As New Label
Dim Label12 As New Label
Dim Label13 As New Label
Dim Label14 As New Label
Dim Label15 As New Label
' METHODS for object: DiceAboutForm
Sub btnClose_Click()
Hide
End Sub
End Type
Type DiceMenuBar From MenuBar
End Type
Begin Code
' Reconstruction commands for object: DiceOptionMenu
'
With DiceOptionMenu
.InsertItem("NewGame", "&New Game", -1)
.InsertItem("DiceAbout", "&About", -1)
.InsertPopup(OptionsPlayersMenu, "Players", -1)
End With 'DiceOptionMenu
' Reconstruction commands for object: OptionsPlayersMenu
'
With OptionsPlayersMenu
.InsertItem("PlayerNumber1", "1", -1)
.InsertItem("PlayerNumber2", "2", -1)
.InsertItem("PlayerNumber3", "3", -1)
.InsertItem("PlayerNumber4", "4", -1)
.InsertItem("PlayerNumber5", "5", -1)
.InsertItem("PlayerNumber6", "6", -1)
End With 'OptionsPlayersMenu
' Reconstruction commands for object: DiceMasterForm
'
With DiceMasterForm
.Caption := "10,000 Dice Game"
.BackColor := 8421440
.Move(3810, 1860, 7485, 4140)
.BevelWidth := 0
.MenuBar := DiceMenuBar
.SampleDir := "C:\ENVELOP\arsenal\apps\gamedice\"
.SampleName := "gamedice"
.DiceRolled := ""
.DiceCount := 0
.DiceMatched := 0
.ClickFlag := 0
.KeepFlag := 1
.PlayerNumber := 6
.CurrentTurn := 1
With .btnRoll
.Caption := "Roll"
.ZOrder := 1
.Move(300, 2700, 1050, 450)
End With 'DiceMasterForm.btnRoll
With .chkKeep1
.ZOrder := 2
.Move(465, 1800, 300, 300)
.Ctrl3d := False
End With 'DiceMasterForm.chkKeep1
With .chkKeep2
.ZOrder := 3
.Move(1365, 1800, 330, 300)
.Ctrl3d := False
End With 'DiceMasterForm.chkKeep2
With .chkKeep3
.ZOrder := 4
.Move(2250, 1800, 345, 300)
.Ctrl3d := False
End With 'DiceMasterForm.chkKeep3
With .chkKeep4
.ZOrder := 5
.Move(3150, 1800, 300, 300)
.Ctrl3d := False
End With 'DiceMasterForm.chkKeep4
With .chkKeep5
.ZOrder := 6
.Move(4065, 1800, 300, 300)
.Ctrl3d := False
End With 'DiceMasterForm.chkKeep5
With .imgDice1
.Caption := "imgDice1"
.ZOrder := 7
.Move(300, 1200, 480, 480)
.BevelOuter := "None"
.AutoInitCropRect := False
.Picture := DiceMasterForm.bmpDice0
.ResizeMode := "Clip"
.ScrollBars := "Never"
.ScaleX := 1
.ScaleY := 1
End With 'DiceMasterForm.imgDice1
With .imgDice2
.Caption := "imgDice2"
.ZOrder := 8
.Move(1200, 1200, 480, 480)
.BevelOuter := "None"
.AutoInitCropRect := False
.Picture := DiceMasterForm.bmpDice0
.ResizeMode := "Clip"
.ScrollBars := "Never"
.ScaleX := 1
.ScaleY := 1
End With 'DiceMasterForm.imgDice2
With .imgDice3
.Caption := "imgDice3"
.ZOrder := 9
.Move(2100, 1200, 480, 480)
.BevelOuter := "None"
.AutoInitCropRect := False
.Picture := DiceMasterForm.bmpDice0
.ResizeMode := "Clip"
.ScrollBars := "Never"
.ScaleX := 1
.ScaleY := 1
End With 'DiceMasterForm.imgDice3
With .imgDice4
.Caption := "imgDice4"
.ZOrder := 10
.Move(3000, 1200, 480, 480)
.BevelOuter := "None"
.AutoInitCropRect := False
.Picture := DiceMasterForm.bmpDice0
.ResizeMode := "Clip"
.ScrollBars := "Never"
.ScaleX := 1
.ScaleY := 1
End With 'DiceMasterForm.imgDice4
With .imgDice5
.Caption := "imgDice5"
.ZOrder := 11
.Move(3900, 1200, 480, 480)
.BevelOuter := "None"
.AutoInitCropRect := False
.Picture := DiceMasterForm.bmpDice0
.ResizeMode := "Clip"
.ScrollBars := "Never"
.ScaleX := 1
.ScaleY := 1
End With 'DiceMasterForm.imgDice5
With .bmpDice1
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 0
End With 'DiceMasterForm.bmpDice1
With .bmpDice2
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 628
End With 'DiceMasterForm.bmpDice2
With .bmpDice3
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 1256
End With 'DiceMasterForm.bmpDice3
With .bmpDice4
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 1884
End With 'DiceMasterForm.bmpDice4
With .bmpDice5
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 2512
End With 'DiceMasterForm.bmpDice5
With .bmpDice6
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 3140
End With 'DiceMasterForm.bmpDice6
With .bmpDice0
.LoadType := "MemoryBased"
.FileName := "gamedice.ero"
.ResId := 3768
End With 'DiceMasterForm.bmpDice0
With .Label1
.Caption := "Click box below dice to keep roll."
.ZOrder := 12
.Move(750, 2250, 3450, 300)
End With 'DiceMasterForm.Label1
With .btnKeep
.Caption := "Keep Match"
.Enabled := False
.ZOrder := 13
.Move(3450, 600, 1350, 300)
End With 'DiceMasterForm.btnKeep
With .Label2
.Caption := "Total score this turn:"
.ZOrder := 14
.Move(300, 150, 2100, 300)
End With 'DiceMasterForm.Label2
With .lblTotalScore
.ZOrder := 15
.Move(2400, 150, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblTotalScore
With .Label3
.Caption := "Matching dice score:"
.ZOrder := 16
.Move(300, 600, 2100, 300)
End With 'DiceMasterForm.Label3
With .lblMatchDice
.ZOrder := 17
.Move(2400, 600, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblMatchDice
With .Label4
.Caption := "Players:"
.ZOrder := 18
.Move(5100, 150, 1050, 300)
End With 'DiceMasterForm.Label4
With .btnPlayer1
.Caption := "Player 1"
.ZOrder := 19
.Move(5100, 600, 1050, 300)
End With 'DiceMasterForm.btnPlayer1
With .btnPlayer2
.Caption := "Player 2"
.Enabled := False
.ZOrder := 20
.Move(5100, 1050, 1050, 300)
End With 'DiceMasterForm.btnPlayer2
With .btnPlayer3
.Caption := "Player 3"
.Enabled := False
.ZOrder := 21
.Move(5100, 1500, 1050, 300)
End With 'DiceMasterForm.btnPlayer3
With .btnPlayer4
.Caption := "Player 4"
.Enabled := False
.ZOrder := 22
.Move(5100, 1950, 1050, 300)
End With 'DiceMasterForm.btnPlayer4
With .lblScore1
.ZOrder := 23
.Move(6300, 600, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore1
With .lblScore2
.ZOrder := 24
.Move(6300, 1050, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore2
With .lblScore3
.ZOrder := 25
.Move(6300, 1500, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore3
With .lblScore4
.ZOrder := 26
.Move(6300, 1950, 885, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore4
With .Label9
.Caption := "Scores:"
.ZOrder := 27
.Move(6300, 150, 900, 300)
End With 'DiceMasterForm.Label9
With .btnPlayer5
.Caption := "Player 5"
.Enabled := False
.ZOrder := 28
.Move(5100, 2400, 1050, 300)
End With 'DiceMasterForm.btnPlayer5
With .btnPlayer6
.Caption := "Player 6"
.Enabled := False
.ZOrder := 29
.Move(5100, 2850, 1050, 300)
End With 'DiceMasterForm.btnPlayer6
With .lblScore5
.ZOrder := 30
.Move(6300, 2400, 900, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore5
With .lblScore6
.ZOrder := 31
.Move(6300, 2850, 900, 300)
.BorderStyle := "Fixed Single"
End With 'DiceMasterForm.lblScore6
With .lblLostAmount
.ForeColor := 33023
.ZOrder := 32
.Move(1650, 2850, 3000, 300)
.Alignment := "Center"
End With 'DiceMasterForm.lblLostAmount
With .helpfile
.FileName := "C:\ENVELOP\arsenal\apps\gamedice\gamedice.hlp"
End With 'DiceMasterForm.helpfile
End With 'DiceMasterForm
' Reconstruction commands for object: DiceAboutForm
'
With DiceAboutForm
.Caption := " About 10,000 Dice Game"
.Move(7020, 1350, 7290, 5205)
.Outlined := True
With .btnClose
.Caption := "Close"
.ZOrder := 1
.Move(6000, 300, 900, 450)
End With 'DiceAboutForm.btnClose
With .Label1
.Caption := "Objective:"
.ForeColor := 13107200
.ZOrder := 1
.Move(300, 300, 1050, 300)
End With 'DiceAboutForm.Label1
With .Label2
.Caption := "First player to score 10,000 points wins!"
.ZOrder := 1
.Move(1500, 300, 4050, 300)
End With 'DiceAboutForm.Label2
With .Label3
.Caption := "Scoring:"
.ForeColor := 13107200
.ZOrder := 1
.Move(300, 750, 1050, 300)
End With 'DiceAboutForm.Label3
With .Label4
.Caption := "Each '1' rolled worth 100 pts."
.ZOrder := 1
.Move(450, 1050, 3000, 300)
End With 'DiceAboutForm.Label4
With .Label5
.Caption := "Each '5' rolled worth 50 pts."
.ZOrder := 1
.Move(3600, 1050, 3000, 300)
End With 'DiceAboutForm.Label5
With .Label6
.Caption := "(3) 1's rolled = 1000 (4) 1's rolled = 2000 (5) 1's rolled = 4000"
.ZOrder := 1
.Move(450, 1350, 6300, 300)
End With 'DiceAboutForm.Label6
With .Label7
.Caption := "(3) 2's rolled = 200 (4) 2's rolled = 400 (5) 2's rolled = 800"
.ZOrder := 1
.Move(450, 1650, 6300, 300)
End With 'DiceAboutForm.Label7
With .Label8
.Caption := "(3) 3's rolled = 300 (4) 3's rolled = 600 (5) 3's rolled = 1200"
.ZOrder := 1
.Move(450, 1950, 6300, 300)
End With 'DiceAboutForm.Label8
With .Label9
.Caption := "(3) 4's rolled = 400 (4) 4's rolled = 800 (5) 4's rolled = 1600"
.ZOrder := 1
.Move(450, 2250, 6300, 300)
End With 'DiceAboutForm.Label9
With .Label10
.Caption := "(3) 5's rolled = 500 (4) 5's rolled = 1000 (5) 5's rolled = 2000"
.ZOrder := 1
.Move(450, 2550, 6300, 300)
End With 'DiceAboutForm.Label10
With .Label11
.Caption := "(3) 6's rolled = 600 (4) 6's rolled = 1200 (5) 6's rolled = 2400"
.ZOrder := 1
.Move(450, 2850, 6300, 300)
End With 'DiceAboutForm.Label11
With .Label12
.Caption := "Rules:"
.ForeColor := 13107200
.ZOrder := 1
.Move(300, 3300, 1050, 300)
End With 'DiceAboutForm.Label12
With .Label13
.Caption := "1. Your turn continues as long as you score points on your roll."
.ZOrder := 1
.Move(450, 3600, 6300, 300)
End With 'DiceAboutForm.Label13
With .Label14
.Caption := "2. If you fail to score any points on your roll, you lose your score."
.ZOrder := 1
.Move(450, 3900, 6450, 300)
End With 'DiceAboutForm.Label14
With .Label15
.Caption := "3. You can stop anytime by clicking your designated player button."
.ZOrder := 1
.Move(450, 4200, 6600, 300)
End With 'DiceAboutForm.Label15
End With 'DiceAboutForm
' Reconstruction commands for object: DiceMenuBar
'
With DiceMenuBar
.InsertPopup(SampleMasterFormFileMenu, "&File", -1)
.InsertPopup(DiceOptionMenu, "&Options", -1)
.InsertPopup(SampleMasterFormHelpMenu, "&Help", -1)
End With 'DiceMenuBar
End Code