Advertisement
Mi4_Slayer

TestPoker

Sep 13th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 13.83 KB | None | 0 0
  1. Public Class Form1
  2.     Dim pic(4) As PictureBox
  3.     Dim Cartes(51) As Integer
  4.     Dim anti_clone(51) As Boolean
  5.     Dim main(4) As Integer
  6.     Dim ninja(4) As Integer
  7.     Dim Cpt_Cartes As Integer
  8.     Dim Option_Enable As Boolean
  9.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  10.         numCredit.Value = 50
  11.         Creer_Le_Poker()
  12.     End Sub
  13.     Private Sub Creer_Le_Poker()
  14.         Dim i As Integer
  15.         For i = 0 To pic.GetUpperBound(0)
  16.             pic(i) = New PictureBox
  17.  
  18.             With pic(i)
  19.                 .Visible = True
  20.                 .Width = 130
  21.                 .Height = 200
  22.                 .Left = 20 + (i * 160)
  23.                 .Top = 20
  24.                 .BorderStyle = BorderStyle.Fixed3D
  25.                 .SizeMode = PictureBoxSizeMode.StretchImage
  26.  
  27.             End With
  28.             Me.Controls.Add(pic(i))
  29.  
  30.  
  31.         Next
  32.     End Sub
  33.  
  34.     Private Sub cmdJouer_Click(sender As Object, e As EventArgs) Handles cmdJouer.Click
  35.         numMise.Enabled = False
  36.         cmdJouer.Enabled = False
  37.         cmdContinuer.Enabled = True
  38.         numCredit.Value = numCredit.Value - numMise.Value
  39.         Cpt_Cartes = 0
  40.  
  41.         Dim cpt As Integer
  42.         Dim c As Integer
  43.         Dim i As Integer
  44.         Dim hasard As New Random
  45.  
  46.  
  47.         For i = 0 To Cartes.GetUpperBound(0)
  48.             Cartes(i) = (cpt)
  49.             cpt += 1
  50.         Next
  51.  
  52.  
  53.         Dim temp As Integer
  54.         Dim i1, i2, i3 As Integer
  55.         For c = 0 To 30000
  56.             For i1 = 0 To Cartes.GetUpperBound(0)
  57.                 i2 = hasard.Next(0, Cartes.GetUpperBound(0))
  58.  
  59.                 temp = Cartes(i1)
  60.                 Cartes(i1) = Cartes(i2)
  61.                 Cartes(i2) = temp
  62.  
  63.             Next i1
  64.         Next
  65.  
  66.         'Array.Sort(Cartes)
  67.  
  68.         For i = 0 To main.GetUpperBound(0)
  69.             main(i) = Cartes(i)
  70.  
  71.         Next
  72.  
  73.  
  74.         For i = 0 To main.GetUpperBound(0)
  75.             pic(i).Image = imaCartes.Images(main(i))
  76.             Cpt_Cartes += 1
  77.         Next
  78.  
  79.  
  80.     End Sub
  81.  
  82.  
  83.     Private Sub CarteSelection(sender As Object, e As EventArgs)
  84.  
  85.     End Sub
  86.  
  87.     Private Sub cmdContinuer_Click(sender As Object, ass As EventArgs) Handles cmdContinuer.Click
  88.         Dim i As Integer
  89.         Dim Filtre_Condition As Boolean
  90.         Dim Carte_haute As Boolean = True
  91.  
  92.  
  93.  
  94.         Dim cpt, cpt_coeur, cpt_trefle, cpt_carreau, cpt_pique As Integer
  95.         Dim hasard As New Random
  96.  
  97.         If chkGarder1.Checked = False Then
  98.             i = Cpt_Cartes
  99.             main(0) = Cartes(51)
  100.             pic(0).Image = imaCartes.Images(main(0))
  101.             Cpt_Cartes += 1
  102.         End If
  103.  
  104.  
  105.         If chkGarder2.Checked = False Then
  106.             i = Cpt_Cartes
  107.             main(1) = Cartes(50)
  108.             pic(1).Image = imaCartes.Images(main(1))
  109.             Cpt_Cartes += 1
  110.         End If
  111.  
  112.  
  113.         If chkGarder3.Checked = False Then
  114.             i = Cpt_Cartes
  115.  
  116.             main(2) = Cartes(49)
  117.             pic(2).Image = imaCartes.Images(main(2))
  118.             Cpt_Cartes += 1
  119.         End If
  120.  
  121.         If chkGarder4.Checked = False Then
  122.             i = Cpt_Cartes
  123.             main(3) = Cartes(48)
  124.             pic(3).Image = imaCartes.Images(main(3))
  125.             Cpt_Cartes += 1
  126.         End If
  127.  
  128.         If chkGarder5.Checked = False Then
  129.             i = Cpt_Cartes
  130.             main(4) = Cartes(47)
  131.             pic(4).Image = imaCartes.Images(main(4))
  132.             Cpt_Cartes += 1
  133.         End If
  134.  
  135.  
  136.  
  137.         'Royale Flush
  138.  
  139.         Array.Sort(main)
  140.         For i = 0 To main.GetUpperBound(0)
  141.             If main(i) >= 8 And main(i) <= 12 And main(4) = main(3) + 1 And main(3) = main(2) + 1 And main(2) = main(1) + 1 And main(1) = main(0) + 1 Then
  142.                 cpt_coeur += 1
  143.             End If
  144.             If cpt_coeur = 5 Then
  145.                 MsgBox("Royale Flush!!")
  146.                 txtGain.Text = numMise.Value * 100
  147.                 numCredit.Value = numCredit.Value + (numMise.Value * 100)
  148.                 Filtre_Condition = True
  149.                 Carte_haute = False
  150.             End If
  151.  
  152.             If main(i) >= 21 And main(i) <= 25 And main(4) = main(3) + 1 And main(3) = main(2) + 1 And main(2) = main(1) + 1 And main(1) = main(0) + 1 Then
  153.                 cpt_trefle += 1
  154.             End If
  155.             If cpt_trefle = 5 Then
  156.                 MsgBox("Royale Flush!!")
  157.                 txtGain.Text = numMise.Value * 100
  158.                 numCredit.Value = numCredit.Value + (numMise.Value * 100)
  159.                 Filtre_Condition = True
  160.                 Carte_haute = False
  161.             End If
  162.  
  163.  
  164.             If main(i) >= 34 And main(i) <= 38 And main(4) = main(3) + 1 And main(3) = main(2) + 1 And main(2) = main(1) + 1 And main(1) = main(0) + 1 Then
  165.                 cpt_carreau += 1
  166.             End If
  167.             If cpt_carreau = 5 Then
  168.                 MsgBox("Royale Flush!!")
  169.                 txtGain.Text = numMise.Value * 100
  170.                 numCredit.Value = numCredit.Value + (numMise.Value * 100)
  171.                 Filtre_Condition = True
  172.                 Carte_haute = False
  173.             End If
  174.  
  175.  
  176.  
  177.             If main(i) >= 47 And main(i) <= 51 And main(4) = main(3) + 1 And main(3) = main(2) + 1 And main(2) = main(1) + 1 And main(1) = main(0) + 1 Then
  178.                 cpt_pique += 1
  179.             End If
  180.             If cpt_pique = 5 Then
  181.                 MsgBox("Royale Flush!!")
  182.                 txtGain.Text = numMise.Value * 100
  183.                 numCredit.Value = numCredit.Value + (numMise.Value * 100)
  184.                 Filtre_Condition = True
  185.                 Carte_haute = False
  186.             End If
  187.  
  188.  
  189.         Next
  190.  
  191.         'Straight flush
  192.         cpt = 0
  193.         If Filtre_Condition = False Then
  194.             For i = 0 To main.GetUpperBound(0)
  195.                 Array.Sort(main)
  196.                 'If main(i) >= 39 And main(i) <= 51 Or main(i) >= 26 And main(i) <= 38 Or main(i) >= 13 And main(i) <= 25 Or main(i) >= 0 And main(i) <= 12 Then
  197.                 If main(4) = main(3) + 1 And main(3) = main(2) + 1 And main(2) = main(1) + 1 And main(1) = main(0) + 1 Then
  198.                     cpt += 1
  199.                     If cpt = 5 Then
  200.  
  201.                         MsgBox("Straight flush")
  202.                         'straight_Flush = True
  203.                         Filtre_Condition = True
  204.                         Carte_haute = False
  205.                         txtGain.Text = numMise.Value * 50
  206.                         numCredit.Value = numCredit.Value + (numMise.Value * 50)
  207.                     End If
  208.                 End If
  209.                 'End If
  210.             Next
  211.         End If
  212.  
  213.         'Four of kind
  214.         If Filtre_Condition = False Then
  215.             For i = 0 To main.GetUpperBound(0)
  216.                 ninja(i) = main(i) Mod 13
  217.             Next
  218.             Array.Sort(ninja)
  219.             If ninja(4) = ninja(3) And ninja(3) = ninja(2) And ninja(2) = ninja(1) Or ninja(0) = ninja(1) And ninja(1) = ninja(2) And ninja(2) = ninja(3) Then
  220.                 MsgBox("Four of kind")
  221.                 'multi_filtre = True
  222.                 Filtre_Condition = True
  223.                 Carte_haute = False
  224.                 txtGain.Text = numMise.Value * 25
  225.                 numCredit.Value = numCredit.Value + (numMise.Value * 25)
  226.             End If
  227.         End If
  228.  
  229.  
  230.         'Full house
  231.         If Filtre_Condition = False Then
  232.             For i = 0 To main.GetUpperBound(0)
  233.                 ninja(i) = main(i) Mod 13
  234.             Next
  235.             Array.Sort(ninja)
  236.             If ninja(4) = ninja(3) And ninja(3) = ninja(2) And ninja(1) = ninja(0) Or ninja(0) = ninja(1) And ninja(1) = ninja(2) And ninja(3) = ninja(4) Then
  237.                 MsgBox("Full house")
  238.                 Filtre_Condition = True
  239.                 'multi_filtre = True
  240.                 Carte_haute = False
  241.                 txtGain.Text = numMise.Value * 20
  242.                 numCredit.Value = numCredit.Value + (numMise.Value * 20)
  243.  
  244.  
  245.             End If
  246.         End If
  247.  
  248.  
  249.         'Flush
  250.         If Filtre_Condition = False Then ' ici si la condition du filtre est fausse, il va continuer l'évaluation de la main pour évaluer une flush
  251.             ' sans que cette condition et celle de la straight rentre en clonflit
  252.             For i = 0 To main.GetUpperBound(0)
  253.                 If main(i) >= 0 And main(i) <= 12 Then
  254.                     cpt_coeur += 1
  255.                 End If
  256.                 If cpt_coeur = 5 Then
  257.                     MsgBox("Flush")
  258.                     txtGain.Text = numMise.Value * 15
  259.                     numCredit.Value = numCredit.Value + (numMise.Value * 15)
  260.                     Filtre_Condition = True
  261.                     Carte_haute = False
  262.                 End If
  263.  
  264.                 If main(i) >= 13 And main(i) <= 25 Then
  265.                     cpt_trefle += 1
  266.                 End If
  267.                 If cpt_trefle = 5 Then
  268.                     MsgBox("Flush")
  269.                     txtGain.Text = numMise.Value * 15
  270.                     numCredit.Value = numCredit.Value + (numMise.Value * 15)
  271.                     Filtre_Condition = True
  272.                     Carte_haute = False
  273.                 End If
  274.  
  275.                 If main(i) >= 26 And main(i) <= 38 Then
  276.                     cpt_carreau += 1
  277.                 End If
  278.                 If cpt_carreau = 5 Then
  279.                     MsgBox("Flush")
  280.                     txtGain.Text = numMise.Value * 15
  281.                     numCredit.Value = numCredit.Value + (numMise.Value * 15)
  282.                     Filtre_Condition = True
  283.                     Carte_haute = False
  284.                 End If
  285.  
  286.                 If main(i) >= 39 And main(i) <= 51 Then
  287.                     cpt_pique += 1
  288.                 End If
  289.                 If cpt_pique = 5 Then
  290.                     MsgBox("Flush")
  291.                     txtGain.Text = numMise.Value * 15
  292.                     numCredit.Value = numCredit.Value + (numMise.Value * 15)
  293.                     Filtre_Condition = True
  294.                     Carte_haute = False
  295.                 End If
  296.  
  297.  
  298.             Next
  299.         End If
  300.  
  301.         'Straight
  302.         If Filtre_Condition = False Then
  303.             For i = 0 To main.GetUpperBound(0)
  304.                 ninja(i) = main(i) Mod 13
  305.             Next
  306.             Array.Sort(ninja)
  307.             If ninja(4) = ninja(3) + 1 And ninja(3) = ninja(2) + 1 And ninja(2) = ninja(1) + 1 And ninja(1) = ninja(0) + 1 Then
  308.  
  309.                 MsgBox("Straight")
  310.                 Filtre_Condition = True
  311.                 txtGain.Text = numMise.Value * 10
  312.                 numCredit.Value = numCredit.Value + (numMise.Value * 10)
  313.                 Carte_haute = False
  314.             End If
  315.         End If
  316.  
  317.         'three of a kind
  318.         If Filtre_Condition = False Then
  319.             For i = 0 To main.GetUpperBound(0)
  320.                 ninja(i) = main(i) Mod 13
  321.             Next
  322.             Array.Sort(ninja)
  323.             If ninja(0) = ninja(1) And ninja(1) = ninja(2) Or ninja(1) = ninja(2) And ninja(2) = ninja(3) Or ninja(4) = ninja(3) And ninja(3) = ninja(2) Then
  324.                 MsgBox("Three of a kind")
  325.                 txtGain.Text = numMise.Value * 5
  326.                 numCredit.Value = numCredit.Value + (numMise.Value * 5)
  327.                 Carte_haute = False
  328.                 Filtre_Condition = True
  329.                 'three_kind = True
  330.             End If
  331.         End If
  332.  
  333.         ' two pairs
  334.         If Filtre_Condition = False Then
  335.             For i = 0 To main.GetUpperBound(0)
  336.                 ninja(i) = main(i) Mod 13
  337.             Next
  338.             Array.Sort(ninja)
  339.             If ninja(0) = ninja(1) And ninja(2) = ninja(3) Or ninja(1) = ninja(2) And ninja(3) = ninja(4) Or ninja(0) = ninja(1) And ninja(3) = ninja(4) Then
  340.                 MsgBox("two pairs")
  341.                 txtGain.Text = numMise.Value * 3
  342.                 numCredit.Value = numCredit.Value + (numMise.Value * 3)
  343.                 Filtre_Condition = True
  344.                 Carte_haute = False
  345.             End If
  346.         End If
  347.  
  348.         'pair
  349.         If Filtre_Condition = False Then
  350.             For i = 0 To main.GetUpperBound(0)
  351.                 ninja(i) = main(i) Mod 13
  352.             Next
  353.             Array.Sort(ninja)
  354.             If ninja(0) = ninja(1) Or ninja(1) = ninja(2) Or ninja(2) = ninja(3) Or ninja(3) = ninja(4) Then
  355.                 If ninja(0) >= 9 And ninja(1) >= 9 Or ninja(1) >= 9 And ninja(2) >= 9 Or ninja(2) >= 9 And ninja(3) >= 9 Or ninja(3) >= 9 And ninja(4) >= 9 Then
  356.                     MsgBox("pairs")
  357.                     txtGain.Text = numMise.Value * 1
  358.                     numCredit.Value = numCredit.Value + (numMise.Value * 1)
  359.                     Filtre_Condition = True
  360.                     Carte_haute = False
  361.                 Else
  362.                     MsgBox("Main pairs infèrieure au valet, votre main est perdante")
  363.                     Filtre_Condition = True
  364.                     Carte_haute = False
  365.                 End If
  366.             End If
  367.         End If
  368.  
  369.         'Main haute
  370.         If Carte_haute = True Then
  371.             MsgBox("main haute.  votre main est perdante")
  372.             txtGain.Text = "-" & numMise.Value
  373.         End If
  374.         numMise.Enabled = True
  375.         cmdJouer.Enabled = True
  376.         numMise.Enabled = True
  377.         cmdContinuer.Enabled = False
  378.         Uncheck_after_play() 'ici on appelle on bloque de code qui a pour but de décocher les cases
  379.  
  380.     End Sub
  381.  
  382.     Private Sub Uncheck_after_play()
  383.         ' ici losrque le tour de jeux est terminer on décoche les case pour
  384.         ' éviter que elle restent cocher et ennuiyer le joueur a devoir les décocher
  385.         chkGarder1.Checked = False
  386.         chkGarder2.Checked = False
  387.         chkGarder3.Checked = False
  388.         chkGarder4.Checked = False
  389.         chkGarder5.Checked = False
  390.     End Sub
  391.  
  392.     Private Sub cmdQuitte_Click(sender As Object, e As EventArgs) Handles cmdQuitte.Click
  393.         If MsgBox("Voulez-vous quitter le jeux ? ", MsgBoxStyle.YesNo) = MsgBoxResult.Ok Then
  394.             Application.Exit()
  395.         End If
  396.     End Sub
  397.  
  398.  
  399.  
  400. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement