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
The trade winds are the dominant surface winds from the subtropics to high latitudes. 1. True 2. False
Hatshy [7]

Answer:FALSE

Explanation: ITS THE WESTERLIES

5 0
3 years ago
Which tools would you use to make header 1 look like header 2.
Kamila [148]

The tools that would be used to make header 1 appear and look like header 2 is the alignment tool icon and the Bold tool icon.

To understand this question, we must understand the interface of the Microsoft Excel.

<h3>What is Microsoft Excel?</h3>

Microsoft Excel is a spreadsheet that can be used for a variety of features such as:

  • Computation of Data sets and variables
  • Calculation of Business Data
  • Arrangement and Analysis of Data into Tables etc.

As a Microsoft software, Microsoft Excel can also be used to edit sheets. In the image attached, the required tool icons needed to change the header 1 into header 2 is the alignment tool icon and the Bold tool icon.

The two tools can be seen in the image as the two lower left icons.

Learn more about Microsoft Excel here:

brainly.com/question/25863198

6 0
2 years ago
This is a bit confusing to me. Could someone please help me! I have to use CSS to Design a Web Page. I will mark Brainliest!
GrogVix [38]

Answer:

CSS is easy

Explanation:

CSS is like the color or your sylte for a webpage.

6 0
3 years ago
How was WiFi discovered?
postnew [5]

Answer:

An Australian scientist by the name of John O'Sullivan was inspired by Stephen Hawking's theory of evaporating black holes and their subsequent radio waves. He set out to find them and prove the theory correct. (Wi-Fi was discovered on accident)

7 0
3 years ago
To create an instance of Big Decimal for 454.45, use ________.
agasfer [191]

Answer:

C.

Explanation:

Based on the Java documentation; when creating an instance of BigDecimal, we can pass a string as a constructor.

System.out.println(new BigDecimal("454.45"));

8 0
4 years ago
Other questions:
  • . char values are surrounded by _____ quotes
    15·1 answer
  • State two ways a local area network can be used to monitor the work of employees
    11·1 answer
  • Using the find and replace tool would be most appropriate when
    6·2 answers
  • The scope of a variable declared inside of a function is:
    8·1 answer
  • While saving her word-processed academic documents, Ashley includes the subject, title, and the author's name in the properties.
    7·1 answer
  • your computer running Windows 10 is doing some very strange things with operating system you are fairly certain it is not a hard
    13·2 answers
  • PLEASE HELP ASAP!!
    13·1 answer
  • SOMEONE PLEASE HELP!! i’ll give brainliest
    14·2 answers
  • ________ programs help solve the problem of running out of storage space by providing lists of application programs, stored vide
    13·1 answer
  • Kkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkk
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!