Pycharm 中的基于文本的游戏没有给我正确的响应,我做错了什么?

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

每当我尝试在 pycharm 中运行游戏时,无论我输入什么动作,它都会给我“不是那样”选项,即使我输入正确的动作,我做错了什么?

#Dictionary
rooms = {
        'Laundry Room': {'West': 'Basement'}, #Game Starts Here
        'Basement': {'North': 'Kitchen'},
        'Kitchen': {'West': 'Living Room', 'East': 'Dining Room', 'North': 'Bedroom', 'South': 'Basement'},
        'Living Room': {'East': 'Kitchen', 'item': '$100 cash'},
        'Dining Room': {'West': 'Kitchen', 'North': 'Backyard', 'item': '$6 cash'},
        'Bedroom': {'South': 'Kitchen', 'East': 'Bathroom', 'item': '$200 cash'},
        'Bathroom': {'West': 'Bedroom', 'item': '$300 cash'},
        'Backyard': {'South': 'Dining Room', 'item': '$60 cash'} #Return to the Laundry Room via the Basement
}


player_move = ['North', 'South', 'East', 'West']
currentRoom = 'Laundry Room'


while True:


    player_move = input('Enter a move: \n')

    if player_move == 'Exit':
        print('Thanks for playing.')
        # break statement for exiting
        break

    if player_move in rooms[currentRoom]:
        currentRoom = rooms[currentRoom][player_move]

        addItem = input(' \n')

        if 'item' in rooms[currentRoom]:
            game(rooms[currentRoom]['item'])

        #if/else statements with break statement for final room/finishing the game
        if currentRoom == 'Laundry Room':
            if len(inventory) == 5:
                print('\n***********************     Congratulations!     ***********************')
                print('\n************************************************************************')
                print('\nYou have made it to the Laundry Room with all of the devils cash to ')
                print('pay off your sins. You used it to pay the devil his due and he morphs into a serpent')
                print('and slithers back down to hell. You can finally do your laundry in peace.\n')
                print('*************************************************************************\n')
                print('^^^^^^^^^^^^^^^^^^^^^^^^^^ Thanks for playing! ^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n')
                break

            else:
                print('\n################## You Failed! #######################',)
                print('\n####################################################')
                print('\nYou do not have the Devils money')
                print('and he morphs into a serpent and eats you ***CRUNCH***')
                print('YOU ARE DEAD')
                print('\n####################################################\n')
                print('Try again\n')
                break

    # else statement for input validation/invalid move
    else:
        print('\nNot that way, try again.\n')

我尝试修复类型错误,但我修复了错误,但仍然得到了正确的结果。

python dictionary scripting pycharm
1个回答
0
投票

谷歌如何使用 Pycharm 进行调试。一旦您可以检查 x 条件下的变量使用了哪些值,您就会发现问题。我认为 StackOverflow 不适合这个,无论如何你都会学到更多的调试知识。祝你好运!

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