Skip to content
Snippets Groups Projects
Commit cb1ad634 authored by Morgan Diment's avatar Morgan Diment
Browse files
parents f1702055 53f7e98b
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ start_time = "" ...@@ -12,6 +12,7 @@ start_time = ""
global current_room global current_room
global current_level global current_level
gas_starttime = "" gas_starttime = ""
time_penalty = False
def list_of_items(items): def list_of_items(items):
time.sleep(0.1) time.sleep(0.1)
...@@ -227,12 +228,15 @@ def check_timer(): ...@@ -227,12 +228,15 @@ def check_timer():
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()
if time_penalty:
time_left = time_left - 300
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")
def execute_command(command): def execute_command(command):
global time_penalty
if 0 == len(command): if 0 == len(command):
return return
...@@ -317,7 +321,9 @@ def execute_command(command): ...@@ -317,7 +321,9 @@ def execute_command(command):
print("remove what?") print("remove what?")
elif command[0] == "drink": elif command[0] == "drink":
if command[1] == "wine": if command[1] == "wine":
drink_wine() x = drink_wine()
if x == 3:
time_penalty = True
else: else:
print("drink what?") print("drink what?")
elif command[0] == "play": elif command[0] == "play":
...@@ -360,24 +366,26 @@ def main(): ...@@ -360,24 +366,26 @@ def main():
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()
if time_penalty:
time_left = time_left - 300
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"]: if location_boileroom["valve_open"]:
gastime = current_time - gas_starttime gastime = current_time - gas_starttime
gastime_left = 120 - gastime.total_seconds() gastime_left = 180 - gastime.total_seconds()
if gastime_left < 0: if gastime_left < 0:
print("OH NO! the floor was filled with gas and you died") print("OH NO! the floor was filled with gas and you died")
break break
# Display game status (room description, inventory etc.) # Display game status (room description, inventory etc.)
if current_room == location_boileroom: if current_room == location_entrance:
if not location_boileroom["entered"]: if not location_entrance["entered"]:
location_boileroom["valve_open"] = True location_boileroom["valve_open"] = True
print("You immediately start hearing a high pitched hissing sound. You look around and see a valve needs to be closed. If only you had come sort of utensil to shut it.") print("You immediately start hearing a high pitched hissing sound. You look around and see a valve needs to be closed. If only you had come sort of utensil to shut it.")
print("You've got 2 minutes to close the valve before the room fills with gas") print("You've got 3 minutes to close the valve in the boiling room before the room fills with gas")
time.sleep(5) time.sleep(5)
gas_starttime = datetime.now() gas_starttime = datetime.now()
location_boileroom["entered"] = True location_entrance["entered"] = True
print_room(current_room) print_room(current_room)
print_inventory_items(inventory) print_inventory_items(inventory)
......
...@@ -11,6 +11,7 @@ import time ...@@ -11,6 +11,7 @@ import time
def drink_wine(): def drink_wine():
# need to add time deduction # need to add time deduction
counter = 0 counter = 0
x = ""
while counter < 3: while counter < 3:
if counter < 1: if counter < 1:
time.sleep(1) time.sleep(1)
...@@ -22,6 +23,7 @@ def drink_wine(): ...@@ -22,6 +23,7 @@ def drink_wine():
counter += 1 counter += 1
else: else:
counter = 3 counter = 3
x = 1
elif counter == 1: elif counter == 1:
time.sleep(1) time.sleep(1)
print() print()
...@@ -33,6 +35,7 @@ def drink_wine(): ...@@ -33,6 +35,7 @@ def drink_wine():
counter += 1 counter += 1
else: else:
counter = 3 counter = 3
x = 2
else: else:
time.sleep(1) time.sleep(1)
print() print()
...@@ -42,9 +45,10 @@ def drink_wine(): ...@@ -42,9 +45,10 @@ def drink_wine():
print('...') print('...')
counter += 1 counter += 1
time.sleep(4) time.sleep(4)
x = 3
# time_taken = time_taken - 360 # time_taken = time_taken - 360
# remove wine from inventory # remove wine from inventory
return x
def close_valve(): def close_valve():
...@@ -81,7 +85,7 @@ def use_battery_lock(): ...@@ -81,7 +85,7 @@ def use_battery_lock():
def gas_timer(timer): def gas_timer(timer):
current_time = datetime.now() current_time = datetime.now()
time_taken = current_time - timer time_taken = current_time - timer
time_left = 120 - time_taken.total_seconds() time_left = 180 - time_taken.total_seconds()
minutes = time_left//60 minutes = time_left//60
seconds = time_left%60 seconds = time_left%60
if time_left > 0: if time_left > 0:
......
...@@ -71,7 +71,8 @@ location_entrance = { ...@@ -71,7 +71,8 @@ location_entrance = {
"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"},
"items": [] "items": [],
"entered": False
} }
location_winecellar = { location_winecellar = {
"name": "Wine Cellar", "name": "Wine Cellar",
...@@ -100,7 +101,7 @@ location_boileroom = { ...@@ -100,7 +101,7 @@ location_boileroom = {
"items": [], "items": [],
"valve_open": False, "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