Replace this with a switch statement, make it easier to read

master
CrystalMoogle 2023-07-16 16:10:48 +01:00
parent 2860c9c622
commit d4eff0d774
1 changed files with 22 additions and 29 deletions

View File

@ -141,35 +141,28 @@
RaiseEvent EndGame(winMessage) RaiseEvent EndGame(winMessage)
End Sub End Sub
Function GetResults() Function GetResults()
If dealer.winType = WinCondition.Blackjack Then Select Case True
Case dealer.winType = WinCondition.Blackjack
If player.winType = WinCondition.Blackjack Then If player.winType = WinCondition.Blackjack Then
Return "Player ties with Blackjack!" Return "Player ties with Blackjack!"
Else Else
Return "Dealer wins with Blackjack!" Return "Dealer wins with Blackjack!"
End If End If
End If Case player.winType = WinCondition.Blackjack
If player.winType = WinCondition.Blackjack Then
Return "Player wins with Blackjack!" Return "Player wins with Blackjack!"
End If Case player.winType = WinCondition.FiveCard
If player.winType = WinCondition.FiveCard Then
Return "Player wins with Five Card Charlie!" Return "Player wins with Five Card Charlie!"
End If Case player.winType = WinCondition.Bust
If player.winType = WinCondition.Bust Then
Return "Player busts!" Return "Player busts!"
End If Case dealer.winType = WinCondition.Bust
If dealer.winType = WinCondition.Bust Then
Return "Dealer busts!" Return "Dealer busts!"
End If Case player.total > dealer.total
If player.total > dealer.total Then Return "Player wins with a total of " & player.total.ToString() & "!"
Return "Player wins with total of " + player.total.ToString() + "!" Case player.total = dealer.total
End If
If player.total = dealer.total Then
Return "Tie!" Return "Tie!"
End If Case Else
If player.total < dealer.total Then Return "Dealer wins with a total of " & dealer.total.ToString() & "!"
Return "Dealer wins with total of " + dealer.total.ToString() + "!" End Select
End If
Return "error"
End Function End Function
Function CreateDeck() As List(Of Tuple(Of String, String)) Function CreateDeck() As List(Of Tuple(Of String, String))
Dim response As New List(Of Tuple(Of String, String)) Dim response As New List(Of Tuple(Of String, String))