Skip to content

completed most of the assignment #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from room import Room
from player import Player

# Declare all the rooms

room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mount beckons"),
"North of you, the cave mount beckons", ["Torch"]),

'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""),
passages run north and east.""", ["Coins", "Map", "Shield"]),

'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""),
the distance, but there is no way across the chasm.""", ["Sword", "Coins", "Potion"]),

'narrow': Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),
to north. The smell of gold permeates the air.""", ["Compass"]),

'treasure': Room("Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
Expand All @@ -39,6 +40,8 @@

# Make a new player object that is currently in the 'outside' room.

player = Player("Stephen The Magnificently Benevolent", room['outside'])

# Write a loop that:
#
# * Prints the current room name
Expand All @@ -49,3 +52,66 @@
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

active = True

print(f"Welcome to {player.name} to the ADVENTURE GAAAAAAAAME! \n\nYou have been chosen to complete a quest of epic proportions, also known as an EPIC QUEST!\n\n{player.current_room.description}.\n\nStep to the north to enter the cave!\n\n***Press N to move North")
print(player.current_room.name)
while player.current_room.name is "Outside Cave Entrance":
first_move = input()
if first_move is "N":
player.current_room = player.current_room.n_to
else:
"I'm sorry that move isn't allowed!"

print(f'{player.name} steps north, into the {player.current_room.name}....\n{player.current_room.description}\n')

print("If you're ever too scared to go on, enter q in any prompt! Bwahahahaha!!!!!")


while active is True:
print(f"\nYou Are Here: {player.current_room.name}\n{player.current_room.description}\n")
if len(player.current_room.items) > 0:
print("There are items for plundering here!\n")
print(f"What's your next move, {player.name}???")
choice = input("Please choose 1 for move or 2 for change inventory: ")
if choice == "1":
move = input("Please choose a direction. N, S, E, or W: ")
if move == "N":
if hasattr(player.current_room, 'n_to'):
player.current_room = player.current_room.n_to
else:
print("I'm sorry that move isn't allowed!\n")
elif move == "S":
if hasattr(player.current_room, 's_to'):
player.current_room = player.current_room.s_to
else:
print("I'm sorry that move isn't allowed!\n")
elif move == "E":
if hasattr(player.current_room, 'e_to'):
player.current_room = player.current_room.e_to
else:
print("I'm sorry that move isn't allowed!\n")
elif move == "W":
if hasattr(player.current_room, 'w_to'):
player.current_room = player.current_room.w_to
else:
print("I'm sorry that move isn't allowed!\n")
else:
print("I'm sorry that's not a valid move! Try again!\n")
if choice == "2":
print(f"\n{player.name}'s current inventory:")
print(*player.inventory, sep=', ')
print(f"\nThese are the items in {player.current_room.name}:")
print(*player.current_room.items, sep=', ')
action, obj = input("\nWhat do you want to do? 'Take Coins' or 'Drop Sword': ").split()
if action == "Take":
player.inventory.append(obj)
player.current_room.items.remove(obj)
if action == "Drop":
print("\nWhich item do you want to discard?")
print(player.inventory)
player.inventory.remove(obj)
player.current_room.items.append(obj)


7 changes: 7 additions & 0 deletions src/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Implement a class to hold room information. This should have name and
# description attributes.

class Item():
def __init__(self, name, description):
self.name = name
self.description = description
6 changes: 6 additions & 0 deletions src/player.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Write a class to hold player information, e.g. what room they are in
# currently.

class Player():
def __init__(self, name, current_room, inventory=[]):
self.name = name
self.current_room = current_room
self.inventory = inventory
8 changes: 7 additions & 1 deletion src/room.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Implement a class to hold room information. This should have name and
# description attributes.
# description attributes.

class Room():
def __init__(self, name, description, items=[]):
self.name = name
self.description = description
self.items = items