Compare commits
No commits in common. "master" and "v1.1.0" have entirely different histories.
|
@ -1,28 +0,0 @@
|
||||||
# This workflow will build a .NET project
|
|
||||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
|
|
||||||
|
|
||||||
name: .NET
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "master" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Setup .NET
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
dotnet-version: 6.0.x
|
|
||||||
- name: Restore dependencies
|
|
||||||
run: dotnet restore
|
|
||||||
- name: Build
|
|
||||||
run: dotnet build --no-restore
|
|
||||||
- name: Test
|
|
||||||
run: dotnet test --no-build --verbosity normal
|
|
|
@ -1,59 +0,0 @@
|
||||||
Public Class Card
|
|
||||||
Private Shared idCounter As Integer = 1
|
|
||||||
Private id As Integer
|
|
||||||
Private boxId As PictureBox
|
|
||||||
Private cardImage As Image
|
|
||||||
Private card As (suit As String, number As String)
|
|
||||||
Private cardLocation As Point
|
|
||||||
Private cardHidden As Boolean
|
|
||||||
Private size As Size
|
|
||||||
|
|
||||||
Public Sub New(name As (String, String), Optional hidden As Boolean = False)
|
|
||||||
id = idCounter
|
|
||||||
idCounter += 1
|
|
||||||
boxId = New PictureBox()
|
|
||||||
card = name
|
|
||||||
cardHidden = hidden
|
|
||||||
cardImage = Utilities.GetCardImage(name, hidden)
|
|
||||||
size = New Size(125,175)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Sub SetLocation(location As point)
|
|
||||||
cardLocation = location
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Sub SetName(name As (String, String))
|
|
||||||
card = 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 card
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function GetSuit() As String
|
|
||||||
Return card.suit
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function GetNumber() As String
|
|
||||||
Return card.number
|
|
||||||
End Function
|
|
||||||
Public Function GetLocation()
|
|
||||||
Return cardLocation
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function IsHidden()
|
|
||||||
Return cardHidden
|
|
||||||
End Function
|
|
||||||
End Class
|
|
|
@ -38,7 +38,6 @@ Partial Class GameWindow
|
||||||
PlayerTotal = New Label()
|
PlayerTotal = New Label()
|
||||||
DealerTotal = New Label()
|
DealerTotal = New Label()
|
||||||
WinMessage = New Label()
|
WinMessage = New Label()
|
||||||
deckPictureBox = New PictureBox()
|
|
||||||
CType(PlayerCard1, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard1, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(PlayerCard2, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard2, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(PlayerCard3, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard3, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
|
@ -49,12 +48,11 @@ Partial Class GameWindow
|
||||||
CType(PlayerCard8, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard8, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(PlayerCard9, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard9, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(PlayerCard10, ComponentModel.ISupportInitialize).BeginInit()
|
CType(PlayerCard10, ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(deckPictureBox, ComponentModel.ISupportInitialize).BeginInit()
|
|
||||||
SuspendLayout()
|
SuspendLayout()
|
||||||
'
|
'
|
||||||
' HitButton
|
' HitButton
|
||||||
'
|
'
|
||||||
HitButton.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
|
HitButton.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
HitButton.Enabled = False
|
HitButton.Enabled = False
|
||||||
HitButton.Font = New Font("Segoe UI", 36.0F, FontStyle.Regular, GraphicsUnit.Point)
|
HitButton.Font = New Font("Segoe UI", 36.0F, FontStyle.Regular, GraphicsUnit.Point)
|
||||||
HitButton.Location = New Point(100, 490)
|
HitButton.Location = New Point(100, 490)
|
||||||
|
@ -66,7 +64,7 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' StandButton
|
' StandButton
|
||||||
'
|
'
|
||||||
StandButton.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
|
StandButton.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
StandButton.Enabled = False
|
StandButton.Enabled = False
|
||||||
StandButton.Font = New Font("Segoe UI", 36.0F, FontStyle.Regular, GraphicsUnit.Point)
|
StandButton.Font = New Font("Segoe UI", 36.0F, FontStyle.Regular, GraphicsUnit.Point)
|
||||||
StandButton.Location = New Point(780, 490)
|
StandButton.Location = New Point(780, 490)
|
||||||
|
@ -78,11 +76,11 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard1
|
' PlayerCard1
|
||||||
'
|
'
|
||||||
PlayerCard1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
|
PlayerCard1.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard1.ErrorImage = My.Resources.Resources.blue2
|
PlayerCard1.ErrorImage = My.Resources.Resources.blue2
|
||||||
PlayerCard1.Image = My.Resources.Resources.blue
|
PlayerCard1.Image = My.Resources.Resources.blue
|
||||||
PlayerCard1.InitialImage = My.Resources.Resources.blue2
|
PlayerCard1.InitialImage = My.Resources.Resources.blue2
|
||||||
PlayerCard1.Location = New Point(150, 303)
|
PlayerCard1.Location = New Point(150, 284)
|
||||||
PlayerCard1.Name = "PlayerCard1"
|
PlayerCard1.Name = "PlayerCard1"
|
||||||
PlayerCard1.Size = New Size(125, 175)
|
PlayerCard1.Size = New Size(125, 175)
|
||||||
PlayerCard1.TabIndex = 2
|
PlayerCard1.TabIndex = 2
|
||||||
|
@ -90,11 +88,11 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard2
|
' PlayerCard2
|
||||||
'
|
'
|
||||||
PlayerCard2.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
|
PlayerCard2.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard2.ErrorImage = My.Resources.Resources.blue2
|
PlayerCard2.ErrorImage = My.Resources.Resources.blue2
|
||||||
PlayerCard2.Image = My.Resources.Resources.blue
|
PlayerCard2.Image = My.Resources.Resources.blue
|
||||||
PlayerCard2.InitialImage = My.Resources.Resources.blue2
|
PlayerCard2.InitialImage = My.Resources.Resources.blue2
|
||||||
PlayerCard2.Location = New Point(364, 303)
|
PlayerCard2.Location = New Point(375, 284)
|
||||||
PlayerCard2.Name = "PlayerCard2"
|
PlayerCard2.Name = "PlayerCard2"
|
||||||
PlayerCard2.Size = New Size(125, 175)
|
PlayerCard2.Size = New Size(125, 175)
|
||||||
PlayerCard2.TabIndex = 3
|
PlayerCard2.TabIndex = 3
|
||||||
|
@ -102,10 +100,10 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard3
|
' PlayerCard3
|
||||||
'
|
'
|
||||||
PlayerCard3.Anchor = AnchorStyles.Bottom
|
PlayerCard3.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard3.ErrorImage = Nothing
|
PlayerCard3.ErrorImage = Nothing
|
||||||
PlayerCard3.InitialImage = Nothing
|
PlayerCard3.InitialImage = Nothing
|
||||||
PlayerCard3.Location = New Point(578, 303)
|
PlayerCard3.Location = New Point(578, 284)
|
||||||
PlayerCard3.Name = "PlayerCard3"
|
PlayerCard3.Name = "PlayerCard3"
|
||||||
PlayerCard3.Size = New Size(125, 175)
|
PlayerCard3.Size = New Size(125, 175)
|
||||||
PlayerCard3.TabIndex = 4
|
PlayerCard3.TabIndex = 4
|
||||||
|
@ -113,10 +111,10 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard4
|
' PlayerCard4
|
||||||
'
|
'
|
||||||
PlayerCard4.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
|
PlayerCard4.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard4.ErrorImage = Nothing
|
PlayerCard4.ErrorImage = Nothing
|
||||||
PlayerCard4.InitialImage = Nothing
|
PlayerCard4.InitialImage = Nothing
|
||||||
PlayerCard4.Location = New Point(792, 303)
|
PlayerCard4.Location = New Point(780, 284)
|
||||||
PlayerCard4.Name = "PlayerCard4"
|
PlayerCard4.Name = "PlayerCard4"
|
||||||
PlayerCard4.Size = New Size(125, 175)
|
PlayerCard4.Size = New Size(125, 175)
|
||||||
PlayerCard4.TabIndex = 5
|
PlayerCard4.TabIndex = 5
|
||||||
|
@ -124,10 +122,10 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard5
|
' PlayerCard5
|
||||||
'
|
'
|
||||||
PlayerCard5.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
|
PlayerCard5.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard5.ErrorImage = Nothing
|
PlayerCard5.ErrorImage = Nothing
|
||||||
PlayerCard5.InitialImage = Nothing
|
PlayerCard5.InitialImage = Nothing
|
||||||
PlayerCard5.Location = New Point(1005, 303)
|
PlayerCard5.Location = New Point(1005, 284)
|
||||||
PlayerCard5.Name = "PlayerCard5"
|
PlayerCard5.Name = "PlayerCard5"
|
||||||
PlayerCard5.Size = New Size(125, 175)
|
PlayerCard5.Size = New Size(125, 175)
|
||||||
PlayerCard5.TabIndex = 6
|
PlayerCard5.TabIndex = 6
|
||||||
|
@ -153,7 +151,7 @@ Partial Class GameWindow
|
||||||
PlayerCard7.ErrorImage = My.Resources.Resources.blue2
|
PlayerCard7.ErrorImage = My.Resources.Resources.blue2
|
||||||
PlayerCard7.Image = My.Resources.Resources.blue
|
PlayerCard7.Image = My.Resources.Resources.blue
|
||||||
PlayerCard7.InitialImage = My.Resources.Resources.blue2
|
PlayerCard7.InitialImage = My.Resources.Resources.blue2
|
||||||
PlayerCard7.Location = New Point(792, 12)
|
PlayerCard7.Location = New Point(780, 12)
|
||||||
PlayerCard7.Name = "PlayerCard7"
|
PlayerCard7.Name = "PlayerCard7"
|
||||||
PlayerCard7.Size = New Size(125, 175)
|
PlayerCard7.Size = New Size(125, 175)
|
||||||
PlayerCard7.TabIndex = 10
|
PlayerCard7.TabIndex = 10
|
||||||
|
@ -161,7 +159,7 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard8
|
' PlayerCard8
|
||||||
'
|
'
|
||||||
PlayerCard8.Anchor = AnchorStyles.Top
|
PlayerCard8.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard8.ErrorImage = Nothing
|
PlayerCard8.ErrorImage = Nothing
|
||||||
PlayerCard8.InitialImage = Nothing
|
PlayerCard8.InitialImage = Nothing
|
||||||
PlayerCard8.Location = New Point(578, 12)
|
PlayerCard8.Location = New Point(578, 12)
|
||||||
|
@ -172,9 +170,10 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard9
|
' PlayerCard9
|
||||||
'
|
'
|
||||||
|
PlayerCard9.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard9.ErrorImage = Nothing
|
PlayerCard9.ErrorImage = Nothing
|
||||||
PlayerCard9.InitialImage = Nothing
|
PlayerCard9.InitialImage = Nothing
|
||||||
PlayerCard9.Location = New Point(364, 12)
|
PlayerCard9.Location = New Point(375, 12)
|
||||||
PlayerCard9.Name = "PlayerCard9"
|
PlayerCard9.Name = "PlayerCard9"
|
||||||
PlayerCard9.Size = New Size(125, 175)
|
PlayerCard9.Size = New Size(125, 175)
|
||||||
PlayerCard9.TabIndex = 8
|
PlayerCard9.TabIndex = 8
|
||||||
|
@ -182,6 +181,7 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerCard10
|
' PlayerCard10
|
||||||
'
|
'
|
||||||
|
PlayerCard10.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
PlayerCard10.ErrorImage = Nothing
|
PlayerCard10.ErrorImage = Nothing
|
||||||
PlayerCard10.InitialImage = Nothing
|
PlayerCard10.InitialImage = Nothing
|
||||||
PlayerCard10.Location = New Point(150, 12)
|
PlayerCard10.Location = New Point(150, 12)
|
||||||
|
@ -192,7 +192,7 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' StartGame
|
' StartGame
|
||||||
'
|
'
|
||||||
StartGame.Anchor = AnchorStyles.Bottom
|
StartGame.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
||||||
StartGame.Font = New Font("Segoe UI", 26.25F, FontStyle.Regular, GraphicsUnit.Point)
|
StartGame.Font = New Font("Segoe UI", 26.25F, FontStyle.Regular, GraphicsUnit.Point)
|
||||||
StartGame.Location = New Point(535, 490)
|
StartGame.Location = New Point(535, 490)
|
||||||
StartGame.Name = "StartGame"
|
StartGame.Name = "StartGame"
|
||||||
|
@ -203,7 +203,6 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' PlayerTotal
|
' PlayerTotal
|
||||||
'
|
'
|
||||||
PlayerTotal.Anchor = AnchorStyles.Bottom
|
|
||||||
PlayerTotal.AutoSize = True
|
PlayerTotal.AutoSize = True
|
||||||
PlayerTotal.Font = New Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point)
|
PlayerTotal.Font = New Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point)
|
||||||
PlayerTotal.Location = New Point(535, 561)
|
PlayerTotal.Location = New Point(535, 561)
|
||||||
|
@ -214,7 +213,6 @@ Partial Class GameWindow
|
||||||
'
|
'
|
||||||
' DealerTotal
|
' DealerTotal
|
||||||
'
|
'
|
||||||
DealerTotal.Anchor = AnchorStyles.Bottom
|
|
||||||
DealerTotal.AutoSize = True
|
DealerTotal.AutoSize = True
|
||||||
DealerTotal.Font = New Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point)
|
DealerTotal.Font = New Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point)
|
||||||
DealerTotal.Location = New Point(535, 610)
|
DealerTotal.Location = New Point(535, 610)
|
||||||
|
@ -232,25 +230,10 @@ Partial Class GameWindow
|
||||||
WinMessage.Size = New Size(0, 30)
|
WinMessage.Size = New Size(0, 30)
|
||||||
WinMessage.TabIndex = 15
|
WinMessage.TabIndex = 15
|
||||||
'
|
'
|
||||||
' deckPictureBox
|
|
||||||
'
|
|
||||||
deckPictureBox.Anchor = AnchorStyles.Top Or AnchorStyles.Right
|
|
||||||
deckPictureBox.BackgroundImageLayout = ImageLayout.None
|
|
||||||
deckPictureBox.ErrorImage = My.Resources.Resources.blue2
|
|
||||||
deckPictureBox.Image = My.Resources.Resources.blue
|
|
||||||
deckPictureBox.InitialImage = My.Resources.Resources.blue2
|
|
||||||
deckPictureBox.Location = New Point(1136, 156)
|
|
||||||
deckPictureBox.Name = "deckPictureBox"
|
|
||||||
deckPictureBox.Size = New Size(125, 175)
|
|
||||||
deckPictureBox.SizeMode = PictureBoxSizeMode.Zoom
|
|
||||||
deckPictureBox.TabIndex = 16
|
|
||||||
deckPictureBox.TabStop = False
|
|
||||||
'
|
|
||||||
' GameWindow
|
' GameWindow
|
||||||
'
|
'
|
||||||
AutoScaleMode = AutoScaleMode.Inherit
|
AutoScaleMode = AutoScaleMode.Inherit
|
||||||
ClientSize = New Size(1264, 681)
|
ClientSize = New Size(1264, 681)
|
||||||
Controls.Add(deckPictureBox)
|
|
||||||
Controls.Add(WinMessage)
|
Controls.Add(WinMessage)
|
||||||
Controls.Add(DealerTotal)
|
Controls.Add(DealerTotal)
|
||||||
Controls.Add(PlayerTotal)
|
Controls.Add(PlayerTotal)
|
||||||
|
@ -281,7 +264,6 @@ Partial Class GameWindow
|
||||||
CType(PlayerCard8, ComponentModel.ISupportInitialize).EndInit()
|
CType(PlayerCard8, ComponentModel.ISupportInitialize).EndInit()
|
||||||
CType(PlayerCard9, ComponentModel.ISupportInitialize).EndInit()
|
CType(PlayerCard9, ComponentModel.ISupportInitialize).EndInit()
|
||||||
CType(PlayerCard10, ComponentModel.ISupportInitialize).EndInit()
|
CType(PlayerCard10, ComponentModel.ISupportInitialize).EndInit()
|
||||||
CType(deckPictureBox, ComponentModel.ISupportInitialize).EndInit()
|
|
||||||
ResumeLayout(False)
|
ResumeLayout(False)
|
||||||
PerformLayout()
|
PerformLayout()
|
||||||
End Sub
|
End Sub
|
||||||
|
@ -302,5 +284,4 @@ Partial Class GameWindow
|
||||||
Friend WithEvents PlayerTotal As Label
|
Friend WithEvents PlayerTotal As Label
|
||||||
Friend WithEvents DealerTotal As Label
|
Friend WithEvents DealerTotal As Label
|
||||||
Friend WithEvents WinMessage As Label
|
Friend WithEvents WinMessage As Label
|
||||||
Friend WithEvents deckPictureBox As PictureBox
|
|
||||||
End Class
|
End Class
|
||||||
|
|
|
@ -27,15 +27,20 @@
|
||||||
StartGame.Enabled = False
|
StartGame.Enabled = False
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub OnCardDealt(card As Card, 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)
|
||||||
|
Try
|
||||||
pictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox)
|
pictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox)
|
||||||
If hide Then
|
If hide Then
|
||||||
pictureBox.Image = My.Resources.blue
|
pictureBox.Image = My.Resources.blue
|
||||||
Else
|
Else
|
||||||
pictureBox.Image = Utilities.GetCardImage((card.GetSuit(), card.GetNumber()))
|
pictureBox.Image = Utilities.GetCardImage(card)
|
||||||
End If
|
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
|
||||||
|
@ -49,15 +54,6 @@
|
||||||
PlayerCard7.Image = Utilities.GetCardImage(card)
|
PlayerCard7.Image = Utilities.GetCardImage(card)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub EndPlayerTurn() Handles game.EndPlayerTurn
|
|
||||||
HitButton.Enabled = False
|
|
||||||
StandButton.Enabled = False
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub MessageLabel(message) Handles game.MessageLabel
|
|
||||||
WinMessage.Text = message
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub EndGame(message) Handles game.EndGame
|
Private Sub EndGame(message) Handles game.EndGame
|
||||||
WinMessage.Text = message
|
WinMessage.Text = message
|
||||||
HitButton.Enabled = False
|
HitButton.Enabled = False
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Public Shared Function Shuffle(list)
|
Public Shared Function Shuffle(list)
|
||||||
Dim max As Integer = list.Count - 1
|
Dim max As Integer = list.Count - 1
|
||||||
Dim random As New Random()
|
Dim random As New Random()
|
||||||
For x = 0 To max
|
For x As Integer = 0 To max
|
||||||
Dim rand As Integer = random.Next(0, max)
|
Dim rand As Integer = random.Next(0, max)
|
||||||
Dim temp = list(x)
|
Dim temp = list(x)
|
||||||
list(x) = list(rand)
|
list(x) = list(rand)
|
||||||
|
@ -11,10 +11,7 @@
|
||||||
Return list
|
Return list
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function GetCardImage(card As (String, String), Optional hidden As Boolean = False) As Image
|
Public Shared Function GetCardImage(card As Tuple(Of String, String)) 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
|
||||||
|
@ -29,10 +26,6 @@
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
Dim img As String = suit + "_" + num
|
Dim img As String = suit + "_" + num
|
||||||
Try
|
|
||||||
Return My.Resources.ResourceManager.GetObject(img.ToLower())
|
Return My.Resources.ResourceManager.GetObject(img.ToLower())
|
||||||
Catch
|
|
||||||
Return My.Resources.blue
|
|
||||||
End Try
|
|
||||||
End Function
|
End Function
|
||||||
End Class
|
End Class
|
|
@ -3,13 +3,11 @@
|
||||||
Public Event CardDealt(card, cardNumber, hide)
|
Public Event CardDealt(card, cardNumber, hide)
|
||||||
Public Event SetTotalLabels(playerTotal, dealerTotal)
|
Public Event SetTotalLabels(playerTotal, dealerTotal)
|
||||||
Public Event ShowDealerCard(card)
|
Public Event ShowDealerCard(card)
|
||||||
Public Event EndPlayerTurn()
|
|
||||||
Public Event EndGame(winMessage)
|
Public Event EndGame(winMessage)
|
||||||
Public Event MessageLabel(message)
|
|
||||||
|
|
||||||
Private player As Player
|
Private player As Player
|
||||||
Private dealer As Dealer
|
Private dealer As Dealer
|
||||||
Private deck As List(Of (String, String))
|
Private deck As List(Of Tuple(Of String, String))
|
||||||
Private WithEvents dealerDelay As Timer
|
Private WithEvents dealerDelay As Timer
|
||||||
|
|
||||||
Public Sub Start()
|
Public Sub Start()
|
||||||
|
@ -32,9 +30,8 @@
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub DealCard(playerDealt As Object, Optional hide As Boolean = False)
|
Sub DealCard(playerDealt As Object, Optional hide As Boolean = False)
|
||||||
Dim card As (String, String) = deck(0)
|
Dim card As Tuple(Of String, String) = deck(0)
|
||||||
Dim playingCard = New Card(card, hide)
|
playerDealt.hand.Add(card)
|
||||||
playerDealt.hand.Add(playingCard)
|
|
||||||
deck.RemoveAt(0)
|
deck.RemoveAt(0)
|
||||||
GetTotal(playerDealt, hide)
|
GetTotal(playerDealt, hide)
|
||||||
If hide Then
|
If hide Then
|
||||||
|
@ -43,20 +40,20 @@
|
||||||
Dim cardNumber As String =
|
Dim cardNumber As String =
|
||||||
If(TypeOf playerDealt Is Dealer, (playerDealt.hand.Count + 5).ToString(), playerDealt.hand.Count)
|
If(TypeOf playerDealt Is Dealer, (playerDealt.hand.Count + 5).ToString(), playerDealt.hand.Count)
|
||||||
|
|
||||||
RaiseEvent CardDealt(playingCard, cardNumber, hide)
|
RaiseEvent CardDealt(card, cardNumber, hide)
|
||||||
RaiseEvent SetTotalLabels(player.total, dealer.total)
|
RaiseEvent SetTotalLabels(player.total, dealer.total)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub GetTotal(playerToCheck As Object, Optional hide As Boolean = False)
|
Sub GetTotal(playerToCheck As Object, Optional hide As Boolean = False)
|
||||||
Dim cards As List(Of Card) = playerToCheck.hand
|
Dim cards As List(Of Tuple(Of String, String)) = playerToCheck.hand
|
||||||
If cards.Count = 0 Then
|
If cards.Count = 0 Then
|
||||||
playerToCheck.total = 0
|
playerToCheck.total = 0
|
||||||
Return
|
Return
|
||||||
End If
|
End If
|
||||||
Dim total = 0
|
Dim total As Integer = 0
|
||||||
Dim aceTotal = 0
|
Dim aceTotal As Integer = 0
|
||||||
For Each card In cards
|
For Each card In cards
|
||||||
Dim num As String = card.GetNumber()
|
Dim num As String = card.Item2
|
||||||
If num = "K" Or num = "Q" Or num = "J" Then
|
If num = "K" Or num = "Q" Or num = "J" Then
|
||||||
num = 10
|
num = 10
|
||||||
End If
|
End If
|
||||||
|
@ -110,8 +107,6 @@
|
||||||
|
|
||||||
Sub DealerTurn()
|
Sub DealerTurn()
|
||||||
GetTotal(dealer)
|
GetTotal(dealer)
|
||||||
RaiseEvent MessageLabel("Dealer's turn...")
|
|
||||||
RaiseEvent EndPlayerTurn()
|
|
||||||
RaiseEvent SetTotalLabels(player.total, dealer.total)
|
RaiseEvent SetTotalLabels(player.total, dealer.total)
|
||||||
RaiseEvent ShowDealerCard(dealer.hidden)
|
RaiseEvent ShowDealerCard(dealer.hidden)
|
||||||
If player.winType = WinCondition.Bust Then
|
If player.winType = WinCondition.Bust Then
|
||||||
|
@ -189,10 +184,15 @@
|
||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Shared Function CreateDeck() As List(Of (String,String))
|
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 nums As String() = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}
|
||||||
Dim suits As String() = {"Hearts", "Diamonds", "Spades", "Clubs"}
|
Dim suits As String() = {"Hearts", "Diamonds", "Spades", "Clubs"}
|
||||||
Dim response As List(Of (String, String)) = (From suit In suits From num In nums Select (suit, num)).ToList()
|
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(response)
|
Return Utilities.Shuffle(response)
|
||||||
End Function
|
End Function
|
||||||
End Class
|
End Class
|
|
@ -1,10 +1,10 @@
|
||||||
Public Class Player
|
Public Class Player
|
||||||
Public Property hand As New List(Of Card)
|
Public Property hand As New List(Of Tuple(Of String, String))
|
||||||
Public Property total As Integer
|
Public Property total As Integer
|
||||||
Public Property ingame As Boolean
|
Public Property ingame As Boolean
|
||||||
Public Property winType As WinCondition
|
Public Property winType As WinCondition
|
||||||
|
|
||||||
Public Sub Start()
|
Sub Start()
|
||||||
hand.Clear()
|
hand.Clear()
|
||||||
total = 0
|
total = 0
|
||||||
ingame = True
|
ingame = True
|
||||||
|
@ -16,6 +16,6 @@ Public Class Dealer
|
||||||
Inherits Player
|
Inherits Player
|
||||||
|
|
||||||
Public Property limit As Integer = 17
|
Public Property limit As Integer = 17
|
||||||
Public Property hidden As (String, String)
|
Public Property hidden As Tuple(Of String, String)
|
||||||
Public Property trueTotal As Integer
|
Public Property trueTotal As Integer
|
||||||
End Class
|
End Class
|
Loading…
Reference in New Issue