wuziclient.frm
来自「vb编程+从基础到实践光盘代码」· FRM 代码 · 共 2,139 行 · 第 1/5 页
FRM
2,139 行
vbCrLf
'显示私聊的内容
Case 4
MessageBox.Text = MessageBox.Text & Mid$(Information, 4) & _
vbCrLf
Case 5
MessageBox.Text = MessageBox.Text & Mid$(Information, 4) & _
vbCrLf
Case "P"
Dim Playcolor As Integer
Dim DetailColor As String
Dim OneName As String
OneName = Mid$(Information, 4, InStr(4, Information, _
":", vbTextCompare) - 4)
num1 = InStr(4, Information, ":", vbTextCompare)
num2 = InStr(num1 + 1, Information, ":", vbTextCompare)
'比赛方式
Style = CInt(Mid$(Information, num1 + 1, num2 - num1 - 1))
'找出该比赛的具体规定
PlayStyle.ListIndex = Style
Playcolor = CInt(Mid$(Information, num2 + 1))
If Playcolor = 0 Then
MyColor = 1
DetailColor = "黑"
Else
MyColor = 0
DetailColor = "白"
End If
answer = MsgBox(OneName & "想用" & DetailColor & "棋和你下" & vbCrLf & PlayStyle.Text, vbYesNo, "NOTECE")
If answer = vbYes Then
IfWatching = False
TCP2.SendData "/A:" & OneName & ":" & YourNickName & ":1"
If MyColor = 0 Then
BlackName.Caption = YourNickName
WhiteName.Caption = OneName
Else
BlackName.Caption = OneName
WhiteName.Caption = YourNickName
End If
OpponentName = OneName
Select Case Style
Case 1
CanUseTime = 60
EveryStepTime = 60
TimeCanUseCount = 60
Case 2
CanUseTime = 30
EveryStepTime = 30
TimeCanUseCount = 30
Case 3
CanUseTime = 10
EveryStepTime = 10
TimeCanUseCount = 10
Case 4
CanUseTime = 0
EveryStepTime = 10
TimeCanUseCount = 10
Case 5
End Select
Call NewGame
If MyColor = 0 Then
Mytime = Format(Time, "hh:mm:ss")
TimeBlack.Enabled = True
' Else
' Mytime = Format(Time, "hh:mm:ss")
' TimeWhite.Enabled = True
End If
LocalPlay = False
Else
TCP2.SendData "/A:" & OneName & ":" & YourNickName & ":0"
End If
Case "R"
MessageBox.Text = MessageBox.Text & Mid$(Information, 4) & _
"注册上网!" & Chr$(10) & Chr$(13)
Case "Q"
MessageBox.Text = MessageBox.Text & Mid$(Information, 4) & _
"下网!" & Chr$(10) & Chr$(13)
Case "A"
Ansernum = Mid$(Information, 4, InStr(4, Information, ":", vbTextCompare) - 4)
num1 = InStr(4, Information, ":", vbTextCompare)
OpponentName = Mid$(Information, num1 + 1)
If Ansernum = "1" Then
IfWatching = False
Call NewGame
If MyColor = 0 Then
TimeBlack.Enabled = True
Mytime = Format(Time, "hh:mm:ss")
FirstStep = True
WhiteName.Caption = OpponentName
BlackName.Caption = "你走..."
Else
FirstStep = False
TimeWhite.Enabled = False
WhiteName.Caption = YourNickName
BlackName.Caption = "对方走..."
End If
Else
MsgBox "对不起" & OpponentName & "不想和你下!", vbOKOnly, "哈哈"
End If
Case "D"
Dim X As Integer
Dim Y As Integer
Dim TempNum1 As Integer
Dim TempNum2 As Integer
Dim HisTime As String
X = CInt(Mid$(Information, 4, InStr(4, _
Information, ":", vbTextCompare) - 4))
TempNum1 = InStr(4, Information, ":", vbTextCompare)
TempNum2 = InStr(TempNum1 + 1, Information, ":", vbTextCompare)
Y = CInt(Mid$(Information, TempNum1 + 1, TempNum2 - TempNum1 - 1))
HisTime = Mid$(Information, TempNum2 + 1)
Drawing = True
Mytime = Format(Time, "hh:mm:ss")
Buffer = Buffer & Format(X, "00") & "-" & Format(Y, "00") & ":"
Call DrawPill(X, Y)
If MyColor = 0 Then
'如果是黑棋,则黑方记时器启动
TimeBlack.Enabled = True
If TimeDisplayB.Text <> "" Then
MidVariant = CDate(TimeDisplayB.Text)
End If
TimeWhite.Enabled = False
TimeDisplayW.Text = HisTime
Else
'如果是白棋,则白方记时器启动
If TimeDisplayW.Text <> "" Then
MidVariant = CDate(TimeDisplayW.Text)
End If
TimeWhite.Enabled = True
TimeBlack.Enabled = False
TimeDisplayB.Text = HisTime
End If
' StatusBar1.SimpleText = "你走!"
If MyColor = 0 Then
BlackName.Caption = "你走..."
WhiteName.Caption = OpponentName
Else
BlackName.Caption = OpponentName
WhiteName.Caption = "你走..."
End If
Case "W"
MsgBox "你输了!", vbOKOnly
IfPlaying = False
Drawing = False
TimeBlack.Enabled = False
TimeWhite.Enabled = False
TCP2.SendData "/L:"
Case "L"
MsgBox "恭喜你,你赢了这局比赛,希望你再接再励!", vbOKOnly
IfPlaying = False
Drawing = False
TimeBlack.Enabled = False
TimeWhite.Enabled = False
Case "G"
Dim TempPos0
Dim TempPos1
Dim Temppos2
IfWatching = True
TempPos0 = 4
TempPos1 = InStr(5, Information, ":", vbTextCompare)
Do While TempPos1 <> 0
str11 = Mid$(Information, TempPos0, TempPos1 - TempPos0)
Buffer = Buffer & Left$(str11, 2) & "-" & Right$(str11, 2) & ":"
Call DrawPill2(CInt(Left$(str11, 2)), CInt(Right$(str11, 2)))
TempPos0 = TempPos1 + 1
TempPos1 = InStr(TempPos1 + 1, Information, ":", vbTextCompare)
If tmeppos1 <> 0 Then
Temppos2 = TempPos1
End If
Loop
TempPos1 = InStr(Temppos2, Information, "|", vbTextCompare)
BlackName.Caption = Mid$(Information, Temppos2 + 1, TempPos1 - Temppos2 - 1)
WhiteName.Caption = Mid$(Information, TempPos1 + 1)
Case "g"
MsgBox "没有这个棋局!", vbCritical
MessageBox.Text = MessageBox.Text & "没有这个棋局!" & _
Chr(10) & Chr(13)
IfWatching = False
WatchQiJu = 0
Case "S"
Call DrawPill2(CInt(Mid$(Information, 4, 2)), CInt(Right(Information, 2)))
Buffer = Buffer & Mid$(Information, 4, 2) & "-" & Right(Information, 2) & ":"
Case "H"
Dim AnserNumber As Integer
Dim StepInfo As String
Dim StepX As Integer
Dim StepY As Integer
AnserNumber = MsgBox("对方想悔棋,你同意吗?", vbYesNo)
If AnserNumber = vbYes Then
StepInfo = Right(Buffer, 6)
StepX = CInt(Left(StepInfo, 2))
StepY = CInt(Left(Right(StepInfo, 3), 2))
PicQipan.ForeColor = &HC0E0FF
PicQipan.FillColor = &HC0E0FF
PicQipan.Circle (StepX * SubWidth, StepY * SubWidth), _
SubWidth / 3
PicQipan.ForeColor = vbBlack
If StepX <> 1 And StepX < 14 Then
PicQipan.Line ((StepX - 0.5) * SubWidth, StepY * SubWidth)-( _
(StepX + 0.5) * SubWidth, StepY * SubWidth)
Else
If StepX = 1 Then
PicQipan.Line (StepX * SubWidth, StepY * SubWidth)-( _
(StepX + 0.5) * SubWidth, StepY * SubWidth)
Else
PicQipan.Line ((StepX - 0.5) * SubWidth, StepY * SubWidth)-( _
StepX * SubWidth, StepY * SubWidth)
End If
End If
If StepY <> 1 And StepY < 14 Then
PicQipan.Line (StepX * SubWidth, (StepY - 0.5) * SubWidth)-( _
StepX * SubWidth, (StepY + 0.5) * SubWidth)
Else
If StepX = 1 Then
PicQipan.Line (StepX * SubWidth, StepY * SubWidth)-( _
StepX * SubWidth, (StepY + 0.5) * SubWidth)
Else
PicQipan.Line (StepX * SubWidth, (StepY - 0.5) * SubWidth)-( _
StepX * SubWidth, StepY * SubWidth)
End If
End If
Buffer = Mid$(Buffer, 1, Len(Buffer) - 6)
Drawing = Not Drawing
TCP2.SendData "/T:" & vbYes
Else
TCP2.SendData "/T:" & vbNo
End If
Case "T"
Dim AnserNumber1 As Integer
AnserNumber1 = CInt(Mid$(Information, 4))
If AnserNumber1 = vbNo Then
MsgBox "对方不同意悔棋!", vbCritical
' Drawing = True
Else
If AnserNumber = vbYes Then
StepInfo = Right(Buffer, 6)
StepX = CInt(Left(StepInfo, 2))
StepY = CInt(Left(Right(StepInfo, 3), 2))
PicQipan.ForeColor = &HC0E0FF
PicQipan.FillColor = &HC0E0FF
PicQipan.Circle (StepX * SubWidth, StepY * SubWidth), _
SubWidth / 3
PicQipan.ForeColor = vbBlack
If StepX <> 1 And StepX < 14 Then
PicQipan.Line ((StepX - 0.5) * SubWidth, StepY * SubWidth)-( _
(StepX + 0.5) * SubWidth, StepY * SubWidth)
Else
If StepX = 1 Then
PicQipan.Line (StepX * SubWidth, StepY * SubWidth)-( _
(StepX + 0.5) * SubWidth, StepY * SubWidth)
Else
PicQipan.Line ((StepX - 0.5) * SubWidth, StepY * SubWidth)-( _
StepX * SubWidth, StepY * SubWidth)
End If
End If
If StepY <> 1 And StepY < 14 Then
PicQipan.Line (StepX * SubWidth, (StepY - 0.5) * SubWidth)-( _
StepX * SubWidth, (StepY + 0.5) * SubWidth)
Else
If StepX = 1 Then
PicQipan.Line (StepX * SubWidth, StepY * SubWidth)-( _
StepX * SubWidth, (StepY + 0.5) * SubWidth)
Else
PicQipan.Line (StepX * SubWidth, (StepY - 0.5) * SubWidth)-( _
StepX * SubWidth, StepY * SubWidth)
End If
End If
'去掉一步
Buffer = Mid$(Buffer, 1, Len(Buffer) - 6)
Drawing = Not Drawing
End If
End If
Case "N"
MessageBox.Text = MessageBox.Text + Mid$(Information, 4) & vbCrLf
End Select
End If
'MessageBox.Text = Information
End Sub
Private Sub TCP2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "连接失败!", vbCritical
Timer1.Enabled = False
Connect.Tag = 1
TCP2.Close
Connect.Caption = "继续连接"
End Sub
Private Sub TimeBlack_Timer()
' TimeDisplayB.Text=cdate
' Mytime = TimeDisplayB.Text
Dim TimeUsed
Dim TotalSecond As Integer
Dim TotalMinuteTimeUsed As Single
If Drawing Then
If TimeDisplayB.Text <> "" Then
TimeDisplayB.Text = Format(CDate(Time - _
CDate(Mytime) + MidVariant), "hh:mm:ss")
Else
TimeDisplayB.Text = Format(CDate(Time - _
CDate(Mytime)), "hh:mm:ss")
End If
TotalMinuteTimeUsed = Minute(CDate(TimeDisplayB.Text))
If TotalMinuteTimeUsed > CanUseTime Then
TimeUsed = CDate(Time - CDate(Mytime))
TotalSecond = Second(TimeUsed) + Minute(TimeUsed) * 60
If TotalSecond > EveryStepTime Then
TimeCanUseCount = TimeCanUseCount - CInt(TotalSecond / EveryStepTime)
If TimeCanUseCount < 0 Then
TCP2.SendData "/L"
MsgBox "你已经超时判输", vbOKOnly
TimeWhite.Enabled = False
TimeBlack.Enabled = False
Drawing = False
Exit Sub
End If
End If
End If
Else
If TimeDisplayB.Text <> "" Then
TimeDisplayB.Text = Format(CDate(Time - _
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?