OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

IT 140 Project loss statement [closed]

  • Thread starter Thread starter Joshua Mantooth
  • Start date Start date
J

Joshua Mantooth

Guest
I'm currently working on my project for IT140 where you use dictionaries, lists, and functions to create a text-based game. You have to move between rooms and pick up 6 objects to win the game; if you enter the room with the villain the game ends.

my lose statements is not triggering and i cannot figure out why

Code:
print('Welcome to the Hungry Karen game!!!')
print('Karen is Hungry, she ordered food for pickup. However she forgot to complete the online order.')
print('She is very upset with the restaurant that her order is not ready, she wants answers!')
print('Collect your items before dealing with her or she will ruin your day.')
print('You will need: \n - A cigarette in the Outside Alley \n - Pencil from the Office'
          ' \n - A beer from the Walk-in Cooler'
          ' \n - Cupcake from the Kitchen \n - Your notepad from the Dining Room \n - An espresso from the Barista Parlor')
print('You wont need any supplies from the bathroom, but feel free to take a few minutes to yourself here.')
print('          ')

rooms = {
    'Host Stand': {'west': 'Barista Parlor'},
    'Barista Parlor': {'east': 'Host Stand', 'south': 'Dining Room', 'item': 'espresso'},
    'Dining Room': {'west': 'Bathroom', 'north': 'Barista Parlor', 'east': 'Office', 'south': 'Kitchen',
                    'item': 'notepad'},
    'Bathroom': {'east': 'Dining Room'},
    'Kitchen': {'east': 'Walk-in Cooler', 'north': 'Dining Room', 'item': 'cupcake'},
    'Office': {'north': 'Outside Alley', 'west': 'Dining Room', 'item': 'pencil'},
    'Outside Alley': {'south': 'Office', 'item': 'cigarette'},
    'Walk-in Cooler': {'west': 'Kitchen', 'item': 'beer'}
}
# Player begins game in the Bathroom
starting_room = 'Dining Room'
# setting room up
current_room = starting_room
# define inventory dictionary
inventory = []
# Function to display player's status and possible commands
def display_status():
  print(' ')
  print('You are in the', current_room)
  print('Inventory:', inventory)
  if 'item' in rooms[current_room]:
   print('You see a', rooms[current_room]['item'])


if all(item in inventory for item in ['beer', 'espresso', 'notepad', 'cupcake', 'cigarette', 'pencil']):
    print('Congratulations! You have collected all items and defeated the villain!')


# Check lose condition
if current_room == 'Host Stand':
    print('Game Over! The villain got you. Better luck next time!')

while True:
    display_status()
    move = input("Enter your move: ").split()
    if len(move) == 2:
     action, target = move
    if action == 'go' and target in rooms[current_room]:
        current_room = rooms[current_room][target]
    elif action == 'get' and 'item' in rooms[current_room] and target == rooms[current_room]['item']:
        print(' ')
        print('You got the', target)
        inventory.append(target)
        del rooms[current_room]['item']
    else:
        print(' ')
        print('Invalid command. Try again.')
        break
if all item in inventory['beer', 'espresso', 'notepad', 'cupcake', 'cigarette', 'pencil']:
    print('Congratulations! You are ready to deal with Karen')


# Check lose condition
if current_room == 'Host Stand':
    print('Game Over! Karen destroyed you!')
<p>I'm currently working on my project for IT140 where you use dictionaries, lists, and functions to create a text-based game. You have to move between rooms and pick up 6 objects to win the game; if you enter the room with the villain the game ends.</p>
<p>my lose statements is not triggering and i cannot figure out why</p>
<pre><code>
print('Welcome to the Hungry Karen game!!!')
print('Karen is Hungry, she ordered food for pickup. However she forgot to complete the online order.')
print('She is very upset with the restaurant that her order is not ready, she wants answers!')
print('Collect your items before dealing with her or she will ruin your day.')
print('You will need: \n - A cigarette in the Outside Alley \n - Pencil from the Office'
' \n - A beer from the Walk-in Cooler'
' \n - Cupcake from the Kitchen \n - Your notepad from the Dining Room \n - An espresso from the Barista Parlor')
print('You wont need any supplies from the bathroom, but feel free to take a few minutes to yourself here.')
print(' ')

rooms = {
'Host Stand': {'west': 'Barista Parlor'},
'Barista Parlor': {'east': 'Host Stand', 'south': 'Dining Room', 'item': 'espresso'},
'Dining Room': {'west': 'Bathroom', 'north': 'Barista Parlor', 'east': 'Office', 'south': 'Kitchen',
'item': 'notepad'},
'Bathroom': {'east': 'Dining Room'},
'Kitchen': {'east': 'Walk-in Cooler', 'north': 'Dining Room', 'item': 'cupcake'},
'Office': {'north': 'Outside Alley', 'west': 'Dining Room', 'item': 'pencil'},
'Outside Alley': {'south': 'Office', 'item': 'cigarette'},
'Walk-in Cooler': {'west': 'Kitchen', 'item': 'beer'}
}
# Player begins game in the Bathroom
starting_room = 'Dining Room'
# setting room up
current_room = starting_room
# define inventory dictionary
inventory = []
# Function to display player's status and possible commands
def display_status():
print(' ')
print('You are in the', current_room)
print('Inventory:', inventory)
if 'item' in rooms[current_room]:
print('You see a', rooms[current_room]['item'])


if all(item in inventory for item in ['beer', 'espresso', 'notepad', 'cupcake', 'cigarette', 'pencil']):
print('Congratulations! You have collected all items and defeated the villain!')


# Check lose condition
if current_room == 'Host Stand':
print('Game Over! The villain got you. Better luck next time!')

while True:
display_status()
move = input("Enter your move: ").split()
if len(move) == 2:
action, target = move
if action == 'go' and target in rooms[current_room]:
current_room = rooms[current_room][target]
elif action == 'get' and 'item' in rooms[current_room] and target == rooms[current_room]['item']:
print(' ')
print('You got the', target)
inventory.append(target)
del rooms[current_room]['item']
else:
print(' ')
print('Invalid command. Try again.')
break
if all item in inventory['beer', 'espresso', 'notepad', 'cupcake', 'cigarette', 'pencil']:
print('Congratulations! You are ready to deal with Karen')


# Check lose condition
if current_room == 'Host Stand':
print('Game Over! Karen destroyed you!')
</code></pre>
 

Latest posts

Top