I'm making a Texas Hold Em' game and I just started rewriting it, and I ran into a problem trying to get a random string value. My string arrayCard()
is 2 of spades to Ace of Diamonds and I don't know what random function I have to write because I only know how to get a random integer value = Math.Floor(Random () * 51)
.
CODE:
Public Class Form1
Dim arrayCard() As String = {"2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "11S", "12S", "13S", "14S", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "10C", "11C", "12C", "13C", "14C", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "11H", "12H", "13H", "14H", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "11D", "12D", "13D", "14D"}
'*_CARD & SUIT RANDOM_*
Dim card As Integer = Equals(Rnd() * arrayCard.Length)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cmdBestHand.Visible = False
cmdBestHandPvP.Visible = False
cmdHit.Visible = False
cmdHitX.Visible = False
cmdWin.Visible = False
picHit1.Visible = False
picHit2.Visible = False
'Randomize()
End Sub
Private Function callCard()
Do While arrayCard.Length > 0
arrayCard(card) = Math.Floor(Rnd() * 51)
ReDim Preserve arrayCard(card)
Loop
Return "-1" 'error = deck empty
End Function
'while my arrayCard is greater then 0
'put random card and suit
'call the card + suit
'after it calls the card and suit, save that card, put it as used, and delete the card from the array
're dim the suit and save the array as 51 cards now
'repeat till the array = -1 then say ERROR out or cards
'eventually Re-Loop it To be Like 2 arrays so When it equals -1 To back To 52 For a full deck
'DO IN FUNCTION so i can call the card in the picturebox and display the RIGHT CARD
Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
Application.Exit()
End Sub
Private Sub cmdNewGame_Click(sender As Object, e As EventArgs) Handles cmdNewGame.Click
'arrayCard(card) = random string value
arrayCard(card) = arrayCard(value)
picUser.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
picUserX.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
picStart.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
picStartX.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
picStartX2.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
cmdBestHand.Visible = True
cmdBestHandPvP.Visible = False
cmdHit.Visible = True
cmdHitX.Visible = False
cmdWin.Visible = False
txtP1.Text = arrayCard(card)
'txtP1.Text = "The Bridge has been made. Click Best Hand to see your fate."
txtP2.Text = "Press Player VS Player to add a 2nd Player."
End Sub
Private Sub cmdPvP_Click(sender As Object, e As EventArgs) Handles cmdPvP.Click
txtPvP.Text = "Player 2"
txtP2.Text = "The Bridge has been made. Click Best Hand to see your fate."
picDealer.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
picDealerX.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
cmdBestHandPvP.Visible = True
End Sub
Private Sub cmdBestHand_Click(sender As Object, e As EventArgs) Handles cmdBestHand.Click
End Sub
Private Sub cmdBestHandPvP_Click(sender As Object, e As EventArgs) Handles cmdBestHandPvP.Click
End Sub
Private Sub cmdHit_Click(sender As Object, e As EventArgs) Handles cmdHit.Click
picHit1.Visible = True
picHit1.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
cmdHitX.Visible = True
txtP1.Text = "Have you checked your hand lately? Click Best Hand to see your fate."
txtP2.Text = "Have you checked your hand lately? Click Best Hand to see your fate."
End Sub
Private Sub cmdHitX_Click(sender As Object, e As EventArgs) Handles cmdHitX.Click
picHit2.Visible = True
picHit2.Image = My.Resources.ResourceManager.GetObject("_" & arrayCard(card))
cmdWin.Visible = True
txtP1.Text = "Is your hand strong? Click Best Hand to see your fate."
txtP2.Text = "Is your hand strong? Click Best Hand to see your fate."
End Sub
Private Sub cmdWin_Click(sender As Object, e As EventArgs) Handles cmdWin.Click
'determines who has better hand and winner
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire