Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.74 KB | None | 0 0
  1. Public Structure Card
  2. Dim Name As String
  3. Dim Suit As String
  4. Dim Number As Integer
  5. Dim Available As Boolean
  6. Dim filePath As String
  7. End Structure
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Public Class GameForm
  14.  
  15. Dim Deck(51) As Card
  16. Dim players(3) As Player
  17.  
  18.  
  19. Dim pot As Integer = 0
  20. Dim handNum As Integer = 1
  21.  
  22. Dim playerTurn As Integer = 1
  23. Dim currentTurn As Integer
  24. Dim moneyEntered(3, 3) As Integer
  25. Dim potTotal As Integer
  26. Dim flopPlayed As Boolean = False
  27. Dim turnPlayed As Boolean = False
  28. Dim riverPlayed As Boolean = False
  29. Dim progression As Integer
  30. Dim isChecked = False
  31. Dim foldCount As Integer = 0
  32. Dim checkCount As Integer = 0
  33. Dim lastBetter As Integer
  34. Dim handOverBool As Boolean = False
  35.  
  36. Dim conn As New System.Data.Odbc.OdbcConnection("DRIVER={MySQL ODBC 5.3 ANSI Driver};SERVER=localhost;PORT=3306;DATABASE=handdatabase;USER=root;PASSWORD=root;OPTION=3;")
  37. Dim rs As Odbc.OdbcDataReader
  38.  
  39.  
  40. Private Sub GameForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  41.  
  42.  
  43.  
  44. For i = 0 To 3
  45. players(i) = New Player
  46. Next
  47.  
  48. WelcomeForm.Show()
  49. Dim humanHand(6) As Card
  50. Dim AI1Hand(6) As Card
  51. Dim AI2Hand(6) As Card
  52. Dim AI3Hand(6) As Card
  53.  
  54. 'players(0).Name = "Mason"
  55. players(1).Name = "AI1"
  56. players(2).Name = "AI2"
  57. players(3).Name = "AI3"
  58.  
  59. players(0).hand = humanHand
  60. players(1).hand = AI1Hand
  61. players(2).hand = AI2Hand
  62. players(3).hand = AI3Hand
  63.  
  64.  
  65.  
  66. For i = 0 To 3
  67. players(i).Money = 100
  68. Next
  69.  
  70. blankCards()
  71.  
  72. Me.BackgroundImage = Image.FromFile("table.png")
  73.  
  74. PotN.Text = "Pot: " & pot
  75.  
  76. refreshMoney()
  77.  
  78.  
  79. initializeDeck()
  80.  
  81.  
  82. End Sub
  83.  
  84. Sub refreshMoney()
  85. If players(0).Money < 0 Then
  86. humanMoney.Text = "0"
  87. Else
  88. humanMoney.Text = "Money: " & players(0).Money
  89. End If
  90.  
  91. If players(1).Money < 0 Then
  92. AI1Money.Text = "0"
  93. Else
  94. AI1Money.Text = "Money: " & players(1).Money
  95. End If
  96.  
  97. If players(2).Money < 0 Then
  98. AI2Money.Text = "0"
  99. Else
  100. AI2Money.Text = "Money: " & players(2).Money
  101. End If
  102.  
  103. If players(3).Money < 0 Then
  104. AI3Money.Text = "0"
  105. Else
  106. AI3Money.Text = "Money: " & players(3).Money
  107. End If
  108.  
  109. humanMoney.Refresh()
  110. AI1Money.Refresh()
  111. AI2Money.Refresh()
  112. AI3Money.Refresh()
  113. End Sub
  114.  
  115. Private Sub GameForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown
  116. HandTableForm.Hide()
  117. Me.Hide()
  118.  
  119.  
  120. WelcomeForm.Show()
  121. End Sub
  122. Sub blankCards()
  123. Com1.Image = Image.FromFile("blank_card.png")
  124. Com2.Image = Image.FromFile("blank_card.png")
  125. Com3.Image = Image.FromFile("blank_card.png")
  126. Com4.Image = Image.FromFile("blank_card.png")
  127. Com5.Image = Image.FromFile("blank_card.png")
  128.  
  129.  
  130. HoleCard1.Image = Image.FromFile("blank_card.png")
  131. HoleCard2.Image = Image.FromFile("blank_card.png")
  132. AI1Card1.Image = Image.FromFile("blank_card.png")
  133. AI1Card2.Image = Image.FromFile("blank_card.png")
  134.  
  135.  
  136. AI2Card1.Image = Image.FromFile("blank_card.png")
  137. AI2Card2.Image = Image.FromFile("blank_card.png")
  138. AI3Card1.Image = Image.FromFile("blank_card.png")
  139. AI3Card2.Image = Image.FromFile("blank_card.png")
  140. End Sub
  141.  
  142. Sub Deal()
  143.  
  144. handOverBool = False
  145. DealButton.Enabled = False
  146. foldCount = 0
  147. checkCount = 0
  148. potTotal = 0
  149. currentTurn = playerTurn
  150. blankCards()
  151.  
  152. flopPlayed = False
  153. turnPlayed = False
  154. riverPlayed = False
  155. progression = 0
  156.  
  157. For i = 0 To 3
  158. For j = 0 To 3
  159. moneyEntered(i, j) = 0
  160. Next
  161. players(i).hasFolded = False
  162. Next
  163.  
  164. resetActions()
  165. HandName.Text = ""
  166.  
  167.  
  168. If players(0).Money = 0 Then
  169. For i = 0 To 3
  170. players(i).Money = 100
  171. refreshMoney()
  172. Next
  173. End If
  174.  
  175. For i = 0 To 3
  176. players(i).currentHand = ""
  177. For j = 0 To 6
  178. players(i).hand(j).Name = ""
  179. players(i).hand(j).Number = 0
  180. players(i).hand(j).Suit = ""
  181. Next
  182. Next
  183. For i = 0 To 51
  184. Deck(i).Available = True
  185. Next
  186.  
  187.  
  188.  
  189. Randomize()
  190.  
  191. Dim randomNums(7) As Integer
  192. For i = 0 To 7
  193. randomNums(i) = CInt(Math.Floor((51) * Rnd()))
  194. If Deck(randomNums(i)).Available = False Then
  195. Do
  196. randomNums(i) = CInt(Math.Floor((51) * Rnd()))
  197. Loop Until Deck(randomNums(i)).Available = True
  198. End If
  199. Deck(randomNums(i)).Available = False
  200. Next
  201.  
  202. Dim count = 0
  203. For i = 0 To 7
  204. players(count).hand(i Mod 2) = Deck(randomNums(i))
  205. If i Mod 2 = 1 And i <> 0 Then
  206. count += 1
  207. End If
  208. Next
  209.  
  210. HoleCard1.Image = Image.FromFile(players(0).hand(0).filePath)
  211. HoleCard1.Refresh()
  212. HoleCard2.Image = Image.FromFile(players(0).hand(1).filePath)
  213. HoleCard2.Refresh()
  214. 'AI1Card1.Image = Image.FromFile(players(1).hand(0).filePath)
  215. 'AI1Card2.Image = Image.FromFile(players(1).hand(1).filePath)
  216. 'AI2Card1.Image = Image.FromFile(players(2).hand(0).filePath)
  217. 'AI2Card2.Image = Image.FromFile(players(2).hand(1).filePath)
  218. 'AI3Card1.Image = Image.FromFile(players(3).hand(0).filePath)
  219. 'AI3Card2.Image = Image.FromFile(players(3).hand(1).filePath)
  220. Refresh()
  221.  
  222. 'Try
  223.  
  224. 'Catch
  225. 'End Try
  226.  
  227. Dim roundCount As Integer = 0
  228. BettingRound(roundCount)
  229.  
  230. End Sub
  231.  
  232. Sub resetActions()
  233. AI1Action.Text = ""
  234. AI2Action.Text = ""
  235. AI3Action.Text = ""
  236. HumanAction.Text = ""
  237. End Sub
  238.  
  239.  
  240.  
  241. Sub Flop()
  242. resetActions()
  243. checkCount = 0
  244. For i = 0 To 3
  245. potTotal += moneyEntered(i, 0)
  246. Next
  247. PotN.Text = "Pot: " & potTotal
  248. PotN.Refresh()
  249.  
  250. currentTurn = playerTurn
  251. Dim randomNums(2) As Integer
  252.  
  253. isChecked = True
  254. For i = 0 To 3
  255. If players(i).Money = 0 Then
  256. players(i).hasFolded = True
  257. checkFoldedCards()
  258. End If
  259. Next
  260.  
  261. For i = 0 To 2
  262. randomNums(i) = CInt(Math.Floor((51) * Rnd()))
  263. If Deck(randomNums(i)).Available = False Then
  264. Do
  265. randomNums(i) = CInt(Math.Floor((51) * Rnd()))
  266. Loop Until Deck(randomNums(i)).Available = True
  267. End If
  268. Deck(randomNums(i)).Available = False
  269.  
  270. For j = 0 To 3
  271. players(j).hand(i + 2) = Deck(randomNums(i))
  272. Next
  273.  
  274.  
  275. Next
  276.  
  277.  
  278.  
  279.  
  280. Com1.Image = Image.FromFile(Deck(randomNums(0)).filePath)
  281. Com2.Image = Image.FromFile(Deck(randomNums(1)).filePath)
  282. Com3.Image = Image.FromFile(Deck(randomNums(2)).filePath)
  283. Com1.Refresh()
  284. Com2.Refresh()
  285. Com3.Refresh()
  286.  
  287.  
  288. For i = 0 To 3
  289. players(i).currentHand = CheckHand(players(i).hand)
  290. Next
  291.  
  292. HandName.Text = "Hand: " & players(0).currentHand
  293. HandName.Refresh()
  294.  
  295. flopPlayed = True
  296.  
  297. Dim roundCount As Integer = 0
  298. BettingRound(roundCount)
  299. End Sub
  300.  
  301. Sub Turn()
  302. resetActions()
  303. checkCount = 0
  304. isChecked = True
  305. For i = 0 To 3
  306. potTotal += moneyEntered(i, 1)
  307. Next
  308. PotN.Text = "Pot: " & potTotal
  309. PotN.Refresh()
  310. currentTurn = playerTurn
  311.  
  312. For i = 0 To 3
  313. If players(i).Money = 0 Then
  314. players(i).hasFolded = True
  315. checkFoldedCards()
  316. End If
  317. Next
  318.  
  319. Dim randomNum As Integer = CInt(Math.Floor((51) * Rnd()))
  320. If Deck(randomNum).Available = False Then
  321. Do
  322. Randomize()
  323. randomNum = CInt(Math.Floor((51) * Rnd()))
  324. Loop Until Deck(randomNum).Available = True
  325. End If
  326.  
  327. Deck(randomNum).Available = False
  328.  
  329. For i = 0 To 3
  330. players(i).hand(5) = Deck(randomNum)
  331. Next
  332.  
  333. Com4.Image = Image.FromFile(Deck(randomNum).filePath)
  334. Com4.Refresh()
  335.  
  336. For i = 0 To 3
  337. players(i).currentHand = CheckHand(players(i).hand)
  338. Next
  339.  
  340.  
  341.  
  342. HandName.Text = "Hand: " & players(0).currentHand
  343. HandName.Refresh()
  344.  
  345. turnPlayed = True
  346.  
  347. Dim roundCount As Integer = 0
  348. BettingRound(roundCount)
  349. End Sub
  350.  
  351.  
  352. Sub River()
  353. currentTurn = playerTurn
  354. resetActions()
  355. checkCount = 0
  356. isChecked = True
  357. For i = 0 To 3
  358. potTotal += moneyEntered(i, 2)
  359. Next
  360. PotN.Text = "Pot: " & potTotal
  361. PotN.Refresh()
  362. For i = 0 To 3
  363. If players(i).Money = 0 Then
  364. players(i).hasFolded = True
  365. checkFoldedCards()
  366. End If
  367. Next
  368. Dim randomNum As Integer = CInt(Math.Floor((51) * Rnd()))
  369. If Deck(randomNum).Available = False Then
  370. Do
  371. Randomize()
  372. randomNum = CInt(Math.Floor((51) * Rnd()))
  373. Loop Until Deck(randomNum).Available = True
  374. End If
  375.  
  376. Deck(randomNum).Available = False
  377.  
  378.  
  379. For i = 0 To 3
  380. players(i).hand(6) = Deck(randomNum)
  381. Next
  382.  
  383. Com5.Image = Image.FromFile(Deck(randomNum).filePath)
  384. Com5.Refresh()
  385.  
  386. 'For i = 0 To 3
  387. ' For j = 0 To 6
  388. ' MsgBox(players(i).hand(j).Name)
  389. ' Next
  390. 'Next
  391.  
  392. For i = 0 To 3
  393. players(i).currentHand = CheckHand(players(i).hand)
  394. Next
  395.  
  396. HandName.Text = "Hand: " & players(0).currentHand
  397. HandName.Refresh()
  398.  
  399. riverPlayed = True
  400.  
  401. Dim roundCount As Integer = 0
  402. BettingRound(roundCount)
  403.  
  404.  
  405. End Sub
  406.  
  407. Sub handOverSub()
  408. handOverBool = True
  409. 'MsgBox("handOver")
  410.  
  411. For i = 0 To 3
  412. potTotal += moneyEntered(i, progression)
  413. Next
  414. PotN.Text = "Pot: " & potTotal
  415. PotN.Refresh()
  416.  
  417. If players(1).hasFolded = False Then
  418. AI1Card1.Image = Image.FromFile(players(1).hand(0).filePath)
  419. AI1Card2.Image = Image.FromFile(players(1).hand(1).filePath)
  420. End If
  421.  
  422. If players(2).hasFolded = False Then
  423.  
  424. AI2Card1.Image = Image.FromFile(players(2).hand(0).filePath)
  425. AI2Card2.Image = Image.FromFile(players(2).hand(1).filePath)
  426. End If
  427.  
  428. If players(3).hasFolded = False Then
  429.  
  430. AI3Card1.Image = Image.FromFile(players(3).hand(0).filePath)
  431. AI3Card2.Image = Image.FromFile(players(3).hand(1).filePath)
  432. End If
  433.  
  434. Dim handArray(3) As String
  435. Dim handArrayNum(3) As Integer
  436. Dim handArrayNumSorted(3) As Integer
  437.  
  438. For i = 0 To 3
  439. If players(i).hasFolded = False Then
  440. handArray(i) = players(i).currentHand
  441. End If
  442. Next
  443.  
  444. For i = 0 To 3
  445. Select Case handArray(i)
  446. Case ""
  447. handArrayNum(i) = 0
  448. Case "Pair"
  449. handArrayNum(i) = 1
  450. Case "Two Pair"
  451. handArrayNum(i) = 2
  452. Case "Three Of A Kind"
  453. handArrayNum(i) = 3
  454. Case "Straight"
  455. handArrayNum(i) = 4
  456. Case "Flush"
  457. handArrayNum(i) = 5
  458. Case "Full House"
  459. handArrayNum(i) = 6
  460. Case "Four Of A Kind"
  461. handArrayNum(i) = 6
  462. End Select
  463. Next
  464.  
  465. For i = 0 To 3
  466. handArrayNumSorted(i) = handArrayNum(i)
  467. Next
  468.  
  469. For i = 0 To 3
  470. For j = 0 To 2
  471. Dim temp As Integer = handArrayNumSorted(j)
  472. If handArrayNumSorted(j) < handArrayNumSorted(j + 1) Then
  473. handArrayNumSorted(j) = handArrayNumSorted(j + 1)
  474. handArrayNumSorted(j + 1) = temp
  475. End If
  476. Next
  477. Next
  478.  
  479. Dim winningHand As Integer = handArrayNumSorted(0)
  480. Dim numOfWinners As Integer = 0
  481.  
  482. For i = 0 To 3
  483. If handArrayNum(i) = winningHand And players(i).hasFolded = False Then
  484. If i = 0 Then
  485. MessageBox.Show("You have won the hand!", "Congratulations!")
  486. Else
  487. MessageBox.Show("Player " & i & " has won the hand!", "Hand Over")
  488. End If
  489. numOfWinners += 1
  490. End If
  491. Next
  492.  
  493. For i = 0 To 3
  494. If handArrayNum(i) = winningHand And players(i).hasFolded = False Then
  495. players(i).Money += Math.Floor(potTotal / numOfWinners)
  496. End If
  497. Next
  498. refreshMoney()
  499.  
  500. Dim sqlString As New Odbc.OdbcCommand("SELECT HandNumber FROM handtable ORDER BY HandNumber DESC LIMIT 1", conn)
  501. conn.Open()
  502. rs = sqlString.ExecuteReader()
  503. Do While rs.Read()
  504. handNum = rs.Item("HandNumber") + 1
  505.  
  506. Loop
  507. 'MsgBox(handNum)
  508. conn.Close()
  509.  
  510. Dim humanMoneyEntered As Integer = 0
  511. Dim handWon As Boolean
  512. Dim moneyWon As Integer
  513. Dim percentage As Double
  514.  
  515. For i = 0 To 3
  516. humanMoneyEntered += moneyEntered(0, i)
  517. Next
  518. If handArrayNum(0) = winningHand Then
  519. handWon = True
  520. moneyWon = Math.Floor(potTotal / numOfWinners)
  521. percentage = (moneyWon / humanMoneyEntered) * 100
  522. Else
  523. moneyWon = 0
  524. End If
  525.  
  526. Dim cardString As String
  527. For i = 0 To 6
  528. If players(0).hand(i).Number < 11 Then
  529. cardString = cardString & UCase(Mid(players(0).hand(i).Number.ToString, 1, 1)) & LCase(Mid(players(0).hand(i).Suit, 1, 1))
  530. Else
  531. Select Case players(0).hand(i).Number
  532. Case 11
  533. cardString = cardString & "J" & LCase(Mid(players(0).hand(i).Suit, 1, 1))
  534. Case 12
  535. cardString = cardString & "Q" & LCase(Mid(players(0).hand(i).Suit, 1, 1))
  536. Case 13
  537. cardString = cardString & "K" & LCase(Mid(players(0).hand(i).Suit, 1, 1))
  538. End Select
  539. End If
  540.  
  541. Next
  542. 'MsgBox(cardString)
  543. Dim sqlString2 As New Odbc.OdbcCommand("INSERT INTO HandTable VALUES('" & handNum & "','" & cardString & "','" & players(0).currentHand & "', '" & handWon & "', '" & humanMoneyEntered & "', '" & potTotal & "', '" & moneyWon & "', '" & percentage & "')", conn)
  544. conn.Open()
  545. rs = sqlString2.ExecuteReader()
  546. conn.Close()
  547.  
  548. blankCards()
  549. HandName.Text = ""
  550. HandName.Refresh()
  551. PotN.Text = ""
  552. PotN.Refresh()
  553.  
  554. playerTurn += 1
  555. If playerTurn = 4 Then
  556. playerTurn = 0
  557. End If
  558.  
  559. For i = 0 To 3
  560. actionChanger(i, "")
  561. Next
  562.  
  563. DealButton.Enabled = True
  564.  
  565. End Sub
  566.  
  567.  
  568. Sub checkFoldedCards()
  569. If players(0).hasFolded = True Then
  570. HoleCard1.Image = Image.FromFile("folded_card.png")
  571. HoleCard2.Image = Image.FromFile("folded_card.png")
  572. HoleCard1.Refresh()
  573. HoleCard2.Refresh()
  574. End If
  575. If players(1).hasFolded = True Then
  576. AI1Card1.Image = Image.FromFile("folded_card.png")
  577. AI1Card2.Image = Image.FromFile("folded_card.png")
  578. AI1Card1.Refresh()
  579. AI1Card2.Refresh()
  580. End If
  581. If players(2).hasFolded = True Then
  582. AI2Card1.Image = Image.FromFile("folded_card.png")
  583. AI2Card2.Image = Image.FromFile("folded_card.png")
  584. AI2Card1.Refresh()
  585. AI2Card2.Refresh()
  586. End If
  587. If players(3).hasFolded = True Then
  588. AI3Card1.Image = Image.FromFile("folded_card.png")
  589. AI3Card2.Image = Image.FromFile("folded_card.png")
  590. AI3Card1.Refresh()
  591. AI3Card2.Refresh()
  592. End If
  593.  
  594. End Sub
  595.  
  596. Function CheckHand(ByVal hand() As Card)
  597.  
  598. Dim handName As String
  599. Dim cardNos(12) As String
  600. Dim cardSuits(12) As String
  601. For i = 0 To 6
  602. cardNos(i) = hand(i).Number.ToString
  603. Next
  604.  
  605. For i = 0 To 6
  606. If hand(i).Suit <> "" Then
  607. cardSuits(i) = hand(i).Suit
  608. End If
  609. Next
  610. handName = checkRep(cardNos)
  611. handName = checkStraight(cardNos, cardSuits, handName)
  612. handName = checkFlush(cardSuits, handName)
  613.  
  614. CheckHand = handName
  615. 'MsgBox(handName)
  616.  
  617.  
  618. End Function
  619.  
  620. Function checkRep(ByVal cardNos() As String)
  621. Dim count As Integer = 0
  622. Dim uniqueCards As Integer = 7
  623.  
  624. For i = 0 To 6
  625. For j = 0 To 6
  626. If cardNos(i) = cardNos(j) And cardNos(i) <> "0" Then
  627. If i <> j Then
  628. count += 1
  629. End If
  630. End If
  631. Next
  632. Next
  633.  
  634. For i = 0 To 6
  635. For j = 0 To 6
  636. If cardNos(i) = cardNos(j) And i <> j And cardNos(i) <> "0" Then
  637. 'MsgBox(cardNos(0) & cardNos(1) & cardNos(2) & cardNos(3) & cardNos(4) & cardNos(5) & cardNos(6))
  638. 'System.Threading.Thread.Sleep(2000)
  639. uniqueCards -= 1
  640. For z = j To 6
  641. cardNos(z) = cardNos(z + 1)
  642. Next
  643. End If
  644. Next
  645. Next
  646.  
  647. 'MsgBox(count & " " & uniqueCards)
  648. If count = 2 Then
  649. checkRep = "Pair"
  650. ElseIf count = 4 Then
  651. checkRep = "Two Pair"
  652. ElseIf count = 6 And uniqueCards = 5 Then
  653. checkRep = "Three Of A Kind"
  654. ElseIf count = 12 And uniqueCards = 3 Then
  655. checkRep = "Three Of A Kind"
  656. ElseIf count = 6 And uniqueCards = 3 Then
  657. checkRep = "Three Of A Kind"
  658. ElseIf count = 8 And uniqueCards = -2 Then
  659. checkRep = "Full House"
  660. ElseIf count = 6 And uniqueCards = -2 Then
  661. checkRep = "Two Pair"
  662. ElseIf count = 6 And uniqueCards = 4 Then
  663. checkRep = "Two Pair"
  664. ElseIf count = 8 And uniqueCards = 4 Then
  665. checkRep = "Full House"
  666. ElseIf count = 0 Then
  667. checkRep = ""
  668. ElseIf count = 12 Then
  669. checkRep = "Four Of A Kind"
  670. ElseIf count = 14 And uniqueCards = 3 Then
  671. checkRep = "Four Of A Kind"
  672. ElseIf ((count = 18 And uniqueCards = 3) Or (count = 18 And uniqueCards = 2)) Then
  673. checkRep = "Four Of A Kind"
  674. End If
  675. End Function
  676.  
  677. Function checkStraight(ByVal cardNos() As String, ByVal cardSuits() As String, ByVal handName As String)
  678. Dim straightCount As Integer = 0
  679. Dim isStraight As Boolean = False
  680.  
  681. Dim cards(12) As Integer
  682. For i = 0 To 7
  683. cards(i) = CInt(cardNos(i))
  684. Next
  685. 'MsgBox(cards(0) & ", " & cards(1) & ", " & cards(2) & ", " & cards(3) & ", " & cards(4) & ", " & cards(5) & ", " & cards(6) & ", " & cards(7))
  686.  
  687. For i = 1 To 7
  688. For j = 0 To 7
  689. If cards(j) > cards(j + 1) Then
  690. cards(12) = cards(j)
  691. cards(j) = cards(j + 1)
  692. cards(j + 1) = cards(12)
  693. End If
  694. Next
  695. Next
  696. 'MsgBox(cards(0) & ", " & cards(1) & ", " & cards(2) & ", " & cards(3) & ", " & cards(4) & ", " & cards(5) & ", " & cards(6) & ", " & cards(7))
  697.  
  698. Dim NumOfZeroes As Integer = 0
  699. For i = 0 To 11
  700. If cards(i) = 0 Then
  701. NumOfZeroes += 1
  702. ElseIf cards(i) <> 0 Then
  703. Exit For
  704. End If
  705. Next
  706.  
  707. For i = 0 To 12 - NumOfZeroes
  708. cards(i) = cards(i + NumOfZeroes)
  709. Next
  710.  
  711. For j = 0 To 2
  712. straightCount = 0
  713. For z = 0 To 4
  714. If cards(j + z) = cards(j) + z Then
  715. straightCount += 1
  716. End If
  717. If cards(j) = 1 And cards(4 + z) = 13 And cards(3 + z) = 12 And cards(2 + z) = 11 And cards(1 + z) = 10 Then
  718. isStraight = True
  719. End If
  720. Next
  721. If straightCount = 5 Then
  722. isStraight = True
  723. End If
  724. Next
  725.  
  726.  
  727. If isStraight = True And (handName = "" Or handName = "Pair" Or handName = "Two Pair" Or handName = "Three Of A Kind") Then
  728. checkStraight = "Straight"
  729. Else
  730. checkStraight = handName
  731. End If
  732. End Function
  733.  
  734. Function checkFlush(ByVal cardSuits() As String, ByVal handName As String)
  735. Dim spadeCount As Integer = 0
  736. Dim clubCount As Integer = 0
  737. Dim diamondCount As Integer = 0
  738. Dim heartCount As Integer = 0
  739.  
  740. For i = 0 To 6
  741. Select Case cardSuits(i)
  742. Case "Spades"
  743. spadeCount += 1
  744. Case "Clubs"
  745. clubCount += 1
  746. Case "Diamonds"
  747. diamondCount += 1
  748. Case "Hearts"
  749. heartCount += 1
  750. End Select
  751. Next
  752.  
  753. 'MsgBox("Spades: " & spadeCount & " | Clubs: " & clubCount & " | Diamonds: " & diamondCount & " | Hearts: " & heartCount)
  754.  
  755. Dim isFlush As Boolean = False
  756. If (spadeCount = 5 Or clubCount = 5 Or diamondCount = 5 Or heartCount = 5) Then
  757. isFlush = True
  758. End If
  759.  
  760. If isFlush = True And (handName <> "Full House" Or handName <> "Four Of A Kind") Then
  761. checkFlush = "Flush"
  762. Else
  763. checkFlush = handName
  764. End If
  765.  
  766. End Function
  767.  
  768.  
  769. Sub initializeDeck()
  770. FileOpen(1, "Cardlist.txt", OpenMode.Input)
  771. Dim CardNumber As Integer = 0
  772. Do While Not EOF(1)
  773. Deck(CardNumber).filePath = LineInput(1)
  774. Deck(CardNumber).Available = 1
  775. CardNumber += 1
  776. Loop
  777.  
  778. FileClose(1)
  779.  
  780. CardNumber = 0
  781. For i = 0 To 51
  782. If i Mod 4 = 0 Then
  783. CardNumber += 1
  784. End If
  785. Deck(i).Number = CardNumber
  786. 'MsgBox(i & " " & i Mod 4 & " " & count & " " & Deck(i).Number)
  787.  
  788. Select Case i Mod 4
  789. Case 0
  790. Deck(i).Suit = "Clubs"
  791. Case 1
  792. Deck(i).Suit = "Diamonds"
  793. Case 2
  794. Deck(i).Suit = "Hearts"
  795. Case 3
  796. Deck(i).Suit = "Spades"
  797. End Select
  798.  
  799. Deck(i).Name = Deck(i).Number & " of " & Deck(i).Suit
  800.  
  801. If Deck(i).Number = 1 Then
  802. Deck(i).Name = "Ace of " & Deck(i).Suit
  803. ElseIf Deck(i).Number = 11 Then
  804. Deck(i).Name = "Jack of " & Deck(i).Suit
  805. ElseIf Deck(i).Number = 12 Then
  806. Deck(i).Name = "Queen of " & Deck(i).Suit
  807. ElseIf Deck(i).Number = 13 Then
  808. Deck(i).Name = "King of " & Deck(i).Suit
  809. End If
  810. 'MsgBox(Deck(i).Name & " " & Deck(i).Available)
  811. Next
  812.  
  813.  
  814. End Sub
  815.  
  816.  
  817.  
  818. Sub BettingRound(ByVal count As Integer)
  819.  
  820.  
  821. If players(0).hasFolded = False Then
  822. lastBetter = 0
  823. End If
  824.  
  825. If flopPlayed = False Then
  826. progression = 0
  827. ElseIf flopPlayed = True And turnPlayed = False Then
  828. progression = 1
  829. ElseIf turnPlayed = True And riverPlayed = False Then
  830. progression = 2
  831. ElseIf riverPlayed = True Then
  832. progression = 3
  833. End If
  834.  
  835.  
  836. If moneyEntered((playerTurn + 1) Mod 4, progression) = 0 And progression = 0 Then
  837.  
  838. actionChanger((playerTurn + 1) Mod 4, 5)
  839. actionChanger((playerTurn + 2) Mod 4, 10)
  840. moneyEntered((playerTurn + 1) Mod 4, progression) = 5
  841. moneyEntered((playerTurn + 2) Mod 4, progression) = 10
  842.  
  843. players((playerTurn + 1) Mod 4).Money -= 5
  844. players((playerTurn + 2) Mod 4).Money -= 10
  845.  
  846. refreshMoney()
  847.  
  848. currentTurn = (currentTurn + 3) Mod 4
  849.  
  850. End If
  851.  
  852. If foldCount = 3 Then
  853. handOverSub()
  854. Exit Sub
  855. End If
  856.  
  857. If currentTurn = 0 And players(0).hasFolded = False Then
  858. humanBet(progression, count)
  859. Else
  860.  
  861. Dim count2 As Integer = 0
  862. 'MsgBox("t" & temp)
  863. While currentTurn <> 0 And foldCount <> 3
  864. If currentTurn > 3 Then
  865. currentTurn = 0
  866. Exit While
  867. End If
  868.  
  869. 'MsgBox(currentTurn & " " & i)
  870. If players(currentTurn).hasFolded = True Then
  871. If players((currentTurn + 1) Mod 4).hasFolded = True Then
  872. currentTurn += 2
  873. Else
  874. currentTurn += 1
  875. End If
  876.  
  877. End If
  878.  
  879. If currentTurn > 3 Then
  880. currentTurn = currentTurn Mod 4
  881. Exit While
  882. End If
  883.  
  884. If currentTurn = 4 Then
  885. currentTurn = 0
  886. Exit While
  887. End If
  888.  
  889. If checkCount = 4 - foldCount Then
  890. Select Case progression
  891. Case 0
  892. Flop()
  893. Case 1
  894. Turn()
  895. Case 2
  896. River()
  897. Case 3
  898. handOverSub()
  899. End Select
  900.  
  901. Exit Sub
  902. End If
  903.  
  904.  
  905.  
  906. AIBet(players(currentTurn), currentTurn, progression, count)
  907.  
  908.  
  909.  
  910. If currentTurn = 0 Then
  911. Exit Sub
  912. End If
  913.  
  914. If handOverBool = True Then
  915. Exit Sub
  916. End If
  917. count += 1
  918. currentTurn += 1
  919.  
  920. If playerTurn = 2 And progression = 0 And currentTurn = 4 Then
  921. Flop()
  922. Exit Sub
  923. End If
  924.  
  925. If currentTurn = 4 Then
  926. currentTurn = 0
  927. Exit While
  928. End If
  929.  
  930.  
  931. If players(currentTurn).hasFolded = True Then
  932. If players((currentTurn + 1) Mod 4).hasFolded = True Then
  933. currentTurn += 2
  934. Else
  935. currentTurn += 1
  936. End If
  937.  
  938. End If
  939.  
  940. If currentTurn > 3 Then
  941. currentTurn = currentTurn Mod 4
  942. Exit While
  943. End If
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950. If moneyEntered(0, progression) = moneyEntered(1, progression) And moneyEntered(1, progression) = moneyEntered(2, progression) And moneyEntered(2, progression) = moneyEntered(3, progression) And isChecked = False And count <> 0 Then
  951. 'MsgBox("Progressing from Betting Round")
  952. Select Case progression
  953. Case 0
  954. Flop()
  955. Case 1
  956. Turn()
  957. Case 2
  958. River()
  959. Case 3
  960. handOverSub()
  961. End Select
  962.  
  963. Exit Sub
  964. End If
  965.  
  966. End While
  967.  
  968. humanBet(progression, count)
  969. End If
  970.  
  971. End Sub
  972.  
  973.  
  974. Sub humanBet(ByVal progression As Integer, ByVal count As Integer)
  975.  
  976. If players(0).hasFolded = True Or players(0).Money = 0 Then
  977. currentTurn = 1
  978. BettingRound(1)
  979. Exit Sub
  980. End If
  981. If players(3).hasFolded = True Then
  982. If players(3).hasFolded = True And players(2).hasFolded = True Then
  983. lastBetter = 1
  984. Else
  985. lastBetter = 2
  986. End If
  987. Else
  988. lastBetter = 3
  989. End If
  990. 'MsgBox(lastBetter)
  991. If moneyEntered(0, progression) = moneyEntered(lastBetter, progression) And isChecked = False And count <> 0 Then
  992.  
  993. Select Case progression
  994. Case 0
  995. Flop()
  996. Case 1
  997. Turn()
  998. Case 2
  999. River()
  1000. Case 3
  1001. handOverSub()
  1002. End Select
  1003. Exit Sub
  1004. End If
  1005.  
  1006. If checkCount = 4 - foldCount Then
  1007. Select Case progression
  1008. Case 0
  1009. Flop()
  1010. Case 1
  1011. Turn()
  1012. Case 2
  1013. River()
  1014. Case 3
  1015. handOverSub()
  1016. End Select
  1017.  
  1018. Exit Sub
  1019. End If
  1020.  
  1021.  
  1022. FoldButton.Enabled = True
  1023. If moneyEntered(0, progression) < moneyEntered(lastBetter, progression) Then
  1024. CallButton.Enabled = True
  1025. BetButton.Enabled = True
  1026. CheckButton.Enabled = False
  1027. isChecked = False
  1028. ElseIf moneyEntered(0, progression) = moneyEntered(lastBetter, progression) Then
  1029. CheckButton.Enabled = True
  1030. CallButton.Enabled = False
  1031. BetButton.Enabled = True
  1032. End If
  1033.  
  1034. End Sub
  1035.  
  1036. Sub AIBet(ByRef player As Player, ByVal currentTurn As Integer, ByVal progression As Integer, ByVal count As Integer)
  1037.  
  1038. FoldButton.Enabled = False
  1039. BetButton.Enabled = False
  1040. CheckButton.Enabled = False
  1041. CallButton.Enabled = False
  1042.  
  1043.  
  1044.  
  1045.  
  1046. lastBetter = currentTurn - 1
  1047. If currentTurn <> 1 Then
  1048. If players(currentTurn - 1).hasFolded = True Then
  1049. If players(currentTurn - 2).hasFolded = True Then
  1050. lastBetter = currentTurn - 3
  1051. ElseIf players(currentTurn - 2).hasFolded = False Then
  1052. lastBetter = currentTurn - 2
  1053. End If
  1054. Else
  1055. lastBetter = currentTurn - 1
  1056. End If
  1057.  
  1058.  
  1059. ElseIf currentTurn = 1 Then
  1060. If players(0).hasFolded = True Then
  1061. If players(3).hasFolded = True Then
  1062. lastBetter = 2
  1063. ElseIf players(3).hasFolded = False Then
  1064. lastBetter = 3
  1065. End If
  1066. Else
  1067. lastBetter = 0
  1068. End If
  1069. End If
  1070. If lastBetter = -1 Then
  1071. lastBetter = 3
  1072. End If
  1073. 'MsgBox(lastBetter)
  1074.  
  1075.  
  1076. 'MsgBox("Current Turn:" & currentTurn & Chr(13) & "Checked: " & isChecked & Chr(13) & "Money Entered: " & moneyEntered(currentTurn, progression) & Chr(13) & "Progression:" & progression & Chr(13) & "Last Better:" & lastBetter)
  1077.  
  1078.  
  1079.  
  1080. If moneyEntered(lastBetter, progression) = moneyEntered(currentTurn, progression) And isChecked = False And count <> 0 Then
  1081.  
  1082. Select Case progression
  1083. Case 0
  1084. Flop()
  1085. Case 1
  1086. Turn()
  1087. Case 2
  1088. River()
  1089. Case 3
  1090. handOverSub()
  1091. End Select
  1092. Exit Sub
  1093. End If
  1094.  
  1095. Threading.Thread.Sleep(1000)
  1096.  
  1097. If progression = 0 And moneyEntered(currentTurn, 0) = 0 And moneyEntered(currentTurn - 1, 0) = 0 Then
  1098. actionChanger(currentTurn, 10)
  1099. moneyEntered(currentTurn, progression) = 10
  1100. player.Money -= 10
  1101.  
  1102. ElseIf progression = 0 Then
  1103. actionChanger(currentTurn, (moneyEntered(currentTurn - 1, progression) - moneyEntered(currentTurn, progression)))
  1104. Dim temp As Integer = moneyEntered(currentTurn, progression)
  1105. moneyEntered(currentTurn, progression) = moneyEntered(currentTurn - 1, progression)
  1106. player.Money -= (moneyEntered(currentTurn, progression) - temp)
  1107. End If
  1108.  
  1109. If progression <> 0 And players(currentTurn).hasFolded = False And players(currentTurn).Money > 0 Then
  1110. player.handStrength = players(currentTurn).getHandStrength(player.currentHand, progression)
  1111.  
  1112.  
  1113.  
  1114. Randomize()
  1115. Dim bluffingInt As Integer = CInt(Math.Floor(4 * Rnd()))
  1116. Dim bluffing As Boolean = False
  1117. ' MsgBox("BI: " & bluffingInt)
  1118. If bluffingInt = 0 Then
  1119. bluffing = True
  1120. End If
  1121. 'MsgBox("CurrentTurn: " & currentTurn & Chr(13) & "Hand Strength: " & player.handStrength & Chr(13) & "BI: " & bluffingInt)
  1122.  
  1123. Select Case player.handStrength
  1124. Case "Very Weak"
  1125. If isChecked = True And bluffing = False Then
  1126. checkCount += 1
  1127. actionChanger(currentTurn, "Check")
  1128. ElseIf isChecked = True And bluffing = True Then
  1129. moneyEntered(currentTurn, progression) += Math.Floor(player.Money / 15)
  1130. actionChanger(currentTurn, Math.Floor(player.Money / 15))
  1131. player.Money -= Math.Floor(player.Money / 15)
  1132. isChecked = False
  1133.  
  1134.  
  1135. ElseIf isChecked = False And bluffing = True And (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression)) <= Math.Floor(player.Money / 15) Then
  1136. actionChanger(currentTurn, (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression)))
  1137. player.Money -= (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1138. moneyEntered(currentTurn, progression) = moneyEntered(lastBetter, progression)
  1139.  
  1140.  
  1141. ElseIf isChecked = False Then
  1142. player.hasFolded = True
  1143. foldCount += 1
  1144. actionChanger(currentTurn, "Fold")
  1145. End If
  1146.  
  1147. Case "Weak"
  1148. If isChecked = True And bluffing = False Then
  1149. checkCount += 1
  1150. actionChanger(currentTurn, "Check")
  1151. ElseIf isChecked = True And bluffing = True Then
  1152. moneyEntered(currentTurn, progression) += Math.Floor(player.Money / 10)
  1153. actionChanger(currentTurn, Math.Floor(player.Money / 10))
  1154. player.Money -= Math.Floor(player.Money / 10)
  1155. isChecked = False
  1156.  
  1157.  
  1158. ElseIf isChecked = False And (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression)) <= Math.Floor(player.Money / 10) Then
  1159. actionChanger(currentTurn, moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1160. player.Money -= (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1161. moneyEntered(currentTurn, progression) = moneyEntered(lastBetter, progression)
  1162.  
  1163. ElseIf isChecked = False Then
  1164. player.hasFolded = True
  1165. foldCount += 1
  1166. actionChanger(currentTurn, "Fold")
  1167. End If
  1168.  
  1169. Case "Average"
  1170. If isChecked = True And bluffing = False Then
  1171. moneyEntered(currentTurn, progression) += 10
  1172. player.Money -= 10
  1173. isChecked = False
  1174. actionChanger(currentTurn, 10)
  1175. ElseIf isChecked = True And bluffing = True Then
  1176. moneyEntered(currentTurn, progression) += Math.Floor(player.Money / 8)
  1177. actionChanger(currentTurn, Math.Floor(player.Money / 8))
  1178. player.Money -= Math.Floor(player.Money / 8)
  1179. isChecked = False
  1180.  
  1181.  
  1182. ElseIf isChecked = False And (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression)) <= Math.Floor(player.Money / 6) Then
  1183. actionChanger(currentTurn, moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1184. player.Money -= (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1185. moneyEntered(currentTurn, progression) = moneyEntered(lastBetter, progression)
  1186.  
  1187. ElseIf isChecked = False Then
  1188. player.hasFolded = True
  1189. foldCount += 1
  1190. actionChanger(currentTurn, "Fold")
  1191. End If
  1192.  
  1193. Case "Strong"
  1194. If isChecked = True Then
  1195. moneyEntered(currentTurn, progression) += Math.Floor(player.Money / 6)
  1196. actionChanger(currentTurn, Math.Floor(player.Money / 6))
  1197. player.Money -= Math.Floor(player.Money / 6)
  1198. isChecked = False
  1199. ElseIf isChecked = False And (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression)) <= Math.Floor(player.Money / 4) Then
  1200. actionChanger(currentTurn, moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1201. player.Money -= (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1202. moneyEntered(currentTurn, progression) = moneyEntered(lastBetter, progression)
  1203.  
  1204. ElseIf isChecked = False Then
  1205. player.hasFolded = True
  1206. foldCount += 1
  1207. actionChanger(currentTurn, "Fold")
  1208. End If
  1209.  
  1210. Case "Very Strong"
  1211. If isChecked = True Then
  1212. actionChanger(currentTurn, Math.Floor(player.Money / 2))
  1213. moneyEntered(currentTurn, progression) += Math.Floor(player.Money / 2)
  1214. player.Money -= Math.Floor(player.Money / 2)
  1215. isChecked = False
  1216.  
  1217. ElseIf isChecked = False Then
  1218. actionChanger(currentTurn, moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1219. player.Money -= (moneyEntered(lastBetter, progression) - moneyEntered(currentTurn, progression))
  1220.  
  1221. moneyEntered(currentTurn, progression) = (moneyEntered(lastBetter, progression))
  1222.  
  1223. End If
  1224. End Select
  1225. refreshMoney()
  1226. checkFoldedCards()
  1227. End If
  1228. If foldCount = 3 Then
  1229. handOverSub()
  1230. Exit Sub
  1231. End If
  1232. refreshMoney()
  1233. If isChecked = False Then
  1234. CheckButton.Enabled = False
  1235. End If
  1236. 'If currentTurn = 1 and progression > 0Then
  1237. ' System.Threading.Thread.Sleep(20000)
  1238. 'End If
  1239.  
  1240. End Sub
  1241.  
  1242. Sub actionChanger(ByVal currentTurnSub As Integer, ByVal action As String)
  1243. Select Case currentTurnSub
  1244. Case 1
  1245. AI1Action.Text = action
  1246. AI1Action.Refresh()
  1247. Case 2
  1248. AI2Action.Text = action
  1249. AI2Action.Refresh()
  1250. Case 3
  1251. AI3Action.Text = action
  1252. AI3Action.Refresh()
  1253. Case 0
  1254. HumanAction.Text = action
  1255. HumanAction.Refresh()
  1256. End Select
  1257. End Sub
  1258.  
  1259.  
  1260.  
  1261. Private Sub CallButton_Click(sender As Object, e As EventArgs) Handles CallButton.Click
  1262.  
  1263. Dim lastBetter As Integer = 0
  1264.  
  1265. 'MsgBox(currentTurn)
  1266. If currentTurn = 0 Then
  1267. Dim temp As Integer = moneyEntered(0, progression)
  1268. If players(3).hasFolded = True Then
  1269. If players(2).hasFolded = True Then
  1270. lastBetter = 1
  1271. Else
  1272. lastBetter = 2
  1273. End If
  1274. Else
  1275. lastBetter = 3
  1276. End If
  1277.  
  1278. 'MsgBox(moneyEntered(lastBetter, progression) & " " & temp & " " & players(0).Money)
  1279. 'MsgBox((moneyEntered(lastBetter, progression) - temp))
  1280. If (moneyEntered(lastBetter, progression) - temp) >= players(0).Money Then
  1281. MsgBox("now")
  1282. moneyEntered(0, progression) = players(0).Money
  1283. actionChanger(0, players(0).Money)
  1284. players(0).Money = 0
  1285. Else
  1286. moneyEntered(0, progression) = moneyEntered(lastBetter, progression)
  1287. actionChanger(0, (moneyEntered(0, progression) - temp))
  1288. players(0).Money -= (moneyEntered(0, progression) - temp)
  1289. End If
  1290.  
  1291.  
  1292. refreshMoney()
  1293. currentTurn = 1
  1294. BettingRound(1)
  1295. End If
  1296.  
  1297. End Sub
  1298.  
  1299. Private Sub DealButton_Click(sender As Object, e As EventArgs) Handles DealButton.Click
  1300. Deal()
  1301. End Sub
  1302.  
  1303. Private Sub CheckButton_Click(sender As Object, e As EventArgs) Handles CheckButton.Click
  1304. currentTurn += 1
  1305. checkCount += 1
  1306. isChecked = True
  1307. actionChanger(0, "Check")
  1308. BettingRound(1)
  1309. End Sub
  1310.  
  1311. Private Sub BetButton_Click(sender As Object, e As EventArgs) Handles BetButton.Click
  1312. If BetAmount.Text <> "" And IsNumeric(BetAmount.Text) = True Then
  1313. If BetAmount.Text > 0 Then
  1314. isChecked = False
  1315. checkCount = 0
  1316. If (players(0).Money - Convert.ToInt32(BetAmount.Text)) >= 0 Then
  1317. actionChanger(0, BetAmount.Text)
  1318. moneyEntered(0, progression) += Convert.ToInt32(BetAmount.Text)
  1319. players(0).Money -= Convert.ToInt32(BetAmount.Text)
  1320. refreshMoney()
  1321.  
  1322. currentTurn += 1
  1323. BettingRound(1)
  1324. End If
  1325.  
  1326. End If
  1327. End If
  1328.  
  1329. End Sub
  1330.  
  1331. Private Sub FoldButton_Click(sender As Object, e As EventArgs) Handles FoldButton.Click
  1332. players(0).hasFolded = True
  1333. checkFoldedCards()
  1334. currentTurn += 1
  1335. foldCount += 1
  1336. actionChanger(0, "Fold")
  1337.  
  1338. BettingRound(1)
  1339. End Sub
  1340.  
  1341. Private Sub HandTableButton_Click(sender As Object, e As EventArgs) Handles HandTableButton.Click
  1342. HandTableForm.Show()
  1343. Dim sqlString3 As New Odbc.OdbcCommand("SELECT * FROM handtable ORDER BY HandNumber ASC", conn)
  1344. conn.Open()
  1345. rs = sqlString3.ExecuteReader()
  1346. Do While rs.Read()
  1347. Dim handWon As String
  1348. If rs.Item("MoneyWon") > 0 Then
  1349. handWon = "Yes"
  1350. Else
  1351. handWon = "No"
  1352. End If
  1353. HandTableForm.HandTableControl.Rows.Add(rs.Item("HandNumber"), rs.Item("Cards"), rs.Item("Hand"), handWon, rs.Item("MoneyEntered"), rs.Item("PotSize"), rs.Item("MoneyWon"), rs.Item("PercentageReturned"))
  1354. Loop
  1355. conn.Close()
  1356.  
  1357.  
  1358. End Sub
  1359. End Class
  1360.  
  1361. Public Class Player
  1362. Public Name As String
  1363. Public Money As Integer
  1364. Public hand() As Card
  1365. Public currentHand As String
  1366. Public handStrength As String
  1367. Public hasFolded As Boolean
  1368.  
  1369. Public Function getHandStrength(ByRef currentHand As String, ByRef progression As Integer)
  1370.  
  1371. Dim factor1 As Integer
  1372. Dim factor2 As Integer
  1373.  
  1374. Select Case progression
  1375. Case 1
  1376. factor1 = 3
  1377. Case 2
  1378. factor1 = 9
  1379. Case 3
  1380. factor1 = 27
  1381. End Select
  1382.  
  1383. Select Case currentHand
  1384. Case ""
  1385. factor2 = 2
  1386. Case "Pair"
  1387. factor2 = 4
  1388. Case "Two Pair"
  1389. factor2 = 8
  1390. Case "Three Of A Kind"
  1391. factor2 = 16
  1392. Case "Straight"
  1393. factor2 = 32
  1394. Case "Flush"
  1395. factor2 = 64
  1396. Case "Full House"
  1397. factor2 = 128
  1398. Case "Four Of A Kind"
  1399. factor2 = 256
  1400. End Select
  1401.  
  1402. Select Case factor1 * factor2
  1403. Case 6
  1404. getHandStrength = "Weak"
  1405. Case 12
  1406. getHandStrength = "Average"
  1407. Case 24
  1408. getHandStrength = "Strong"
  1409. Case 48
  1410. getHandStrength = "Very Strong"
  1411. Case 96
  1412. getHandStrength = "Very Strong"
  1413. Case 192
  1414. getHandStrength = "Very Strong"
  1415. Case 384
  1416. getHandStrength = "Very Strong"
  1417. Case 768
  1418. getHandStrength = "Very Strong"
  1419.  
  1420. Case 18
  1421. getHandStrength = "Very Weak"
  1422. Case 36
  1423. getHandStrength = "Weak"
  1424. Case 72
  1425. getHandStrength = "Strong"
  1426. Case 144
  1427. getHandStrength = "Strong"
  1428. Case 288
  1429. getHandStrength = "Very Strong"
  1430. Case 576
  1431. getHandStrength = "Very Strong"
  1432. Case 1152
  1433. getHandStrength = "Very Strong"
  1434. Case 2304
  1435. getHandStrength = "Very Strong"
  1436.  
  1437. Case 54
  1438. getHandStrength = "Very Weak"
  1439. Case 108
  1440. getHandStrength = "Weak"
  1441. Case 216
  1442. getHandStrength = "Average"
  1443. Case 432
  1444. getHandStrength = "Strong"
  1445. Case 864
  1446. getHandStrength = "Strong"
  1447. Case 1728
  1448. getHandStrength = "Very Strong"
  1449. Case 3456
  1450. getHandStrength = "Very Strong"
  1451. Case 6912
  1452. getHandStrength = "Very Strong"
  1453.  
  1454.  
  1455. End Select
  1456.  
  1457. End Function
  1458. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement