From 53f7e98bdc98885ff689302873605a1af5000391 Mon Sep 17 00:00:00 2001
From: Ahmed Yusuf <yusufa7@cardiff.ac.uk>
Date: Tue, 25 Oct 2022 21:53:09 +0100
Subject: [PATCH] time reduction from wine and gas leakage

---
 Group_game/game.py    | 20 ++++++++++++++------
 Group_game/level_2.py |  8 ++++++--
 Group_game/map.py     |  5 +++--
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/Group_game/game.py b/Group_game/game.py
index 15cfca4..6b01160 100644
--- a/Group_game/game.py
+++ b/Group_game/game.py
@@ -12,6 +12,7 @@ start_time = ""
 global current_room
 global current_level
 gas_starttime = ""
+time_penalty = False
 
 def list_of_items(items):
     time.sleep(0.1)
@@ -225,12 +226,15 @@ def check_timer():
     current_time = datetime.now()
     time_taken = current_time - start_time
     time_left = 1200 - time_taken.total_seconds()
+    if time_penalty:
+        time_left = time_left - 300
     minutes = time_left//60
     seconds = time_left%60
     print("You have", round(minutes), "minutes and", round(seconds), "seconds")
 
 
 def execute_command(command):
+    global time_penalty
     if 0 == len(command):
         return
 
@@ -313,7 +317,9 @@ def execute_command(command):
             print("remove what?")
     elif command[0] == "drink":
         if command[1] == "wine":
-            drink_wine()
+            x = drink_wine()
+            if x == 3:
+                time_penalty = True
         else:
             print("drink what?")
     elif command[0] == "play":
@@ -356,24 +362,26 @@ def main():
         current_time = datetime.now()
         time_taken = current_time - start_time
         time_left = 1200 - time_taken.total_seconds()
+        if time_penalty:
+            time_left = time_left - 300
         if time_left < 0:
             print("Oh no! You ran out of time!")
             break
         if location_boileroom["valve_open"]:
             gastime = current_time - gas_starttime
-            gastime_left = 120 - gastime.total_seconds()
+            gastime_left = 180 - 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.)
-        if current_room == location_boileroom:
-            if not location_boileroom["entered"]:
+        if current_room == location_entrance:
+            if not location_entrance["entered"]:
                 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'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)
                 gas_starttime = datetime.now()
-                location_boileroom["entered"] = True
+                location_entrance["entered"] = True
 
         print_room(current_room)
         print_inventory_items(inventory)
diff --git a/Group_game/level_2.py b/Group_game/level_2.py
index ffca428..e8b9349 100644
--- a/Group_game/level_2.py
+++ b/Group_game/level_2.py
@@ -11,6 +11,7 @@ import time
 def drink_wine():
     # need to add time deduction
     counter = 0
+    x = ""
     while counter < 3:
         if counter < 1:
             time.sleep(1)
@@ -22,6 +23,7 @@ def drink_wine():
                 counter += 1
             else:
                 counter = 3
+                x = 1
         elif counter == 1:
             time.sleep(1)
             print()
@@ -33,6 +35,7 @@ def drink_wine():
                 counter += 1
             else:
                 counter = 3
+                x = 2
         else:
             time.sleep(1)
             print()
@@ -42,9 +45,10 @@ def drink_wine():
             print('...')
             counter += 1
             time.sleep(4)
+            x = 3
             # time_taken = time_taken - 360
             # remove wine from inventory
-    
+    return x
             
 
 def close_valve():
@@ -81,7 +85,7 @@ def use_battery_lock():
 def gas_timer(timer):
     current_time = datetime.now()
     time_taken = current_time - timer
-    time_left = 120 - time_taken.total_seconds()
+    time_left = 180 - time_taken.total_seconds()
     minutes = time_left//60
     seconds = time_left%60
     if time_left > 0:
diff --git a/Group_game/map.py b/Group_game/map.py
index 97fe2a6..8df17fd 100644
--- a/Group_game/map.py
+++ b/Group_game/map.py
@@ -71,7 +71,8 @@ location_entrance = {
 
     "exits": {"north": "wine cellar", "west": "storage room", "south": "boiler room", "east": "trap door", "south-east": "desk", "downstairs": "door"},
 
-    "items": []
+    "items": [],
+    "entered": False
 }
 location_winecellar = {
     "name": "Wine Cellar",
@@ -100,7 +101,7 @@ location_boileroom = {
 
     "items": [],
     "valve_open": False,
-    "entered": False
+
 }
 desk = {
     "name": "desk",
-- 
GitLab