1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
k0ka [10]
3 years ago
12

I'm having trouble with an assignment of mine. I'm making a text based adventure game for extra credit in my class and I'm stuck

on where to continue the code. Basically it's a text based adventure game written in PYTHON. Effectively most rooms have an item and the player MUST obtain two of these items (The Magic Sword and Magic Shield) to defeat the lich, if the player does not have these items, then the game gives an instant game over. This is the code I have done so far, it's the going from room to room portion.
#First, all the rooms are set up.
rooms = {
'Entrance': {'East': 'Private Study'},
'Dining Hall': {'South': 'Kitchen', 'North': 'Entrance', 'East': 'Armory', 'West': 'Hidden Room', 'Item': 'Map'},
'Kitchen': {'North': 'Dining Hall', 'East': 'Dungeon', 'Item': 'Food'},
'Dungeon': {'West': 'Kitchen', 'Item' : 'Lich'},
'Old Bedroom': {'South': 'Armory', 'Item': 'Potion'},
'Armory': {'West': 'Dining Hall', 'North': 'Old Bedroom', 'Item': 'Magic Shield'},
'Private Study' : {'West' : 'Entrance', 'Item' : 'Hidden Room Key'},
'Hidden Room' : {'East' : 'Dining Hall', 'Item' : 'Magic Sword'}
}
#Then the starting room is set
room = 'Entrance'
#This definition will set up the function to move betweem rooms.
def move_to_room(room, direct):
new_room = room
for a in rooms:
if a == room:
if direct in rooms[a]:
if isinstance(rooms[a][direct], list): #This if function is set up incase there are ever two paths in a room
b = input()
if b == '1':
new_room = rooms[a][direct][0]
else:
new_room = rooms[a][direct][1]
else:
new_room = rooms[a][direct]
return new_room
#The while loop is the full gameplay loop, the majority in which the player will see.
#First it will display what room the player is currently in, then asks them what they wish to do.
while 1:
print('\nYou have entered', room)
print('If you wish to stop playing, please enter "Stop" or "stop"')
print("Please enter north, south, east, or west please.")
direct = input('\nWhich direction do you want to enter?: ')
#If the player enters stop, then the game stops
if direct == 'Stop' or direct == 'stop':
exit(0)
#The main if for moving between rooms, there is a a there are no paths, then they player cannot move that way
if direct == 'east' or direct == 'west' or direct == 'north' or direct == 'south':
new_room = move_to_room(room, direct)
if new_room == room:
print('There is a wall in your path! Please enter another direction: ')
else:
room = new_room
#Another if incase the player enters with capital letters in their directions
if direct == 'East' or direct == 'West' or direct == 'North' or direct == 'South':
new_room = move_to_room(room, direct)
if new_room == room:
print('There is a wall in your path! Please enter another direction: ')
else:
room = new_room
#If there is an invalid entry that doesn't fit in the rooms, then the player will be told to enter it again.
else:
print('\nINVALID DIRECTION, PLEASE ENTER A VALID OPTION')
Computers and Technology
1 answer:
mihalych1998 [28]3 years ago
7 0
Invalid format in my brain
You might be interested in
What is the difference between organizing your data in a list and organizing it in a data extension?
azamat

The difference between organizing your data in a list and organizing it in a data extension is that in a list, you organize subscribers by name. In a data extension, you organize them by region.

<h3>What is Data extension?</h3>
  • A data extension contains contact information. A data extension is just a table with fields for contact information.
  • Data extensions can work independently or in conjunction with other data extensions.
  • The data may be used for searches, information retrieval, and sending to a selection of subscribers.
  • You have two options for importing data extensions: manually or automatically using Automation Studio or the Marketing Cloud API.
  • Both Contact Builder and Email Studio allow the usage of data extensions, but Email Studio is the only place where sharing, permissions, and other features are available.

To learn more about data extension, refer to the following link:

brainly.com/question/20388719

#SPJ4

7 0
2 years ago
NEED HELP ASAP JAVA
Bas_tet [7]
I think is C tbh sorry if that’s wrong my fault
4 0
3 years ago
How to add a table in word document
Veseljchak [2.6K]

Answer:

In Word, you can insert a table, convert text to a table, and even draw a table. To quickly insert a table: Select Insert > Table and move the cursor over the grid until you highlight the number of columns and rows you want.

Explanation:

hope this helps have a great day!

6 0
3 years ago
The key invention that enabled computers to go into every home and office is blank
marta [7]
It was the memory board wasn't it
4 0
3 years ago
How does technology improve productivity at
Svetradugi [14.3K]

Answer:

Enables sending documents to multiple

recipients

Provides flexible work schedules and

environments

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the process called that determines how bits are represented on the medium?
    9·1 answer
  • How do keystroke dynamics determine whether to authenticate an individual or not?
    14·1 answer
  • Which describes the first step a crawler-based search engine uses to find information?
    10·2 answers
  • customer seeks to buy a new computer for private use at home. The customer primarily needs the computer to use the Microsoft Pow
    5·1 answer
  • What are the uses of plotters​
    7·2 answers
  • Who does car shows in gta 5 or what do you guys do in gta
    10·2 answers
  • Write a Python program called wdcount.py which uses a dictionary to count the number of occurrences of each word (ignoring case)
    10·1 answer
  • Which would you use to get the number of elements in a dictionary?
    6·1 answer
  • Identify three errors in this HTML code snippet:
    15·2 answers
  • How does accenture generate value for clients through agile and devops?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!