中国石凳联盟 登录注册

MUD路径反转程序

rockage··1 回复·356 浏览

发表回复

Private Sub Command1_Click()
Dim S1 As String, S11 As String, I As Integer, J As Integer, Path() As String
Dim T1 As String, S2 As String
Dim t As Integer, tstr1 As String, jin As Boolean, counts As Integer
S1 = Text1.Text
S1 = S1 ""
I = 0
J = 1
S2 = ""
counts = 0

ReDim Preserve Path(1)

Do
I = I + 1
T1 = Mid(S1, I, 1)
If Asc(T1) 10 And Asc(T1) 13 Then
S11 = S11 T1
End If
Loop Until I = Len(S1)

I = 0: T1 = ""

Do
I = I + 1
T1 = Mid(S11, I, 1)

jin = False
If T1 = "" Then

If Mid(S2, 1, 1) = "#" Then jin = True # 的情况

If jin = True Then
t = InStr(S2, " ")
tstr1 = Mid(S2, 1, t)
S2 = Mid(S2, t + 1, Len(S2) - t)
End If


Select Case S2
Case "e": S2 = "w"
Case "s": S2 = "n"
Case "w": S2 = "e"
Case "n": S2 = "s"

Case "nw": S2 = "se"
Case "ne": S2 = "sw"
Case "nu": S2 = "sd"
Case "nd": S2 = "su"

Case "sw": S2 = "ne"
Case "se": S2 = "nw"
Case "su": S2 = "nd"
Case "sd": S2 = "nu"

Case "wu": S2 = "ed"
Case "wd": S2 = "eu"

Case "eu": S2 = "wd"
Case "ed": S2 = "wu"
Case "out": S2 = "enter"
Case "enter": S2 = "out"





Case Else
S2 = S2
End Select

If jin = True Then # 的情况
S2 = tstr1 S2
counts = counts + Val(Mid(tstr1, 2, Len(tstr1) - 1)) 计算出#的数量
Else
counts = counts + 1

End If

Path(J) = S2
S2 = ""
J = J + 1
ReDim Preserve Path(J)
Else
S2 = S2 T1
End If
Loop Until I = Len(S11)
Label1.Caption = "原路径:" counts "步"

S2 = ""
For I = UBound(Path) To 1 Step -1
S2 = S2 Path(I) ""
Next I
S2 = Mid(S2, 2, Len(S2) - 2)

Text2.Text = S2


End Sub



因为做的时间很短(也就临时做一下顶急用而已),所以算法很粗糙,都是用很笨的办法实现的,有一个地方很奇怪,那就是从Zmud屏幕上截取下来的信息,有时候竟然会包含一些不可见的ASCII码,Chr(13),Chr(10),必须过滤。

因为Form过于简单,仅有一个按钮,一个Label,两个TextBox,所以没有必要放完整的源程序上来了吧,HOHO。
点赞0 收藏
发表回复
发表回复