案件没有归还价值

问题描述 投票:-1回答:1

我在文本冒险中设置了一个选择案例,当输入“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
vb.net
1个回答
0
投票

这种命令不需要trymoving()

© www.soinside.com 2019 - 2024. All rights reserved.