d help fixing this code. I can't collect all the items, plus I need to add a commend to exit the game when users enter "EXIT"     def showinstructions():  # Game instruction     print("Snow Cave adventure Game ======== Collect All 6 Items To Win. ")     print("A GIANT SNOWBALL Is Waiting For You! ")     print("Just Go South, go North, go East, go West, Exit. ")     print("Get a snow Cone. Get some Wine. Get an Icicle. Get Glasses. ")     print("Get Medals. Get Long Underwear. Meet the Giant SNOWBALL. ") def showstatus(currentroom, inventory, rooms):

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need help fixing this code.

I can't collect all the items, plus I need to add a commend to exit the game when users enter "EXIT"

 

 

def showinstructions():  # Game instruction
    print("Snow Cave adventure Game ======== Collect All 6 Items To Win. ")
    print("A GIANT SNOWBALL Is Waiting For You! ")
    print("Just Go South, go North, go East, go West, Exit. ")
    print("Get a snow Cone. Get some Wine. Get an Icicle. Get Glasses. ")
    print("Get Medals. Get Long Underwear. Meet the Giant SNOWBALL. ")


def showstatus(currentroom, inventory, rooms):
    print(' ----------------------------')  # Just for a new line after each move
    print('You are in the ' + currentroom)

    print('Inventory: ' + str(inventory))
    if "item" in rooms[currentroom]:
        print('You have seen the ' + rooms[currentroom]['item'])

def main():

    inventory = []
    # rooms dictionary
    rooms = {

        'Ice Hall': {'South': 'TrophyRoom', 'North': 'IcicleRoom', 'East': 'SittingRoom', 'West': 'SnowRoom'},
        'TrophyRoom': {'North': 'Ice Hall', 'East': 'Dungeon', 'item': 'Medals'},
        'Dungeon': {'West': 'TrophyRoom', 'item': 'Wine'},
        'IcicleRoom': {'South': 'Ice Hall', 'East': 'ConeRoom', 'item': 'Icicle'},
        'ConeRoom': {'West': 'IcicleRoom', 'item': 'Snow Cone'},
        'SittingRoom': {'West': 'Ice Hall', 'North': 'Bedroom', 'item': 'Long Underwear'},
        'Bedroom': {'South': 'SittingRoom', 'item': 'Glasses'},
        'SnowRoom': {'East': 'Ice Hall', 'item': 'Giant SnowBall'}
    }
    # Initially user will be present in the main room or the Ice Hall
    currentroom = 'Ice Hall'

    showinstructions()
    while True:

        showstatus(currentroom, inventory, rooms)
        if 'item' in rooms[currentroom]:
            if rooms[currentroom]['item'] == 'Giant SnowBall':  # User will get frozen and the game will end
                print('You have been Frozen!!!.... GAME OVER!')
                print('Thank you for playing the game! ')
                print('BYE! BYE! ')
                break
        if len(inventory) == 6:
            print('Congratulation! You have collected all items and now won the game!')
            print('Get outside now and warm up.')
            break
        print(' ------------------------------')  # Just for a new line after break

        print('Enter your move: ')  # Prompting the user to enter an input
        move = ''
        while move == '':
            move = input()

            move = move.split()

            if len(move) != 2:
                print('Invalid input!')
                continue

            if move[0] == 'go':

                if move[1] in rooms[currentroom]:

                    currentroom = rooms[currentroom][move[1]]  # main logic part of the program

                else:
                    print("You can't go that way!")

            elif move[0] == 'get':

                if "item" in rooms[currentroom] and move[1] in rooms[currentroom]['item']:

                    inventory += [move[1]]

                    print(move[1] + ' got!')

                    del rooms[currentroom]['item']

                else:
                    print("Can't get" + move[1] + "!")
            else:
                print("Invalid move!")

if __name__ == '__main__':
    main()

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY