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
13 changes: 9 additions & 4 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from room import Room
from player import Player
import textwrap

# Declare Items

# Declare all the rooms

Expand Down Expand Up @@ -52,14 +55,16 @@
# If the user enters "q", quit the game.

player_name = input('Enter a name for your character: ')
user_is_playing = True


while True:
print(f'\n{player_name} is {player.current_room.name} \n{player.current_room.description}')
while user_is_playing:
for line in textwrap.wrap(player_name + ' is in the ' + player.current_room.name + ' ' + player.current_room.description, 25):
print(line)
direction = str(input("\nWhich way would you like to go\n 'n', 's', 'e', 'w', 'q to quit'\n: "))
if direction == "q":
print('Thank you for playing!')
exit(0)
user_is_playing = False
# exit(0)
elif direction == 'n':
if player.current_room.n_to is not None:
player.current_room = player.current_room.n_to
Expand Down
4 changes: 4 additions & 0 deletions src/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Item:
def __init__(self, name, description):
self.name = name
self.description = description
3 changes: 2 additions & 1 deletion src/player.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Write a class to hold player information, e.g. what room they are in
# currently.
class Player:
def __init__(self, name, current_room):
def __init__(self, name, current_room, inventory = None):
self.name = name
self.current_room = current_room
self.inventory = [] if not inventory else inventory

def __str__(self):
print(self.name, self.current_room)
Expand Down
3 changes: 2 additions & 1 deletion src/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# description attributes.

class Room:
def __init__(self, name, description):
def __init__(self, name, description, items = None):
self.name = name
self.description = description
self.items = [] if not items else items
self.n_to = None
self.s_to = None
self.e_to = None
Expand Down