Skip to content
Snippets Groups Projects
Commit 81c7f9df authored by Ahmed Yusuf's avatar Ahmed Yusuf
Browse files

minor changes, game nearly complete

parent 3c93d5e0
No related branches found
No related tags found
No related merge requests found
...@@ -39,12 +39,11 @@ def print_inventory_items(items): ...@@ -39,12 +39,11 @@ def print_inventory_items(items):
def print_room(room): def print_room(room):
time.sleep(0.5)
# Display room name # Display room name
print() print()
print(room["name"].upper()) print(room["name"].upper())
print() print()
time.sleep(1.2) time.sleep(0.5)
# Display room description # Display room description
print(room["description"]) print(room["description"])
print() print()
...@@ -128,11 +127,12 @@ def print_menu(exits, room_items, inv_items): ...@@ -128,11 +127,12 @@ def print_menu(exits, room_items, inv_items):
time.sleep(0.2) time.sleep(0.2)
if current_room==desk: if current_room==desk:
print("PLAY HANGMAN to play a game of hangman") print("PLAY HANGMAN to play a game of hangman")
time.sleep(0.2)
if current_room==trap_door and item_batteries in inventory: if current_room==trap_door and item_batteries in inventory:
print("USE BATTERIES for LOCK to place the batteries in the electrical lock") print("USE BATTERIES for LOCK to place the batteries in the electrical lock")
if current_room==trap_door and item_lock["batteries"] == True: time.sleep(0.2)
if current_room==trap_door:
print("OPEN TRAP DOOR to open the trap door and exit out of it") print("OPEN TRAP DOOR to open the trap door and exit out of it")
time.sleep(0.2)
print("What do you want to do?") print("What do you want to do?")
...@@ -172,7 +172,6 @@ def execute_take(item_id): ...@@ -172,7 +172,6 @@ def execute_take(item_id):
def execute_drop(item_id): def execute_drop(item_id):
time.sleep(0.1)
found = False found = False
for items in inventory: for items in inventory:
if items["id"] == item_id: if items["id"] == item_id:
...@@ -182,6 +181,7 @@ def execute_drop(item_id): ...@@ -182,6 +181,7 @@ def execute_drop(item_id):
if not found: if not found:
print("You cannot drop that.") print("You cannot drop that.")
time.sleep(0.3)
def time_taken(): def time_taken():
...@@ -212,7 +212,7 @@ def unlock_door(): ...@@ -212,7 +212,7 @@ def unlock_door():
current_room = locations["entrance"] current_room = locations["entrance"]
start_time = datetime.now() start_time = datetime.now()
print("You open the door and see a staircase. You decide to head up to the next level...") print("You open the door and see a staircase. You decide to head up to the next level...")
time.sleep(5) time.sleep(3)
break break
else: else:
...@@ -224,7 +224,6 @@ def unlock_door(): ...@@ -224,7 +224,6 @@ def unlock_door():
def check_timer(): def check_timer():
time.sleep(0.2)
current_time = datetime.now() current_time = datetime.now()
time_taken = current_time - start_time time_taken = current_time - start_time
time_left = 1200 - time_taken.total_seconds() time_left = 1200 - time_taken.total_seconds()
...@@ -233,6 +232,8 @@ def check_timer(): ...@@ -233,6 +232,8 @@ def check_timer():
minutes = time_left//60 minutes = time_left//60
seconds = time_left%60 seconds = time_left%60
print("You have", round(minutes), "minutes and", round(seconds), "seconds") print("You have", round(minutes), "minutes and", round(seconds), "seconds")
time.sleep(0.2)
def execute_command(command): def execute_command(command):
...@@ -269,8 +270,8 @@ def execute_command(command): ...@@ -269,8 +270,8 @@ def execute_command(command):
open_diary(current_room["items"]) open_diary(current_room["items"])
elif command[1] == "safe": elif command[1] == "safe":
open_safe(current_room["items"]) open_safe(current_room["items"])
elif command[1] == "trap door": elif command[1] == "trap" and command[2] == "door":
open_trapdoor() open_trapdoor(current_room)
else: else:
print("Open what?") print("Open what?")
...@@ -300,7 +301,7 @@ def execute_command(command): ...@@ -300,7 +301,7 @@ def execute_command(command):
if command[2] == "torch": if command[2] == "torch":
use_battery_torch() use_battery_torch()
elif command[2] == "lock": elif command[2] == "lock":
use_battery_lock() use_battery_lock(current_room)
else: else:
print("use batteries on what?") print("use batteries on what?")
elif command[1] == "torch": elif command[1] == "torch":
...@@ -330,7 +331,7 @@ def execute_command(command): ...@@ -330,7 +331,7 @@ def execute_command(command):
if command[1] == "hangman": if command[1] == "hangman":
hangman("closet") hangman("closet")
else: else:
print("drink what?") print("play what?")
else: else:
print("This makes no sense.") print("This makes no sense.")
...@@ -386,6 +387,10 @@ def main(): ...@@ -386,6 +387,10 @@ def main():
time.sleep(5) time.sleep(5)
gas_starttime = datetime.now() gas_starttime = datetime.now()
location_entrance["entered"] = True location_entrance["entered"] = True
if trap_door["open"]:
print()
print("(game ending)")
break
print_room(current_room) print_room(current_room)
print_inventory_items(inventory) print_inventory_items(inventory)
......
...@@ -63,8 +63,8 @@ def close_valve(): ...@@ -63,8 +63,8 @@ def close_valve():
def open_trapdoor(): def open_trapdoor(room):
if current_room == trap_door: if room == trap_door:
if item_lock["batteries"]: if item_lock["batteries"]:
if key_card in inventory: if key_card in inventory:
trap_door["open"] = True trap_door["open"] = True
...@@ -72,10 +72,12 @@ def open_trapdoor(): ...@@ -72,10 +72,12 @@ def open_trapdoor():
print("You need a key card to open the lock.") print("You need a key card to open the lock.")
else: else:
print("The electrical lock requires batteries to open.") print("The electrical lock requires batteries to open.")
else:
print("Command isn't available in this room")
def use_battery_lock(): def use_battery_lock(room):
if current_room == trap_door: if room == trap_door:
if item_batteries in inventory: if item_batteries in inventory:
item_lock["batteries"] = True item_lock["batteries"] = True
inventory.remove(item_batteries) inventory.remove(item_batteries)
......
...@@ -27,7 +27,8 @@ location_Fireplace = { ...@@ -27,7 +27,8 @@ location_Fireplace = {
location_bookshelf = { location_bookshelf = {
"name": "Bookshelf", "name": "Bookshelf",
"description": "The bookshelf is full of old books and they are all very dusty. You see a book standing out which appears to be a diary", "description": """The bookshelf is full of old books and they are all very dusty.
You see a book standing out which appears to be a diary""",
"exits": {"north-east": "door", "east": "centre"}, "exits": {"north-east": "door", "east": "centre"},
...@@ -37,7 +38,8 @@ location_bookshelf = { ...@@ -37,7 +38,8 @@ location_bookshelf = {
Location_desk = { Location_desk = {
"name": "The office desk", "name": "The office desk",
"description": "You see a desk with what looks to be a safe underneath it. You open the drawer, and sure enough, there is a small safe.", "description": """You see a desk with what looks to be a safe underneath it.
You open the drawer, and sure enough, there is a small safe.""",
"exits": {"west": "door", "south-west": "centre", "south" : "dark corner"}, "exits": {"west": "door", "south-west": "centre", "south" : "dark corner"},
...@@ -47,7 +49,8 @@ Location_desk = { ...@@ -47,7 +49,8 @@ Location_desk = {
location_dark_corner = { location_dark_corner = {
"name": "a dark corner of the room", "name": "a dark corner of the room",
"description": "The dark corner is filled with dust, cobwebs and old papers. There are also some old computers that no one uses anymore, probably the remnants of old computer science students.", "description": """The dark corner is filled with dust, cobwebs and old papers.
There are also some old computers that no one uses anymore, probably the remnants of old computer science students.""",
"exits": {"west": "fireplace", "north": "office desk", "north-west": "centre"}, "exits": {"west": "fireplace", "north": "office desk", "north-west": "centre"},
...@@ -56,7 +59,8 @@ location_dark_corner = { ...@@ -56,7 +59,8 @@ location_dark_corner = {
location_door = { location_door = {
"name": "level 1 Escape door", "name": "level 1 Escape door",
"description": "The door is locked, the keypad has a red light that’s blinking. You press the buttons randomly to no avail. You press more random buttons and the red light blinks faster. :( ", "description": """The door is locked, the keypad has a red light that’s blinking.
You press the buttons randomly to no avail. You press more random buttons and the red light blinks faster. :( """,
"exits": {"south": "centre"}, "exits": {"south": "centre"},
"locked": True, "locked": True,
...@@ -66,8 +70,10 @@ location_door = { ...@@ -66,8 +70,10 @@ location_door = {
location_entrance = { location_entrance = {
"name": "level 2 Entrance", "name": "level 2 Entrance",
"description": "You find yourself in another level of the basement. " "description": """You find yourself in another level of the basement.
"It takes a minute for your eyes to adjust to this new, brighter room. In this room there is a trap door with stairs leading up to it. there seems to be a desk underneath the stairs. There are multiple different rooms to the NORTH, WEST, SOUTH, EAST, SOUTH-EAST and then back DOWNSTAIRS. Once again you have 20 minutes, be careful and good luck.", It takes a minute for your eyes to adjust to this new, brighter room.In this room there is a trap door with stairs leading up to it.
There seems to be a desk underneath the stairs. There are multiple different rooms to the NORTH, WEST, SOUTH, EAST, SOUTH-EAST and then back DOWNSTAIRS.
Once again you have 20 minutes, be careful and good luck.""",
"exits": {"north": "wine cellar", "west": "storage room", "south": "boiler room", "east": "trap door", "south-east": "desk", "downstairs": "door"}, "exits": {"north": "wine cellar", "west": "storage room", "south": "boiler room", "east": "trap door", "south-east": "desk", "downstairs": "door"},
...@@ -77,7 +83,8 @@ location_entrance = { ...@@ -77,7 +83,8 @@ location_entrance = {
location_winecellar = { location_winecellar = {
"name": "Wine Cellar", "name": "Wine Cellar",
"description": "The wine cellar is filled wall to wall with the finest Lambrini and Echo Falls known to man. As you inspect the Lambrini closer, something shiny at the bottom catches your eye. ", "description": """The wine cellar is filled wall to wall with the finest Lambrini and Echo Falls known to man.
As you inspect the Lambrini closer, something shiny at the bottom catches your eye.""",
"exits": {"south": "entrance"}, "exits": {"south": "entrance"},
...@@ -86,7 +93,8 @@ location_winecellar = { ...@@ -86,7 +93,8 @@ location_winecellar = {
location_storage = { location_storage = {
"name": "Storage Room", "name": "Storage Room",
"description": "Infront of you a closet looms large but there are no handles to open the doors. Confused, you scan the room to see if there is anything else useful.", "description": """Infront of you a closet looms large but there are no handles to open the doors.
Confused, you scan the room to see if there is anything else useful.""",
"exits": {"north": "closet", "east": "entrance"}, "exits": {"north": "closet", "east": "entrance"},
...@@ -105,22 +113,25 @@ location_boileroom = { ...@@ -105,22 +113,25 @@ location_boileroom = {
} }
desk = { desk = {
"name": "desk", "name": "desk",
"description": "The desk is similar to the one in the other room, there are many drawers that could hold important items. Sure enough in one of the drawers there is a lock box that has a password. To unlock this box you must guess the word.", "description": """The desk is similar to the one in the other room, there are many drawers that could hold important items.
Sure enough in one of the drawers there is a lock box that has a password. To unlock this box you must guess the word.""",
"exits": {"north-west": "entrance"}, "exits": {"north-west": "entrance"},
"items": [] "items": []
} }
trap_door = { trap_door = {
"name": "trap door", "name": "trap door",
"description": "The trap door is locked! There is an electronic lock, you could use your key again but there is no guarantee it seems unlikely it will work again. The lock also seems to have no power. ", "description": """The trap door is locked!
There is an electronic lock, you could use your key again but there is no guarantee it seems unlikely it will work again. The lock also seems to have no power.""",
"exits": {"west": "entrance"}, "exits": {"west": "entrance"},
"open": False, "open": False,
"items": [item_lock] "items": [item_lock]
} }
closet = { closet = {
"name": "closet", "name": "closet",
"description": "You are amazed that the door is now mysteriously open, wondering how it happened you inspect it further. The closet is wooden with dusty shelves and old literary texts. There is a key card here as well.", "description": """You are amazed that the door is now mysteriously open, wondering how it happened you inspect it further.
The closet is wooden with dusty shelves and old literary texts. There is a key card here as well.""",
"open": False, "open": False,
"exits": {}, "exits": {"south": "storage room"},
"items": [key_card] "items": [key_card]
} }
locations = { locations = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment