案件未归还价值

时间:2017-12-17 15:46:23

标签: vb.net

我在文本冒险中设置了一个选择案例,当输入“inventory”和“pickupblade / takeblade”时,应该调用子程序。然而,尽管情况1和2正确地调用子例程,但是不调用该子例程。代码不会抛出任何异常,但是没有调用相应的子例程。

while playing
        console.write("Where to next? ")
        ' get the command from user
        command = console.readline()
        ' command should be of either a single verb, single direction, or verb noun
        ' parse the command then use verb to identify appropriate action to take
        commandWords = Split(command," ")
        select case ubound(commandwords)
            case 0
            ' 'verb' command
                select case ucase(commandWords(0))
                    case "N","S","E","W","NORTH","SOUTH","EAST","WEST"
                        if tryMoving(commandWords(0)) then displayRoom
                    case "INVENTORY"
                        if trymoving(commandwords(0)) then inventory
                    case "PICKUPBLADE", "TAKEBLADE"
                        if trymoving(commandwords(0)) then pickup_blade

                end select
            case 1
            ' 'verb noun' commands
                select case ucase(commandWords(0))
                    case "GO","MOVE"
                        if trymoving(commandwords(1)) then displayRoom
                end select

        end select


    end while
End Sub

sub displayRoom()
    console.title=room(location)
    console.out.writeline(desc(location))
    if objLocation(0) = location Then
        Console.WriteLine("You can see a blade")
        Console.WriteLine("You can pickup this item.")
    end if  
end sub

sub pickup_blade()
    if objLocation(0) = location Then
        Console.WriteLine("You have picked up the blade.")
        objLocation(0) = 0
    end if
end sub

sub inventory()
    Console.WriteLine("------------------------------------------------------")
    Console.WriteLine("----------------------Inventory-----------------------")
    Console.WriteLine("------------------------------------------------------")
    if objLocation(0) = 0 Then
        Console.WriteLine("> Blade")
    elseif objLocation(1) = 0 Then
        Console.WriteLine("> Gloves")
    else
        Console.WriteLine("Inventory is empty.")
    end if

end sub

1 个答案:

答案 0 :(得分:0)

此类命令不需要trymoving()