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

some more changes

parent 1d9a4e03
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ from player import * ...@@ -4,6 +4,7 @@ from player import *
from gameparser import * from gameparser import *
from datetime import datetime from datetime import datetime
from items import * from items import *
from level_1 import *
start_time = "" start_time = ""
...@@ -58,21 +59,25 @@ def print_menu(exits, room_items, inv_items): ...@@ -58,21 +59,25 @@ def print_menu(exits, room_items, inv_items):
# Print the exit name and where it leads to # Print the exit name and where it leads to
print_exit(direction, exit_leads_to(exits, direction)) print_exit(direction, exit_leads_to(exits, direction))
for items in room_items: for items in room_items:
print("TAKE", items["id"], "to take", items["name"] + ".") if items["pick-up"]:
print("TAKE", items["id"], "to take", items["name"] + ".")
for items in inv_items: for items in inv_items:
print("DROP", items["id"], "to drop", items["name"] + ".") print("DROP", items["id"], "to drop", items["name"] + ".")
for items in inv_items: for items in inv_items:
if "open" in items: if "open" in items:
print("OPEN", items["id"], "to open", items["name"] + ".") if not items["open"]:
print("OPEN", items["id"], "to open", items["name"] + ".")
print("CHECK TIMER to check the time remaining") print("CHECK TIMER to check the time remaining")
if current_room == current_level["door"]: if current_room == current_level["door"]:
print("UNLOCK DOOR to attempt to unlock the escape door") print("UNLOCK DOOR to attempt to unlock the escape door")
if item_note in inv_items:
# print("READ NOTE to read the hidden note")
# COMPLETE ME! if item_safe in room_items:
# if not item_safe["open"]:
print("OPEN SAFE to attempt to open the safe")
else:
"You've already opened the safe"
print("What do you want to do?") print("What do you want to do?")
...@@ -99,7 +104,6 @@ def execute_take(item_id): ...@@ -99,7 +104,6 @@ def execute_take(item_id):
found = True found = True
if not found: if not found:
print(current_room["items"])
print("You cannot take that.") print("You cannot take that.")
...@@ -115,18 +119,17 @@ def execute_drop(item_id): ...@@ -115,18 +119,17 @@ def execute_drop(item_id):
print("You cannot drop that.") print("You cannot drop that.")
def execute_open(item_id):
found = False def unlock_door():
x = "" if current_room["name"] == "Escape door":
for items in inventory: if item_key in inventory:
if items["id"] == item_id: print("WELL DONE! You've escaped",current_level)
print("You opened the", item_id, "and found", items["open"]["name"]) else:
x = items["open"] print("You need a key to open the door")
found = True
if found:
inventory.append(x)
else: else:
print("You cannot open that.") print("There is no door to open")
def check_timer(): def check_timer():
...@@ -160,25 +163,39 @@ def execute_command(command): ...@@ -160,25 +163,39 @@ def execute_command(command):
else: else:
print("Drop what?") print("Drop what?")
# elif command[0] == "read": elif command[0] == "read":
# if len(command) > 1: if command[1] == "note":
# execute_read(command[1]) read_note()
# else: else:
# print("read what?") print("read what?")
elif command[0] == "open": elif command[0] == "open":
if len(command) > 1: if command[1] == "diary":
execute_open(command[1]) open_diary()
elif command[1] == "safe":
open_safe()
else: else:
print("check what?") print("open what?")
elif command[0] == "check": elif command[0] == "check":
if command[1] == "timer": if command[1] == "timer":
check_timer() check_timer()
else: else:
print("Check what?") print("Check what?")
else: elif command[0] == "unlock":
print("This makes no sense.") if command[1] == "door":
unlock_door()
else:
print("unlock what?")
# elif command[0] == "use":
# if command[1] == "battery":
# use_battery()
# if command[1] == "battery":
# use_torch()
# else:
# print("use what?")
# else:
# print("This makes no sense.")
def menu(exits, room_items, inv_items): def menu(exits, room_items, inv_items):
......
item_battery = {
"id": "battery",
"name": "a pair of batteries",
"description": "(no description)",
"pick-up": True
}
item_safe = { item_safe = {
"id": "safe", "id": "safe",
"name": "a secure safe", "name": "a secure safe",
"description": "(no description)" "description": "(no description)",
} "pick-up": False,
"open": False
item_battery = {
"id": "battery",
"name": "a pair of batteries",
"description": "(no description)"
} }
item_note = { item_note = {
"id": "note", "id": "note",
"name": "a hidden note", "name": "a hidden note",
"description": "(no description)" "description": "(no description)",
# "read": read_note() "pick-up": True
} }
item_key = { item_key = {
...@@ -30,7 +31,8 @@ item_key = { ...@@ -30,7 +31,8 @@ item_key = {
"name": "a key", "name": "a key",
"description": "(no description)." "description": "(no description).",
"pick-up": True
} }
item_torch = { item_torch = {
...@@ -38,7 +40,8 @@ item_torch = { ...@@ -38,7 +40,8 @@ item_torch = {
"name": "a torch", "name": "a torch",
"description": "(no description)" "description": "(no description)",
"pick-up": True
} }
item_diary = { item_diary = {
...@@ -47,5 +50,6 @@ item_diary = { ...@@ -47,5 +50,6 @@ item_diary = {
"name": "a personal diary", "name": "a personal diary",
"description": "(no description)", "description": "(no description)",
"open": item_note "pick-up": True,
"open": False
} }
\ No newline at end of file
from items import *
from player import *
def open_diary():
if item_diary in inventory:
print("You opened the diary and found a hidden note.")
inventory.append(item_note)
item_diary.update({"open": True})
else:
print("You cannot open that.")
def open_safe():
global safe_opened
print("To open this safe you need a passcode")
print("please enter the passcode")
passcode = input()
if passcode == "042":
print("THE PASSCODE WAS CORRECT!")
print("inside the safe you found a pair of batteries")
inventory.append(item_battery)
item_safe.update({"open": True})
def use_battery():
if item_battery in inventory:
if item_torch in inventory:
inventory.remove(item_battery)
inventory.remove(item_torch)
def read_note():
if item_note in inventory:
print("You read the note and notice a strange puzzle")
print("682 >> one digit is correct & well placed")
print("614 >> one digit is correct but wrong placed")
print("206 >> two numbers are correct but wrong placed")
print("738 >> nothing is correct")
print("870 >> one number is correct but wrong placed")
else:
print("There is no note to read")
...@@ -7,7 +7,7 @@ location_centre = { ...@@ -7,7 +7,7 @@ location_centre = {
"exits": {"south": "fireplace", "west": "bookshelf", "north": "door", "north-east": "desk", "south-east": "dark corner"}, "exits": {"south": "fireplace", "west": "bookshelf", "north": "door", "north-east": "desk", "south-east": "dark corner"},
"items": [item_torch] "items": []
} }
location_Fireplace = { location_Fireplace = {
...@@ -17,7 +17,7 @@ location_Fireplace = { ...@@ -17,7 +17,7 @@ location_Fireplace = {
"exits": {"north": "centre", "east": "Dark corner"}, "exits": {"north": "centre", "east": "Dark corner"},
"items": [item_safe] "items": [item_torch]
} }
location_bookshelf = { location_bookshelf = {
...@@ -37,7 +37,7 @@ Location_desk = { ...@@ -37,7 +37,7 @@ Location_desk = {
"exits": {"west": "door", "south- west": "centre", "west" : "dark corner"}, "exits": {"west": "door", "south- west": "centre", "west" : "dark corner"},
"items": [item_battery] "items": [item_safe]
} }
location_dark_corner = { location_dark_corner = {
......
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