1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
| Imports VBCards
Public Class Form1
Private Structure UneCarte
Dim Couleur() As Integer
Dim Hauteur() As Integer
Dim Valeur As Integer
End Structure
Private Compte As Integer
Dim Cartes(52) As UneCarte
Dim MonCompte, Carte(), Erreurs As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Pique ,Carreau,Trefle,Coeur
NumericUpDown_nbrJeux.Value = My.Settings.NbrJeux
ReDim Carte((NumericUpDown_nbrJeux.Value * 52) - 1)
NumericUpDown_cartesmax.Value = My.Settings.Max_Cartes
ComboBox2.Text = My.Settings.Systeme
If ComboBox2.Text = "K-O" Then
MonCompte = -4 * NumericUpDown_nbrJeux.Value
End If
DeclareValeurs()
InitCartes()
lblValeurCarte.Text = "0"
lblMoncompte.Text = MonCompte.ToString
lblCompte.Text = Compte.ToString
DisableBouton()
End Sub
Private Sub NumericUpDown1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles NumericUpDown_nbrJeux.ValueChanged
ReDim Carte(NumericUpDown_nbrJeux.Value * 52 - 1)
InitCartes()
lblValeurCarte.Text = "0" 'Valeur
lblMoncompte.Text = "0" ' MonCompte
lblCartesRestantes.Text = ListBox1.Items.Count.ToString ' Cartes restantes
DisableBouton()
InitCompte()
End Sub
Private Sub DeclareValeurs()
Dim i As Integer
For i = 2 To 6
Cartes(i).Valeur = 1
Cartes(i + 13).Valeur = 1
Cartes(i + 26).Valeur = 1
Cartes(i + 39).Valeur = 1
Next
For i = 10 To 13
Cartes(i).Valeur = -1
Cartes(i + 13).Valeur = -1
Cartes(i + 26).Valeur = -1
Cartes(i + 39).Valeur = -1
Next
Cartes(1).Valeur = -1
Cartes(14).Valeur = -1
Cartes(27).Valeur = -1
Cartes(40).Valeur = -1
For i = 7 To 9
Cartes(i).Valeur = 0
Cartes(i + 13).Valeur = 0
Cartes(i + 26).Valeur = 0
Cartes(i + 39).Valeur = 0
Next
If ComboBox2.Text = "K-O" Then
Cartes(7).Valeur = 1
Cartes(20).Valeur = 1
Cartes(33).Valeur = 1
Cartes(46).Valeur = 1
End If
End Sub
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click
Efface()
Dim i, Nbrdecartes As Integer
Dim k As New Random
i = Val(sender.text)
MonCompte += i
If lblValeurCarte.Text <> sender.Text Then
Timer1.Stop()
MsgBox("Erreur")
Erreurs += 1
End If
If ListBox1.Items.Count = 0 Then
Timer1.Stop()
MsgBox("Vous avez fait " & Erreurs & " erreur(s)")
DisableBouton()
Exit Sub
End If
Nbrdecartes = k.Next(NumericUpDown_cartesmax.Value) + 1
i = TireCarte(Nbrdecartes)
lblMoncompte.Text = MonCompte.ToString
lblCartesRestantes.Text = ListBox1.Items.Count.ToString
lblValeurCarte.Text = i.ToString ' Nbrdecartes.ToString
lblCompte.Text = Compte.ToString
End Sub
Private Sub btnMelange_Click(sender As System.Object, e As System.EventArgs) Handles btnMelange.Click
Dim NbrdeCartes As Integer
Dim k As New Random
lblTimes.Text = "0"
Timer1.Start()
Efface()
InitCartes()
EnableBouton()
'Button10.Text = "Melange"
If ComboBox2.Text = "K-O" Then
Compte = -4 * NumericUpDown_nbrJeux.Value
Else : MonCompte = 0
End If
MonCompte = Compte
NbrdeCartes = k.Next(NumericUpDown_cartesmax.Value) + 1
MonCompte = TireCarte(NbrdeCartes)
lblValeurCarte.Text = MonCompte.ToString ' Cartes(NumericUpDown_cartesmax.Value).Valeur
lblCompte.Text = Compte.ToString
lblCartesRestantes.Text = ListBox1.Items.Count.ToString
End Sub
#Region "Pocedures finies"
Private Sub InitCartes()
Dim i, j As Integer
ListBox1.Items.Clear()
For i = 1 To NumericUpDown_nbrJeux.Value * 52
j = i Mod 52
If j = 0 Then j = 52
ListBox1.Items.Add(j.ToString)
Next
If ComboBox2.Text = "K-O" Then
MonCompte = -4 * NumericUpDown_nbrJeux.Value
Compte = MonCompte
End If
Erreurs = 0
End Sub
Private Sub Efface()
PictureBox1.Image = Nothing
PictureBox2.Image = Nothing
PictureBox3.Image = Nothing
PictureBox4.Image = Nothing
End Sub
Private Sub EnableBouton()
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
End Sub
Private Sub DisableBouton()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
InitCompte()
DisableBouton()
DeclareValeurs()
End Sub
Private Sub InitCompte()
Efface()
InitCartes()
btnMelange.Text = "Melange"
If ComboBox2.Text = "K-O" Then
MonCompte = -4 * NumericUpDown_nbrJeux.Value
Else : MonCompte = 0
End If
lblMoncompte.Text = MonCompte.ToString
End Sub
Private Sub Form1_FormClosed(sender As System.Object, e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
My.Settings.Max_Cartes = NumericUpDown_cartesmax.Value
My.Settings.NbrJeux = NumericUpDown_nbrJeux.Value
My.Settings.Systeme = ComboBox2.Text
End Sub
#End Region
Private Function TireCarte(ByVal Nbrdecartes As Integer)
Dim Rdn As New Random
Dim I, J As Integer
Select Case Nbrdecartes
Case 1
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox1.Image = AxDeck1.Picture
Case 2
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox1.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox2.Image = AxDeck1.Picture
Case 3
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox1.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox2.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox3.Image = AxDeck1.Picture
Case 4
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox1.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox2.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
' DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox3.Image = AxDeck1.Picture
If ListBox1.Items.Count = 0 Then
'DisableBouton()
Return I
Exit Function
End If
J = Rdn.Next(ListBox1.Items.Count)
AxDeck1.ChangeCard = ListBox1.Items.Item(J)
ListBox1.Items.RemoveAt(J)
I += Cartes(AxDeck1.ChangeCard).Valeur
PictureBox4.Image = AxDeck1.Picture
End Select
Return I
End Function
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim Temps As Integer
Temps = CInt(lblTimes.Text)
Temps += 1
lblTimes.Text = Temps.ToString
End Sub
End Class |
Partager