Convert cards to tuple
							parent
							
								
									ca2dd78e06
								
							
						
					
					
						commit
						eb37ba7c41
					
				| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
        StartGame.Enabled = False
 | 
			
		||||
    End Sub
 | 
			
		||||
 | 
			
		||||
    Private Sub OnCardDealt(card As String, cardNumber As String, hide As Boolean) Handles game.CardDealt
 | 
			
		||||
    Private Sub OnCardDealt(card As Tuple(Of String, String), cardNumber As String, hide As Boolean) Handles game.CardDealt
 | 
			
		||||
        Dim pictureBox As PictureBox
 | 
			
		||||
        Debug.Print(cardNumber)
 | 
			
		||||
        Try
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,15 +4,15 @@
 | 
			
		|||
        Dim random As New Random()
 | 
			
		||||
        For x As Integer = 0 To max
 | 
			
		||||
            Dim rand As Integer = random.Next(0, max)
 | 
			
		||||
            Dim temp As String = list(x)
 | 
			
		||||
            Dim temp = list(x)
 | 
			
		||||
            list(x) = list(rand)
 | 
			
		||||
            list(rand) = temp
 | 
			
		||||
        Next
 | 
			
		||||
        Return list
 | 
			
		||||
    End Function
 | 
			
		||||
    Public Shared Function GetCardImage(card) As Image
 | 
			
		||||
        Dim num As String = card.split(" ")(0)
 | 
			
		||||
        Dim suit As String = card.split(" ")(2)
 | 
			
		||||
    Public Shared Function GetCardImage(card As Tuple(Of String, String)) As Image
 | 
			
		||||
        Dim suit As String = card.Item1
 | 
			
		||||
        Dim num As String = card.Item2
 | 
			
		||||
        Select Case num
 | 
			
		||||
            Case "K"
 | 
			
		||||
                num = "king"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 | 
			
		||||
    Private player As Player
 | 
			
		||||
    Private dealer As Dealer
 | 
			
		||||
    Private deck As New List(Of String)
 | 
			
		||||
    Private deck As List(Of Tuple(Of String, String))
 | 
			
		||||
 | 
			
		||||
    Public Sub Start()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@
 | 
			
		|||
        RaiseEvent ResetUI()
 | 
			
		||||
    End Sub
 | 
			
		||||
    Sub DealCard(playerDealt, Optional isDealer = False, Optional hide = False)
 | 
			
		||||
        Dim card As String = deck(0)
 | 
			
		||||
        Dim card As Tuple(Of String, String) = deck(0)
 | 
			
		||||
        playerDealt.hand.Add(card)
 | 
			
		||||
        deck.RemoveAt(0)
 | 
			
		||||
        GetTotal(playerDealt, hide)
 | 
			
		||||
| 
						 | 
				
			
			@ -44,15 +44,15 @@
 | 
			
		|||
        If hide Then
 | 
			
		||||
            Exit Sub
 | 
			
		||||
        End If
 | 
			
		||||
        Dim cards As List(Of String) = playerToCheck.hand
 | 
			
		||||
        Dim cards As List(Of Tuple(Of String, String)) = playerToCheck.hand
 | 
			
		||||
        If cards.Count = 0 Then
 | 
			
		||||
            playerToCheck.total = 0
 | 
			
		||||
            Return
 | 
			
		||||
        End If
 | 
			
		||||
        Dim total As Integer = 0
 | 
			
		||||
        Dim aceTotal As Integer = 0
 | 
			
		||||
        For Each card As String In cards
 | 
			
		||||
            Dim num As String = card.Split(" "c)(0)
 | 
			
		||||
        For Each card In cards
 | 
			
		||||
            Dim num As String = card.Item2
 | 
			
		||||
            If num = "K" Or num = "Q" Or num = "J" Then
 | 
			
		||||
                num = 10
 | 
			
		||||
            End If
 | 
			
		||||
| 
						 | 
				
			
			@ -169,16 +169,16 @@
 | 
			
		|||
        End If
 | 
			
		||||
        Return "error"
 | 
			
		||||
    End Function
 | 
			
		||||
    Function CreateDeck()
 | 
			
		||||
        deck.Clear()
 | 
			
		||||
    Function CreateDeck() As List(Of Tuple(Of String, String))
 | 
			
		||||
        Dim response As New List(Of Tuple(Of String, String))
 | 
			
		||||
        Dim nums As String() = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}
 | 
			
		||||
        Dim suits As String() = {"Hearts", "Diamonds", "Spades", "Clubs"}
 | 
			
		||||
        For Each s As String In suits
 | 
			
		||||
            For Each n As String In nums
 | 
			
		||||
                deck.Add(n + " of " + s)
 | 
			
		||||
        For Each suit As String In suits
 | 
			
		||||
            For Each num As String In nums
 | 
			
		||||
                response.Add(Tuple.Create(suit, num))
 | 
			
		||||
            Next
 | 
			
		||||
        Next
 | 
			
		||||
        Return Utilities.Shuffle(deck)
 | 
			
		||||
        Return Utilities.Shuffle(response)
 | 
			
		||||
    End Function
 | 
			
		||||
 | 
			
		||||
End Class
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
Public Class Player
 | 
			
		||||
    Public Property hand As New List(Of String)
 | 
			
		||||
    Public Property hand As New List(Of Tuple(Of String, String))
 | 
			
		||||
    Public Property total As Integer
 | 
			
		||||
    Public Property ingame As Boolean
 | 
			
		||||
    Public Property winType As WinCondition
 | 
			
		||||
| 
						 | 
				
			
			@ -16,5 +16,5 @@ Public Class Dealer
 | 
			
		|||
    Inherits Player
 | 
			
		||||
 | 
			
		||||
    Public Property limit As Integer = 17
 | 
			
		||||
    Public Property hidden As String
 | 
			
		||||
    Public Property hidden As Tuple(Of String, String)
 | 
			
		||||
End Class
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue