Start working on a unified card class
							parent
							
								
									2455812fb2
								
							
						
					
					
						commit
						cc8fbf33ee
					
				| 
						 | 
					@ -30,17 +30,12 @@
 | 
				
			||||||
    Private Sub OnCardDealt(card As Tuple(Of String, String), cardNumber As String, hide As Boolean) _
 | 
					    Private Sub OnCardDealt(card As Tuple(Of String, String), cardNumber As String, hide As Boolean) _
 | 
				
			||||||
        Handles game.CardDealt
 | 
					        Handles game.CardDealt
 | 
				
			||||||
        Dim pictureBox As PictureBox
 | 
					        Dim pictureBox As PictureBox
 | 
				
			||||||
        Debug.Print(cardNumber)
 | 
					        pictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox)
 | 
				
			||||||
        Try
 | 
					        If hide Then
 | 
				
			||||||
            pictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox)
 | 
					            pictureBox.Image = My.Resources.blue
 | 
				
			||||||
            If hide Then
 | 
					        Else
 | 
				
			||||||
                pictureBox.Image = My.Resources.blue
 | 
					            pictureBox.Image = Utilities.GetCardImage(card)
 | 
				
			||||||
            Else
 | 
					        End If
 | 
				
			||||||
                pictureBox.Image = Utilities.GetCardImage(card)
 | 
					 | 
				
			||||||
            End If
 | 
					 | 
				
			||||||
        Catch ex As Exception
 | 
					 | 
				
			||||||
            EndGame("Error: " + ex.Message)
 | 
					 | 
				
			||||||
        End Try
 | 
					 | 
				
			||||||
    End Sub
 | 
					    End Sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Private Sub SetTotalLabels(playerTotalAmount, dealerTotalAmount) Handles game.SetTotalLabels
 | 
					    Private Sub SetTotalLabels(playerTotalAmount, dealerTotalAmount) Handles game.SetTotalLabels
 | 
				
			||||||
| 
						 | 
					@ -69,4 +64,4 @@
 | 
				
			||||||
        StandButton.Enabled = False
 | 
					        StandButton.Enabled = False
 | 
				
			||||||
        StartGame.Enabled = True
 | 
					        StartGame.Enabled = True
 | 
				
			||||||
    End Sub
 | 
					    End Sub
 | 
				
			||||||
End Class
 | 
					End Class
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,10 @@
 | 
				
			||||||
        Return list
 | 
					        Return list
 | 
				
			||||||
    End Function
 | 
					    End Function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Public Shared Function GetCardImage(card As Tuple(Of String, String)) As Image
 | 
					    Public Shared Function GetCardImage(card As Tuple(Of String, String), Optional hidden As Boolean = False) As Image
 | 
				
			||||||
 | 
					        If hidden Then
 | 
				
			||||||
 | 
					            Return My.Resources.blue
 | 
				
			||||||
 | 
					        End If
 | 
				
			||||||
        Dim suit As String = card.Item1
 | 
					        Dim suit As String = card.Item1
 | 
				
			||||||
        Dim num As String = card.Item2
 | 
					        Dim num As String = card.Item2
 | 
				
			||||||
        Select Case num
 | 
					        Select Case num
 | 
				
			||||||
| 
						 | 
					@ -26,6 +29,10 @@
 | 
				
			||||||
        End Select
 | 
					        End Select
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Dim img As String = suit + "_" + num
 | 
					        Dim img As String = suit + "_" + num
 | 
				
			||||||
        Return My.Resources.ResourceManager.GetObject(img.ToLower())
 | 
					        Try
 | 
				
			||||||
 | 
					            Return My.Resources.ResourceManager.GetObject(img.ToLower())
 | 
				
			||||||
 | 
					        Catch
 | 
				
			||||||
 | 
					            Return My.Resources.blue
 | 
				
			||||||
 | 
					        End Try
 | 
				
			||||||
    End Function
 | 
					    End Function
 | 
				
			||||||
End Class
 | 
					End Class
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,50 @@
 | 
				
			||||||
 | 
					Public Class Card
 | 
				
			||||||
 | 
					    Private Shared idCounter As Integer = 1
 | 
				
			||||||
 | 
					    Private id As Integer
 | 
				
			||||||
 | 
					    Private boxId As PictureBox
 | 
				
			||||||
 | 
					    Private cardImage As Image
 | 
				
			||||||
 | 
					    Private cardName As Tuple(Of String, String)
 | 
				
			||||||
 | 
					    Private cardLocation As Point
 | 
				
			||||||
 | 
					    Private cardHidden As Boolean
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Sub New(name As Tuple(Of String, String), Optional hidden As Boolean = False)
 | 
				
			||||||
 | 
					        id = idCounter
 | 
				
			||||||
 | 
					        idCounter += 1
 | 
				
			||||||
 | 
					        boxId = New PictureBox()
 | 
				
			||||||
 | 
					        cardName = name
 | 
				
			||||||
 | 
					        cardHidden = hidden
 | 
				
			||||||
 | 
					        cardImage = Utilities.GetCardImage(name, hidden)
 | 
				
			||||||
 | 
					    End Sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Sub SetLocation(location As point)
 | 
				
			||||||
 | 
					        cardLocation = location
 | 
				
			||||||
 | 
					    End Sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Sub SetName(name As Tuple(Of String, String))
 | 
				
			||||||
 | 
					        cardName = name
 | 
				
			||||||
 | 
					    End Sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Sub SetHidden(hidden As Boolean)
 | 
				
			||||||
 | 
					        cardHidden = hidden
 | 
				
			||||||
 | 
					    End Sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Function GetId()
 | 
				
			||||||
 | 
					        Return id
 | 
				
			||||||
 | 
					    End Function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Function GetBoxId()
 | 
				
			||||||
 | 
					        Return boxId
 | 
				
			||||||
 | 
					    End Function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Function GetName()
 | 
				
			||||||
 | 
					        Return cardName
 | 
				
			||||||
 | 
					    End Function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Function GetLocation()
 | 
				
			||||||
 | 
					        Return cardLocation
 | 
				
			||||||
 | 
					    End Function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Public Function IsHidden()
 | 
				
			||||||
 | 
					        Return cardHidden
 | 
				
			||||||
 | 
					    End Function
 | 
				
			||||||
 | 
					End Class
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@
 | 
				
			||||||
    Public Property ingame As Boolean
 | 
					    Public Property ingame As Boolean
 | 
				
			||||||
    Public Property winType As WinCondition
 | 
					    Public Property winType As WinCondition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Sub Start()
 | 
					    Public Sub Start()
 | 
				
			||||||
        hand.Clear()
 | 
					        hand.Clear()
 | 
				
			||||||
        total = 0
 | 
					        total = 0
 | 
				
			||||||
        ingame = True
 | 
					        ingame = True
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue