Skip to content
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
9 changes: 8 additions & 1 deletion 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,6 +38,7 @@
#

# Make a new player object that is currently in the 'outside' room.
player = Player("Tevvin", room['outside'])

# Write a loop that:
#
Expand All @@ -49,3 +50,9 @@
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

while True:
print(player.room.name)
print(player.room.description)

user = input("Which way, Player? ")
10 changes: 10 additions & 0 deletions src/player.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# Write a class to hold player information, e.g. what room they are in
# currently.


# PLAYER CLASS
class Player:
def __init__(self, name, room):
self.name = name
self.room = room

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


# ROOM CLASS
class Room:
def __init__(self, name, description):
self.name = name
self.description = description

def __str__(self):
return f'Room name is {self.name}, Room description is {self.description}'