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
43 changes: 41 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 All @@ -21,7 +21,6 @@
earlier adventurers. The only exit is to the south."""),
}


# Link rooms together

room['outside'].n_to = room['foyer']
Expand All @@ -38,6 +37,46 @@
#

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

# print(new_player.room.name)

while True:
print(new_player.current_room.name)
print(new_player.current_room.description)
currentroom = new_player.current_room
playerInput = input(":")
if playerInput == "q" or playerInput == "Q":
exit()
elif playerInput.lower() == "n" or playerInput.lower() == "e" or playerInput.lower() == "s" or playerInput.lower() == "w":
if getattr(currentroom, playerInput + "_to") == None:
print(
f"You cannot go {playerInput} from {new_player.current_room.name}\n")
else:
new_player.current_room = getattr(currentroom, playerInput + "_to")
# elif playerInput == "E" or playerInput == "e":
# new_player.current_room = new_player.current_room.e_to
# elif playerInput == "S" or playerInput == "s":
# new_player.current_room = new_player.current_room.s_to
# elif playerInput == "W" or playerInput == "w":
# new_player.current_room = new_player.current_room.w_to


# for key, value in room.items():
# if new_player.room.name == value.name:
# print(value.name)
# print(value.description)
# print(value.n_to.name)
# playerinput = input(": ")


# if(playerinput == "q"):
# print(playerinput)
# quit
# if(playerinput == "N"):
# print(playerinput)
# new_player.room[value.n_to]
# print(new_player.room.name)

# Write a loop that:
#
Expand Down
11 changes: 11 additions & 0 deletions src/player.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# Write a class to hold player information, e.g. what room they are in
# currently.


class Player():
def __init__(self, name, current_room):
self.name = name
self.current_room = current_room


# new_player = Player("outside")

# print(new_player.room)
11 changes: 10 additions & 1 deletion src/room.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Implement a class to hold room information. This should have name and
# description attributes.
# description attributes.

class Room():
def __init__(self, name, description, n_to=None, s_to=None, e_to=None, w_to=None):
self.name = name
self.description = description
self.n_to = n_to
self.s_to = s_to
self.e_to = e_to
self.w_to = w_to
2 changes: 2 additions & 0 deletions src/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

playerInput = input(":")