Skip to content

Commit

Permalink
no idea what adv is doing
Browse files Browse the repository at this point in the history
  • Loading branch information
CScori committed May 14, 2020
1 parent 7291a33 commit 04d7171
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from room import Room

from player import Player
# Declare all the rooms

room = {
Expand Down Expand Up @@ -38,7 +38,7 @@
#

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

player = Player('Cori', room['outside'])
# Write a loop that:
#
# * Prints the current room name
Expand All @@ -49,3 +49,19 @@
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

directions = {'N': 'n_to', 'S':'s_to', 'E':'e_to', 'W':'w_to'}

while True:
print(player.room.name)
print(player.room.description)
choice = input("Which way, Gandalf? ")
direction = directions[choice]

try:
player.room = getattr(player.room, direction)

except AttributeError:
print("Sorry you can't go that way!")
9 changes: 9 additions & 0 deletions src/player.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Write a class to hold player information, e.g. what room they are in
# currently.

class Person:
def __init__(self, name, room, items):
self.name = name
self.room = room
self.item = []

def __str__(self):
return f'{self.name} is in {self.room}'
16 changes: 15 additions & 1 deletion src/room.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# Implement a class to hold room information. This should have name and
# description attributes.
# description attributes.
class Room:
def def __init__(self, name, description, items=[]):
self.name = name
self.description = description

self.n_to = None
self.s_to = None
self.e_to = None
self.w_to = None

def __str__(self):
return self.name, self.descr


0 comments on commit 04d7171

Please sign in to comment.