diff --git a/Group_game/game.py b/Group_game/game.py index d89fbfa51d010ca97b5a286e6fcd6f70c5b1464f..76898bbcd1754ce014b3ef9925337619e0a0d617 100644 --- a/Group_game/game.py +++ b/Group_game/game.py @@ -39,12 +39,11 @@ def print_inventory_items(items): def print_room(room): - time.sleep(0.5) # Display room name print() print(room["name"].upper()) print() - time.sleep(1.2) + time.sleep(0.5) # Display room description print(room["description"]) print() @@ -128,11 +127,12 @@ def print_menu(exits, room_items, inv_items): time.sleep(0.2) if current_room==desk: print("PLAY HANGMAN to play a game of hangman") - time.sleep(0.2) if current_room==trap_door and item_batteries in inventory: 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") + time.sleep(0.2) print("What do you want to do?") @@ -172,7 +172,6 @@ def execute_take(item_id): def execute_drop(item_id): - time.sleep(0.1) found = False for items in inventory: if items["id"] == item_id: @@ -182,6 +181,7 @@ def execute_drop(item_id): if not found: print("You cannot drop that.") + time.sleep(0.3) def time_taken(): @@ -212,7 +212,7 @@ def unlock_door(): current_room = locations["entrance"] start_time = datetime.now() 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 else: @@ -224,7 +224,6 @@ def unlock_door(): def check_timer(): - time.sleep(0.2) current_time = datetime.now() time_taken = current_time - start_time time_left = 1200 - time_taken.total_seconds() @@ -233,6 +232,8 @@ def check_timer(): minutes = time_left//60 seconds = time_left%60 print("You have", round(minutes), "minutes and", round(seconds), "seconds") + time.sleep(0.2) + def execute_command(command): @@ -269,8 +270,8 @@ def execute_command(command): open_diary(current_room["items"]) elif command[1] == "safe": open_safe(current_room["items"]) - elif command[1] == "trap door": - open_trapdoor() + elif command[1] == "trap" and command[2] == "door": + open_trapdoor(current_room) else: print("Open what?") @@ -300,7 +301,7 @@ def execute_command(command): if command[2] == "torch": use_battery_torch() elif command[2] == "lock": - use_battery_lock() + use_battery_lock(current_room) else: print("use batteries on what?") elif command[1] == "torch": @@ -330,7 +331,7 @@ def execute_command(command): if command[1] == "hangman": hangman("closet") else: - print("drink what?") + print("play what?") else: print("This makes no sense.") @@ -386,6 +387,10 @@ def main(): time.sleep(5) gas_starttime = datetime.now() location_entrance["entered"] = True + if trap_door["open"]: + print() + print("(game ending)") + break print_room(current_room) print_inventory_items(inventory) diff --git a/Group_game/level_2.py b/Group_game/level_2.py index c3a0ee195a198ceecb54154c91bd6762553ae2b6..982dcf0521a42aebbda1720e87dc482ce8fdb0c6 100644 --- a/Group_game/level_2.py +++ b/Group_game/level_2.py @@ -63,8 +63,8 @@ def close_valve(): -def open_trapdoor(): - if current_room == trap_door: +def open_trapdoor(room): + if room == trap_door: if item_lock["batteries"]: if key_card in inventory: trap_door["open"] = True @@ -72,10 +72,12 @@ def open_trapdoor(): print("You need a key card to open the lock.") else: print("The electrical lock requires batteries to open.") + else: + print("Command isn't available in this room") -def use_battery_lock(): - if current_room == trap_door: +def use_battery_lock(room): + if room == trap_door: if item_batteries in inventory: item_lock["batteries"] = True inventory.remove(item_batteries) diff --git a/Group_game/map.py b/Group_game/map.py index addd2dafed5c7db2d7fb6f6e7f5d21c6ffb3f031..49bdf68e77a217fd5fd1f8d002c1f968bcfef3cd 100644 --- a/Group_game/map.py +++ b/Group_game/map.py @@ -27,7 +27,8 @@ location_Fireplace = { location_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"}, @@ -37,7 +38,8 @@ location_bookshelf = { Location_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"}, @@ -47,7 +49,8 @@ Location_desk = { location_dark_corner = { "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"}, @@ -56,7 +59,8 @@ location_dark_corner = { location_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"}, "locked": True, @@ -66,8 +70,10 @@ location_door = { location_entrance = { "name": "level 2 Entrance", - "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.", + "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.""", "exits": {"north": "wine cellar", "west": "storage room", "south": "boiler room", "east": "trap door", "south-east": "desk", "downstairs": "door"}, @@ -77,7 +83,8 @@ location_entrance = { location_winecellar = { "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"}, @@ -86,7 +93,8 @@ location_winecellar = { location_storage = { "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"}, @@ -105,22 +113,25 @@ location_boileroom = { } 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"}, "items": [] } 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"}, "open": False, "items": [item_lock] } 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, - "exits": {}, + "exits": {"south": "storage room"}, "items": [key_card] } locations = {