Код: Выделить всё
def intro():
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('See a floorplan of the restaurant by typing "map"')
intro()
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 = 'Bathroom'
# 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'])
print("\nEnter your move:")
def map():
print(
'\n Barista Parlor ----- Host Stand'
'\n | '
'\n | Outside Alley '
'\n | | '
'\n Bathroom - Dining Room ----Office'
'\n |'
'\n Kitchen -- Walk-in Cooler')
while True:
# Show current status
display_status()
# Get the player's next move
move = input('>').strip().split()
if len(move) < 1:
print('Invalid input. Try Again')
command = move[0].lower()
if command == "go":
if len(move) < 2:
print("Invalid input. Try again.")
continue
direction = move[1]
if direction in rooms[current_room]:
current_room = rooms[current_room][direction]
else:
print("You can't go that way!")
elif command == "get":
if len(move) < 2:
print("Invalid input. Try again.")
continue
item = " ".join(move[1:])
if 'item' in rooms[current_room] and rooms[current_room]['item'] == item:
inventory.append(item)
del rooms[current_room]['item']
print(f"you got the {item}")
else:
print("Can't get that item!")
elif command == "quit":
print('Thanks for playing!')
break
# Map print out feature !!!!!!!!!!!
elif command == "map":
print(map())
continue
else:
print("Invalid command. Try again.")
# Check win/lose conditions
if current_room == 'Host Stand':
if len(inventory) == 6:
print('You kept your cool while Karen expressed how upset this made her. She left happy!')
print('You even got tipped extra on top! Good Job!')
break
else:
print("Karen made you cry and rethink your career choices. Game Over. You lose")
break
Подробнее здесь: https://stackoverflow.com/questions/786 ... oming-from