Change how suit/number is handled in the card class, change the layout of the card tuples.
parent
f381a1806e
commit
959b3cd71d
|
@ -3,19 +3,15 @@
|
|||
Private id As Integer
|
||||
Private boxId As PictureBox
|
||||
Private cardImage As Image
|
||||
Private cardName As Tuple(Of String, String)
|
||||
Private cardSuit As String
|
||||
Private cardNumber as String
|
||||
Private card As (suit As String, number As String)
|
||||
Private cardLocation As Point
|
||||
Private cardHidden As Boolean
|
||||
|
||||
Public Sub New(name As Tuple(Of String, String), Optional hidden As Boolean = False)
|
||||
Public Sub New(name As (String, String), Optional hidden As Boolean = False)
|
||||
id = idCounter
|
||||
idCounter += 1
|
||||
boxId = New PictureBox()
|
||||
cardName = name
|
||||
cardSuit = name.item1
|
||||
cardNumber = name.item2
|
||||
card = name
|
||||
cardHidden = hidden
|
||||
cardImage = Utilities.GetCardImage(name, hidden)
|
||||
End Sub
|
||||
|
@ -24,8 +20,8 @@
|
|||
cardLocation = location
|
||||
End Sub
|
||||
|
||||
Public Sub SetName(name As Tuple(Of String, String))
|
||||
cardName = name
|
||||
Public Sub SetName(name As (String, String))
|
||||
card = name
|
||||
End Sub
|
||||
|
||||
Public Sub SetHidden(hidden As Boolean)
|
||||
|
@ -41,15 +37,15 @@
|
|||
End Function
|
||||
|
||||
Public Function GetName()
|
||||
Return cardName
|
||||
Return card
|
||||
End Function
|
||||
|
||||
Public Function GetSuit() As String
|
||||
Return cardSuit
|
||||
Return card.suit
|
||||
End Function
|
||||
|
||||
Public Function GetNumber() As String
|
||||
Return cardNumber
|
||||
Return card.number
|
||||
End Function
|
||||
Public Function GetLocation()
|
||||
Return cardLocation
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
Private player As Player
|
||||
Private dealer As Dealer
|
||||
Private deck As List(Of Tuple(Of String, String))
|
||||
Private deck As List(Of (String, String))
|
||||
Private WithEvents dealerDelay As Timer
|
||||
|
||||
Public Sub Start()
|
||||
|
@ -32,7 +32,7 @@
|
|||
End Sub
|
||||
|
||||
Sub DealCard(playerDealt As Object, Optional hide As Boolean = False)
|
||||
Dim card As Tuple(Of String, String) = deck(0)
|
||||
Dim card As (String, String) = deck(0)
|
||||
Dim playingCard = New Card(card, hide)
|
||||
playerDealt.hand.Add(playingCard)
|
||||
deck.RemoveAt(0)
|
||||
|
@ -189,13 +189,13 @@
|
|||
End Select
|
||||
End Function
|
||||
|
||||
Shared Function CreateDeck() As List(Of Tuple(Of String, String))
|
||||
Dim response As New List(Of Tuple(Of String, String))
|
||||
Shared Function CreateDeck() As List(Of (String,String))
|
||||
Dim response As New List(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 suit As String In suits
|
||||
For Each num As String In nums
|
||||
response.Add(Tuple.Create(suit, num))
|
||||
response.Add((suit, num))
|
||||
Next
|
||||
Next
|
||||
Return Utilities.Shuffle(response)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
If hide Then
|
||||
pictureBox.Image = My.Resources.blue
|
||||
Else
|
||||
pictureBox.Image = Utilities.GetCardImage(Tuple.create(card.GetSuit(), card.GetNumber()))
|
||||
pictureBox.Image = Utilities.GetCardImage((card.GetSuit(), card.GetNumber()))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
|
|
@ -16,6 +16,6 @@ Public Class Dealer
|
|||
Inherits Player
|
||||
|
||||
Public Property limit As Integer = 17
|
||||
Public Property hidden As Tuple(Of String, String)
|
||||
Public Property hidden As (String, String)
|
||||
Public Property trueTotal As Integer
|
||||
End Class
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
Return list
|
||||
End Function
|
||||
|
||||
Public Shared Function GetCardImage(card As Tuple(Of String, String), Optional hidden As Boolean = False) As Image
|
||||
Public Shared Function GetCardImage(card As (String, String), Optional hidden As Boolean = False) As Image
|
||||
If hidden Then
|
||||
Return My.Resources.blue
|
||||
End If
|
||||
|
|
Loading…
Reference in New Issue