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]
2 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]2 years ago
7 0
Invalid format in my brain
You might be interested in
What translates binary data into images on a monitor?
g100num [7]
A video card is what allows a computer to translate the binary data into images.
8 0
3 years ago
A _______ contains several blades of differing thicknesses and is used to measure the clearance between parts.
motikmotik
A Feeler Gauge. It is a tool used to measure gap widths
3 0
3 years ago
A client wishes to update their legacy system even though there have been no
gulaghasi [49]

Answer:

A client wishes to update their legacy system even though there have been no security breaches since its implementation five years ago. If the client has not suffered any attacks, why is it still necessary to update their system? ... Because new security threats emerge all the time.

8 0
3 years ago
Class secretType { public: static int count; static int z; secretType(); secretType(int a); void print(); static void incrementY
ANEK [815]

Answer:

a. secretType mySecret(9)

Explanation:

6 0
3 years ago
Which type of boot authentication is more secure?
Vinvika [58]

Answer:

UEFI

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • What is the e-file rejection error for an Invalid bank account or routing transit numbers?
    5·1 answer
  • __ means having a current knowledge and understanding of computers, mobile devices, the web, and related technologies.
    8·1 answer
  • Which of the following should you NOT do when using CSS3 properties to create text columns for an article element? a. make the c
    12·2 answers
  • Given the class 'ReadOnly' with the following behavior: A (protected) integer instance variable named 'val'. A constructor that
    8·1 answer
  • An Organization Chart to support the Appliance Warehouse case study The SWOT Analysis diagram you performed and created to suppo
    13·1 answer
  • Aspiring graphic designers can earn a(n) certification for graphic design software, such as Photoshop and Acrobat.
    9·2 answers
  • if a user has one column in a table and would like to make it into two columns which command should be used
    13·1 answer
  • You want to calculate a bonus if the sold price was at least equal to the listing price, and if the house sold within 30 days af
    6·1 answer
  • Which of the data repositories serves as a pool of raw data and stores large amounts of structured, semi-structured, and unstruc
    9·1 answer
  • A mobile application delivers market predictions based on stock data from the stock market data platform. Knowing that the data
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!