加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

数值模拟

发布时间:2020-12-17 07:52:11 所属栏目:百科 来源:网络整理
导读:Public getTili As BooleanPublic buyTili As BooleanPublic cishu As IntegerPublic dengji As IntegerPublic tili As IntegerPublic jingyan As IntegerPublic zijin As LongPublic tianshu As IntegerPrivate Sub Check1_Click()If Check1.Value = 1 Then
Public getTili As Boolean
Public buyTili As Boolean
Public cishu As Integer
Public dengji As Integer
Public tili As Integer
Public jingyan As Integer
Public zijin As Long
Public tianshu As Integer
Private Sub Check1_Click()
If Check1.Value = 1 Then
    'MsgBox "被选择"
    getTili = True
Else
    'MsgBox "未被选择"
    getTili = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
    'MsgBox "被选择"
    buyTili = True
Else
    'MsgBox "未被选择"
    buyTili = False
End If
End Sub
Private Sub readButton_Click()
FileNumber = FreeFile
Open "player.txt" For Input As #FileNumber
Do While Not EOF(FileNumber)
    Line Input #FileNumber,TextLine
    temp = temp + TextLine + vbCrLf
    showTxt.Text = temp
Loop
Close #FileNumber
Set re = New RegExp
re.Pattern = "等级:(d+).*n当前经验:(d+).*n当前体力:(d+).*n资金:(d+).*n可购买体力次数:(d+)"
If (re.Test(temp) = True) Then
    Set re1 = re.Execute(temp)(0)
    cishu = re1.SubMatches(4)
    dengji = re1.SubMatches(0)
    tili = re1.SubMatches(2)
    jingyan = re1.SubMatches(1)
    zijin = re1.SubMatches(3)
    showMsg
Else
    MsgBox "文件错误"
End If
End Sub
Public Sub shuaFB()
Debug.Print "刷副本"
tili = tili - 6
zj = 610 + 10 * Int(dengji / 5)
zijin = zijin + zj
Debug.Print "获得资金:" & zj
jingyan = jingyan + 6
End Sub
Public Sub suanLevel()
Dim a,b As Integer
Set re = New RegExp
re.Pattern = "(d+)t(d+)"
FileNumber = FreeFile
Open "level.txt" For Input As #FileNumber
Do While Not EOF(FileNumber)
    Line Input #FileNumber,TextLine
    If re.Test(TextLine) = True Then
        Set re1 = re.Execute(TextLine)(0)
        a = re1.SubMatches(0)
        b = re1.SubMatches(1)
        If a = dengji And b > jingyan Then
            Close #FileNumber
            Exit Sub
        End If
        If a = dengji And b <= jingyan Then
            Debug.Print "Level UP"
            dengji = dengji + 1
            jingyan = jingyan - b
            max_tili = dengji + 59
            tili = tili + 20
        End If
    End If
Loop
'Close #FileNumber
End Sub
Public Sub showMsg()
levelTxt(0).Text = dengji
jingyanTxt(2).Text = jingyan
tiliTxt(1).Text = tili
moneyTxt(3).Text = zijin
End Sub
Private Sub runButton_Click()

If (Text1.Text = "") Then
    MsgBox "请输入天数"
Else
    tianshu = Text1.Text
End If
FileNumber = FreeFile
Open "Log.txt" For Output As #FileNumber
For i = 1 To tianshu
    Print #FileNumber,"====  第" + Str(i) + "天  ===="
    temp = temp + "第" + Str(i) + "天:" + vbCrLf
    tili = dengji + 59
    getTili = True
    buyTili = True
    n = 0
    While tili >= 6
        Print #FileNumber,"角色等级:" + Str(dengji) + "  角色体力:" + Str(tili) + "  当前资金:" + Str(zijin)
        shuaFB
        n = n + 1
        suanLevel
        If tili < 6 And Check1.Value = 1 And getTili = True Then
            tili = tili + 120
            getTili = False
            Print #FileNumber,"领取免费体力120点"
        End If
        If tili < 6 And Check2.Value = 1 And buyTili = True Then
            tl = 120 * cishu
            tili = tili + tl
            buyTili = False
            Print #FileNumber,"购买体力" + Str(tl) + "点"
        End If
    Wend
    Print #FileNumber,"通关主线次数:" + Str(n)
    temp = temp + "当前等级:" + Str(dengji) + " 当前资金:" + Str(zijin) + vbCrLf
    temp = temp + "通关主线次数:" + Str(n) + vbCrLf
Next i
showTxt.Text = temp
Print #FileNumber,"角色等级:" + Str(dengji) + " 当前资金:" + Str(zijin)
Close #FileNumber
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
Exit Sub
End If
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
MsgBox "只能输入数字"
End If
End Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读