diff --git a/Group_game/game.py b/Group_game/game.py index 7034af0ab15a6fdaf93da03b5f79e9fcd31753fd..e2659f3ce1d9d639eddd0acc447d08a9abca7e1b 100644 --- a/Group_game/game.py +++ b/Group_game/game.py @@ -4,6 +4,7 @@ from player import * from gameparser import * from datetime import datetime from items import * +from level_1 import * start_time = "" @@ -58,21 +59,25 @@ def print_menu(exits, room_items, inv_items): # Print the exit name and where it leads to print_exit(direction, exit_leads_to(exits, direction)) 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: print("DROP", items["id"], "to drop", items["name"] + ".") for items in inv_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") if current_room == current_level["door"]: print("UNLOCK DOOR to attempt to unlock the escape door") - - # - # COMPLETE ME! - # - + if item_note in inv_items: + print("READ NOTE to read the hidden note") + 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?") @@ -99,7 +104,6 @@ def execute_take(item_id): found = True if not found: - print(current_room["items"]) print("You cannot take that.") @@ -115,18 +119,17 @@ def execute_drop(item_id): print("You cannot drop that.") -def execute_open(item_id): - found = False - x = "" - for items in inventory: - if items["id"] == item_id: - print("You opened the", item_id, "and found", items["open"]["name"]) - x = items["open"] - found = True - if found: - inventory.append(x) + +def unlock_door(): + if current_room["name"] == "Escape door": + if item_key in inventory: + print("WELL DONE! You've escaped",current_level) + else: + print("You need a key to open the door") else: - print("You cannot open that.") + print("There is no door to open") + + def check_timer(): @@ -160,25 +163,39 @@ def execute_command(command): else: print("Drop what?") - # elif command[0] == "read": - # if len(command) > 1: - # execute_read(command[1]) - # else: - # print("read what?") + elif command[0] == "read": + if command[1] == "note": + read_note() + else: + print("read what?") elif command[0] == "open": - if len(command) > 1: - execute_open(command[1]) + if command[1] == "diary": + open_diary() + elif command[1] == "safe": + open_safe() else: - print("check what?") + print("open what?") elif command[0] == "check": if command[1] == "timer": check_timer() else: print("Check what?") - else: - print("This makes no sense.") + elif command[0] == "unlock": + 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): diff --git a/Group_game/items.py b/Group_game/items.py index 6b1b17b847706dd99d5ea8437c16754f993ea8a7..742664a145eb3a19fbb57b5c7b31862974900595 100644 --- a/Group_game/items.py +++ b/Group_game/items.py @@ -1,28 +1,29 @@ +item_battery = { + "id": "battery", + + "name": "a pair of batteries", + "description": "(no description)", + "pick-up": True +} item_safe = { "id": "safe", "name": "a secure safe", - "description": "(no description)" -} - -item_battery = { - "id": "battery", - - "name": "a pair of batteries", + "description": "(no description)", + "pick-up": False, + "open": False - "description": "(no description)" } - item_note = { "id": "note", "name": "a hidden note", - "description": "(no description)" - # "read": read_note() + "description": "(no description)", + "pick-up": True } item_key = { @@ -30,7 +31,8 @@ item_key = { "name": "a key", - "description": "(no description)." + "description": "(no description).", + "pick-up": True } item_torch = { @@ -38,7 +40,8 @@ item_torch = { "name": "a torch", - "description": "(no description)" + "description": "(no description)", + "pick-up": True } item_diary = { @@ -47,5 +50,6 @@ item_diary = { "name": "a personal diary", "description": "(no description)", - "open": item_note + "pick-up": True, + "open": False } \ No newline at end of file diff --git a/Group_game/level_1.py b/Group_game/level_1.py new file mode 100644 index 0000000000000000000000000000000000000000..aab0d040dfbce3d8031f8f9aa87181ac597d4f3f --- /dev/null +++ b/Group_game/level_1.py @@ -0,0 +1,42 @@ +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") diff --git a/Group_game/map.py b/Group_game/map.py index f2ee264d02ac96cc6f6e741b423f7a4db4a44f2c..0f119efa6b5192d677e7b9667a1019153bc7047b 100644 --- a/Group_game/map.py +++ b/Group_game/map.py @@ -7,7 +7,7 @@ location_centre = { "exits": {"south": "fireplace", "west": "bookshelf", "north": "door", "north-east": "desk", "south-east": "dark corner"}, - "items": [item_torch] + "items": [] } location_Fireplace = { @@ -17,7 +17,7 @@ location_Fireplace = { "exits": {"north": "centre", "east": "Dark corner"}, - "items": [item_safe] + "items": [item_torch] } location_bookshelf = { @@ -37,7 +37,7 @@ Location_desk = { "exits": {"west": "door", "south- west": "centre", "west" : "dark corner"}, - "items": [item_battery] + "items": [item_safe] } location_dark_corner = {