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
Tom wants to find a number so that the sum of the digits of a two-digit number is 7. When reversing the digits, the number shoul
Rudik [331]
A VARIABLE is used to represent an unknown number.
3 0
2 years ago
Imagine you are building an ATM system; list at least 6 application domains for the system. That is, in which context is the sys
Anvisha [2.4K]

Answer:

Six applications domains for the ATM was listed below in the explanation section below

The main aim of the ATM is cash collection, user information update.

The users of the ATM are people, staff, customers/clients.

Explanation:

Solution

Given that

The Application domain for the system is given below:

  • The System is going to verify the details entered
  • Update the database on the server side
  • Calculation of cash Available
  • Count the Cash and Identify the note in the Machine
  • Troubleshooting of the ATM machine (system)
  • Backup of the system and Operating system /Software installed on the ATM machine.

The ATM is going to be used for the purpose of collecting cash, updating user information, cashing cheques etc and is used by all the Bank customers.

Who are the users of ATM:

  • Customers at the bank
  • Individuals /people
  • Staff of the Bank
3 0
3 years ago
OSI layer for HDLC??​
tresset_1 [31]

Answer:

HDLC is one of the most commonly used internet protocols (IP) in what is Layer 2 of the industry communication reference model called Open Systems Interconnection (OSI).

Explanation:

3 0
2 years ago
Use JavaWrite a program that will simulate a change machine found at cash registers. Input the amount due and amount paid from t
Ksju [112]

Answer:

Here is the JAVA program:

import java.util.Scanner;  //to accept input from user

public class Main { // class name

 public static void main(String [] args) {  // start of main method

   Scanner input = new Scanner(System.in);  // creates Scanner class object to take input from user

   System.out.println("Please Enter the Cost of the Item: ");  // prompts user to enter the cost of item

   double itemCost = input.nextDouble();  //scans and reads the input value of item cost

   System.out.println("Please Enter the Amount Paid: ");  // prompts user to enter the amount paid

   double amount = input.nextDouble();  //scans and reads the value of amount from user

   int change = (int)(amount * 100 - itemCost * 100);  //compute the remaining amount i.e. change

   System.out.println("Change Owed: " + change / 100.0);  // displays the owed change

   int quarters = change / 25;  // computes the value for quarters

   change = change % 25;  // compute the quarters remaining

   int dimes = change / 10;  //  computes dimes

   change = change % 10;  //  computes dimes remaining

   int nickels = change / 5;  // computes nickels

   change = change % 5;  // compute nickels remaining

   int pennies = change;  // computes pennies

   System.out.println("Quarters: " + quarters);  // displays computed value of quarters

   System.out.println("Dimes: " + dimes);  // displays value of dimes

   System.out.println("Nickels: " + nickels);  // displays value of nickels

   System.out.println("Pennies: " + pennies);   }} //displays value of pennies

Explanation:

I will explain the program with an examples.

Suppose the user enters 4.57 as cost of the item and 5.00 as amount paid. Then the program works as follows:

Change is computed as

change = (int)(amount * 100 - itemCost * 100);

This becomes;

change = (int)(5.00 * 100 - 4.57 * 100)

            = 500 - 457

change = 43

Now the change owed is computed as:

change / 100.0 = 43/100.0 = 0.43

Hence change owed = 0.43

Next quarters are computed as:

quarters = change / 25;

This becomes:

quarters = 43/25

quarters = 1

Now the remaining is computed as:

   change = change % 25;

This becomes:

   change = 43 % 25;

  change = 18

Next the dimes are computed from remaining value of change as:

dimes = change / 10;

dimes = 18 / 10

dimes = 1

Now the remaining is computed as:

   change = change % 10;

This becomes:

   change = 18 % 10

  change = 8

Next the nickels are computed from remaining value of change as:

nickels = change / 5;

nickels = 8 / 5

nickels = 1

Now the remaining is computed as:

   change = change % 5;

This becomes:

   change = 8 % 5

  change = 3

At last the pennies are computed as:

pennies = change;

pennies = 3

So the output of the entire program is:

Change Owed: 0.43                                                                                                                Quarters: 1                                                                                                                      Dimes: 1                                                                                                                         Nickels: 1                                                                                                                       Pennies: 3  

The screenshot of the output is attached.

7 0
2 years ago
What's the drawback of using Screened Subnet (DMZ)?
lesantik [10]

It's more expensive, it's more difficult to configure and maintain and it can be more difficult to troubleshoot

4 0
3 years ago
Other questions:
  • Which function of a web page relies on responsive web design? Adding extra horizontal scroll Blocking mobile devices from viewin
    11·2 answers
  • How to check what level you are in runescape?
    9·2 answers
  • In this exercise, you are given a phrase and need to return that phrase in all capital letters.
    6·1 answer
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • While doing research on the Internet, what kind of website should you avoid because the information may be biased?
    11·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • Gina is driving her car down the street. She has a teddy bear sitting on the back seat. A dog runs in front of Gina's car, so sh
    15·2 answers
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    8·1 answer
  • How do I contact an admin
    8·1 answer
  • Write the functions of F1 to F12 on the keyboard​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!