-
Nov 2nd, 2011, 10:44 PM
#1
Thread Starter
Junior Member
Game: Under & Over 7
I realized I posted this in the regular code bank, where as it should really go here.
I have just started learning VB today and wanted to experiment with it re-creating this simple game.
I have included the rules to the game in the menu bar, under Help.
Source:
Code:
Imports System.Collections.Generic
Public Class Form1
'Declarations
Dim PlayersName, PlayersBet, PlayersAnte As String
Dim Die1, Die2, DieResults, PlayersTotal, DealersTotal As Integer
Dim DelearsPotTotal, PlayersPotTotal As Double
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PlayersName = InputBox("What is your name?")
Enigma.Text = PlayersName
Randomize()
End Sub
Private Sub PlacePlayerBetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlacePlayerBetButton.Click
PlayersBet = PlayersBetBox.Text
End Sub
Private Sub PlacePlayerAnteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlacePlayerAnteButton.Click
PlayersAnte = PlayersAnteBox.Text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If PlayersBet = "" Then
MsgBox("Please input a bet!")
Exit Sub
ElseIf PlayersAnte = "" Then
MsgBox("Please input an ante!")
Exit Sub
End If
Die1 = Int(Rnd() * 10)
Die2 = Int(Rnd() * 10)
DieResults = Die1 + Die2
RollResults.Text = DieResults
RollResults.Visible = True
If DieResults > 7 Then
MsgBox("Payout is 1:1 because results were > 7")
If PlayersBet = ">" Then
MsgBox("You were right!")
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal - PlayersAnte
PlayersPot.Text = PlayersPotTotal + PlayersAnte
Else
MsgBox("You were wrong!")
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal + PlayersAnte
PlayersPot.Text = PlayersPotTotal - PlayersAnte
End If
ElseIf DieResults < 7 Then
MsgBox("Payout is 1:1 because results are < 7")
If PlayersBet = "<" Then
MsgBox("You were right!")
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal - PlayersAnte
PlayersPot.Text = PlayersPotTotal + PlayersAnte
Else
MsgBox("You were wrong!")
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal + PlayersAnte
PlayersPot.Text = PlayersPotTotal - PlayersAnte
End If
ElseIf DieResults = 7 Then
MsgBox("Payout is 5:5 because results were 7!")
If PlayersBet = "=" Then
MsgBox("You were right!")
PlayersAnte = PlayersAnte * 5
MsgBox(PlayersAnte)
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal - PlayersAnte
PlayersPot.Text = PlayersPotTotal + PlayersAnte
Else
MsgBox("You were wrong!")
DelearsPotTotal = DealersPot.Text
PlayersPotTotal = PlayersPot.Text
DealersPot.Text = DelearsPotTotal + PlayersAnte
PlayersPot.Text = PlayersPotTotal - PlayersAnte
End If
End If
End Sub
Private Sub AboutTheGameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutTheGameToolStripMenuItem.Click
MsgBox("There are three outcomes of the dice" & Environment.NewLine & _
Environment.NewLine & _
"1: The sum of the die is < 7" & Environment.NewLine & _
Environment.NewLine & _
"2: The sum of the die is > 7" & Environment.NewLine & _
Environment.NewLine & _
"3: The sum of the die is = 7" & Environment.NewLine & _
Environment.NewLine & _
"The payout that you recieve depends on the outcome." & Environment.NewLine & _
Environment.NewLine & _
"1 & 2 results in 1:1 payout (Depending on your difficulty choice)" & Environment.NewLine & _
Environment.NewLine & _
"3 results in a 5:5 payout (Once again, depending on your difficulty)" & Environment.NewLine & _
Environment.NewLine & _
"You and the banker both start with 10,000 cash." & Environment.NewLine & _
Environment.NewLine & _
"If you run out of money, you lose." & Environment.NewLine & _
Environment.NewLine & _
"If the banker runs out, you beat the house" & Environment.NewLine & _
Environment.NewLine & _
"In order to play, you must first put in your bet." & Environment.NewLine & _
Environment.NewLine & _
"This is your guess to which outcome the dice will be: <, >, =" & Environment.NewLine & _
Environment.NewLine & _
"Next you must put in an ante. The amount you are gambling" & Environment.NewLine & _
Environment.NewLine & _
"Depending on the outcome, you will lose or win this amount" & Environment.NewLine & _
"(Or 5x the amount if you bet 7 and won)" & Environment.NewLine & _
Environment.NewLine & _
"Next move is to roll the die by clicking the roll button." & Environment.NewLine & _
Environment.NewLine & _
"The rest is self self explanatory!" & Environment.NewLine & _
Environment.NewLine & _
Environment.NewLine & _
"Enjoy the game!")
End Sub
End Class
Since I don't know how you are suppose to send one user your source + all required files (In this case, just two images) I am also uploading the .zip with the build version.
Last edited by Hack; Nov 3rd, 2011 at 05:45 AM.
Reason: Removed Attachment
-
Nov 3rd, 2011, 05:51 AM
#2
Re: Game: Under & Over 7
Thank you for your CodeBank submission.
Per this CodeBank policy, which is clearly posted at the top of each CodeBank forum section, I have removed your attachment as it contained nothing but a single, compiled, file.
We welcome and appreciate all entries into our Codebank and require that source code only be included with anything attached.
Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|