扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:朱罗海 来源:天极网 2007年11月9日
关键字:
Structure card Public face As Integer Public suit As Integer Public count As Integer Public faceup As Boolean End Structure |
Dim Deck() As card |
Dim playerCount As Integer = 0 Dim playerAce As Integer = 0 Dim dealerCount As Integer = 0 Dim dealerAce As Integer = 0 Dim ipcard, idcard As Integer Private Sub delay(ByVal dt As Integer) Dim t As Integer t = My.Computer.Clock.TickCount Do If My.Computer.Clock.TickCount >= t + dt Then Exit Do Loop End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button1.Visible = False Label1.Text=”” Label2.Text=”” Label1.Refresh() Label2.Refresh() MyBase.CreateGraphics.Clear(Color.DarkGreen) dealerAce = 0 playerAce = 0 dealerCount = 0 playerCount = 0 cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) playerCount += Deck(TopCard).count If Deck(TopCard).face = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label2.Text = playerCount.ToString Label2.Refresh() delay(1000) cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) dealerCount += Deck(TopCard).count If Deck(TopCard).face = 0 Then dealerCount += 10 : dealerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label1.Text = dealerCount.ToString Label1.Refresh() delay(1000) cdtDrawExt(MyBase.CreateGraphics.GetHdc, 220, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) playerCount += Deck(TopCard).count If Deck(TopCard).face = 0 And playerAce = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label2.Text = playerCount.ToString Label2.Refresh() delay(1000) cdtDrawExt(MyBase.CreateGraphics.GetHdc, 220, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) dealerCount += Deck(TopCard).count If Deck(TopCard).face = 0 And dealerAce = 0 Then dealerCount += 10 : dealerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label1.Text = dealerCount.ToString Label1.Refresh() delay(1000) ipcard = 2 idcard = 2 Button2.Visible = True Button3.Visible = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200 + 20 * ipcard, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) playerCount += Deck(TopCard).count If Deck(TopCard).face = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") ipcard += 1 Label2.Text = playerCount.ToString Label2.Refresh() If playerCount > 21 Then If playerAce >= 1 Then playerCount -= 10 playerAce -= 1 Label2.Text = playerCount.ToString Label2.Refresh() Else MsgBox("Player loss!") Button1.Visible = True Button2.Visible = False Button3.Visible = False End If End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Button2.Visible = False Button3.Visible = False dealerPlay() End Sub Private Sub dealerPlay() Do If dealerCount < 17 Then cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200 + 20 * idcard, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) dealerCount += Deck(TopCard).count If dealerCount > 21 And dealerAce = 1 Then dealerCount -= 10 : dealerAce -= 1 If Deck(TopCard).face = 0 And dealerCount <= 11 Then dealerCount += 10 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") idcard += 1 Else Exit Do End If Loop Label1.Text = dealerCount.ToString Label1.Refresh() If dealerCount <= 21 Then If playerCount > dealerCount Then MsgBox("Player win!") Else MsgBox("Dealer win!") End If Else MsgBox("Player win!") End If Button1.Visible = True Button2.Visible = False Button3.Visible = False End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者