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
1 change: 1 addition & 0 deletions game_map.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2020-06-04T17:22:27.434Z" agent="5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36" etag="oUzgU9-ywYFzmR9midQ2" version="13.1.14" type="device"><diagram id="1EokbCsPythKlQ7v2-tt" name="Page-1">7Zddb9sgFIZ/jS9XYWOnyeWatJs2TZoUqdt6h8yJTYeNhUls79ePxPiTRGmqqfGkSr7weYEDPO8RCAcvk/KTJFn8TVDgjodo6eCV43mu73nO/kO0qpXb2awWIsmo6dQJa/YHjIiMumUU8kFHJQRXLBuKoUhTCNVAI1KKYthtI/hw1oxEYAnrkHBb/cGoimt1HqBO/wwsipuZXWRaEtJ0NkIeEyqKnoTvHbyUQqj6LymXwPfwGi71uIcTre3CJKTqJQPY183i8VF8eS7QE33alSyS5IPJsiN8azYstirXyM2aVdWAKGKmYJ2RcB8X2mwH38Uq4Tpy9S/Jsxr/hpWgZ7wziUEqKE+u2G056AICkYCSle5iBni3Bp2pnWBu4qLnhJHingmNRoz3UZu5w6N/DKELaHkWrY2oQE6RlT+7MitsV5beIBfi9xRxYf/KuHwLV3o4vqYAy0cTq63AgqUkkHwrJ3FsjXFdvbbmFi4LE6T046Hc8CrkJM9ZqFnkikhlyz18moisfuoA3QRN+KvfttozQW1UmaieH6h1944Y68ueyAjUuTPZ9qLHOjjCutEkcKLYbriMYwaYGb4LphfYWo3dEzdUkyIXWxmCGdW/nMeJZqNEeJSo5mAlOtRDu+3Xl8jivy2Rq1mPFjfB8WPxYvPtVN7b2t+U8bv/L/bfx//M/yOp3tp/+x3w7v8Z/xEam7Zobbz4BAjQuVSvrgAddo/Munv3VMf3fwE=</diagram></mxfile>
41 changes: 41 additions & 0 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from room import Room

from player import Player

import textwrap

# Declare all the rooms

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

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

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

user_is_playing = True
# welcome message
print("Welcome to the adventure game")


# loop starts
while user_is_playing:
# print current room and description
print(player.current_room)
for line in textwrap.wrap(player.current_room.description, width=200):
print(line)
# take user input
user_cmd = input(
"[n] North [s] South [e] East [w] West [q] Quit\n").lower()
print(f"You chose {user_cmd}")
# user choose a cardinal direction
# if user inputs q, quit the game
if user_cmd == "q":
print("Bye, hope to see you next time!")
exit()

# if user inputs 4 directions
if user_cmd in ("n", "s", "e", "w"):
user_cmd = f"{user_cmd}_to"
# if the direction is available/not none then go to that room
if hasattr(player.current_room, user_cmd):
player.current_room = getattr(
player.current_room, user_cmd)
# else the option is not available/none then throw error and back to user input
else:
print("There's not room with your chosen direction.")
# any other user input will throw any error
else:
print(
"Please choose 1 of the 5 given options: [n] North [s] South [e] East [w] West [q] Quit")
4 changes: 4 additions & 0 deletions src/player.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 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
14 changes: 13 additions & 1 deletion src/room.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# Implement a class to hold room information. This should have name and
# description attributes.
# description attributes.

class Room:
def __init__(self, name, description):
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 f"You're currently in {self.name}"