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

boiler room gas leakage works

parent 829029d5
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ from level_2 import * ...@@ -10,6 +10,7 @@ from level_2 import *
start_time = "" start_time = ""
global current_room global current_room
global current_level global current_level
gas_starttime = ""
def list_of_items(items): def list_of_items(items):
new_list = "" new_list = ""
...@@ -72,7 +73,8 @@ def print_menu(exits, room_items, inv_items): ...@@ -72,7 +73,8 @@ def print_menu(exits, room_items, inv_items):
if "open" in items: if "open" in items:
if not items["open"]: if not items["open"]:
print("OPEN", items["id"], "to open", items["name"] + ".") print("OPEN", items["id"], "to open", items["name"] + ".")
print("CHECK TIMER to check the time remaining") if not location_boileroom["valve_open"]:
print("CHECK TIMER to check the time remaining")
if current_room == location_door and location_door["locked"]: if current_room == location_door and location_door["locked"]:
if current_level == "level 1": if current_level == "level 1":
print("UNLOCK DOOR to attempt to unlock the escape door") print("UNLOCK DOOR to attempt to unlock the escape door")
...@@ -91,6 +93,10 @@ def print_menu(exits, room_items, inv_items): ...@@ -91,6 +93,10 @@ def print_menu(exits, room_items, inv_items):
# print("USE BATTERIES for LOCK to place the batteries in the torch") # print("USE BATTERIES for LOCK to place the batteries in the torch")
if (powered_torch in inv_items) or (unpowered_torch in inv_items): if (powered_torch in inv_items) or (unpowered_torch in inv_items):
print("USE TORCH to use your torch") print("USE TORCH to use your torch")
if current_room == location_boileroom and location_boileroom["valve_open"]:
print("CLOSE valve to close the valve and stop the leakage")
if location_boileroom["valve_open"]:
print("CHECK GAS TIMER to see how long left before the room fills with gas")
print("What do you want to do?") print("What do you want to do?")
...@@ -218,8 +224,12 @@ def execute_command(command): ...@@ -218,8 +224,12 @@ def execute_command(command):
print("open what?") print("open what?")
elif command[0] == "check": elif command[0] == "check":
if command[1] == "timer": if len(command) > 1:
check_timer() if command[1] == "timer":
check_timer()
elif command[1] == "gas":
if location_boileroom["valve_open"]:
gas_timer(gas_starttime)
else: else:
print("Check what?") print("Check what?")
elif command[0] == "unlock": elif command[0] == "unlock":
...@@ -227,6 +237,11 @@ def execute_command(command): ...@@ -227,6 +237,11 @@ def execute_command(command):
unlock_door() unlock_door()
else: else:
print("unlock what?") print("unlock what?")
elif command[0] == "close":
if command[1] == "valve":
close_valve()
else:
print("unlock what?")
elif command[0] == "use": elif command[0] == "use":
if len(command) > 1: if len(command) > 1:
if command[1] == "batteries": if command[1] == "batteries":
...@@ -268,6 +283,7 @@ def move(exits, direction): ...@@ -268,6 +283,7 @@ def move(exits, direction):
def main(): def main():
global current_level global current_level
current_level = "level 1" current_level = "level 1"
global gas_starttime
global start_time global start_time
start_time = datetime.now() start_time = datetime.now()
# Main game loop # Main game loop
...@@ -278,7 +294,21 @@ def main(): ...@@ -278,7 +294,21 @@ def main():
if time_left < 0: if time_left < 0:
print("Oh no! You ran out of time!") print("Oh no! You ran out of time!")
break break
if location_boileroom["valve_open"]:
gastime = current_time - gas_starttime
gastime_left = 120 - gastime.total_seconds()
if gastime_left < 0:
print("OH NO! the floor was filled with gas and you died")
break
# Display game status (room description, inventory etc.) # Display game status (room description, inventory etc.)
if current_room == location_boileroom:
if not location_boileroom["entered"]:
location_boileroom["valve_open"] = True
print("(gas warning message 2 min)")
time.sleep(5)
gas_starttime = datetime.now()
location_boileroom["entered"] = True
print_room(current_room) print_room(current_room)
print_inventory_items(inventory) print_inventory_items(inventory)
......
...@@ -62,3 +62,11 @@ item_diary = { ...@@ -62,3 +62,11 @@ item_diary = {
"pick-up": True, "pick-up": True,
"open": False "open": False
} }
item_screwdriver = {
"id": "screwdriver",
"name": "a screwdriver",
"description": "()",
"pick-up": True
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ from operator import truediv ...@@ -3,6 +3,7 @@ from operator import truediv
from items import * from items import *
from player import * from player import *
from map import * from map import *
from datetime import datetime
from gameparser import * from gameparser import *
...@@ -23,15 +24,31 @@ def drink_wine(time_taken): ...@@ -23,15 +24,31 @@ def drink_wine(time_taken):
False False
def close_valve(): def close_valve():
pass if item_screwdriver in inventory:
if location_boileroom["valve_open"]:
location_boileroom["valve_open"] = False
print("Well done! You stopped the leakage")
else:
print("valve is closed")
else:
print("You need a screwdriver to close the valve")
def open_trapdoor(): def open_trapdoor():
pass pass
def hangman(): def play_hangman():
pass pass
def open_closet(): def open_closet():
pass pass
def use_battery_lock(): def use_battery_lock():
pass pass
\ No newline at end of file def gas_timer(timer):
current_time = datetime.now()
time_taken = current_time - timer
time_left = 120 - time_taken.total_seconds()
minutes = time_left//60
seconds = time_left%60
if time_left > 0:
print("You have", round(minutes), "minutes and", round(seconds), "seconds before the room fills with gas")
\ No newline at end of file
...@@ -10,7 +10,7 @@ Good luck you have 20 minutes!""", ...@@ -10,7 +10,7 @@ Good luck you have 20 minutes!""",
"exits": {"south": "fireplace", "west": "bookshelf", "north": "door", "north-east": "office desk", "south-east": "dark corner"}, "exits": {"south": "fireplace", "west": "bookshelf", "north": "door", "north-east": "office desk", "south-east": "dark corner"},
"items": [] "items": [item_screwdriver]
} }
location_Fireplace = { location_Fireplace = {
...@@ -97,7 +97,9 @@ location_boileroom = { ...@@ -97,7 +97,9 @@ location_boileroom = {
"exits": {"north": "entrance"}, "exits": {"north": "entrance"},
"items": [] "items": [],
"valve_open": False,
"entered": False
} }
desk = { desk = {
"name": "desk", "name": "desk",
......
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