From d010e1324179c6cb524ac79160cff33d152a7a34 Mon Sep 17 00:00:00 2001
From: Ahmed Yusuf <yusufa7@cardiff.ac.uk>
Date: Sun, 23 Oct 2022 20:57:15 +0100
Subject: [PATCH] bug fixes

---
 Group_game/game.py    | 12 +++++++-----
 Group_game/level_1.py | 15 ++++++++-------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/Group_game/game.py b/Group_game/game.py
index 68f020c..76bbf92 100644
--- a/Group_game/game.py
+++ b/Group_game/game.py
@@ -106,10 +106,12 @@ def execute_take(item_id):
     found = False
     for items in current_room["items"]:
         if item_id == items["id"]:
-            inventory.append(items)
-            current_room["items"].remove(items)
             found = True
-
+            if len(inventory) < 3:
+                inventory.append(items)
+                current_room["items"].remove(items)
+            else:
+                print("Your inventory is full, Drop an item to free some space.")
     if not found:
         print("You cannot take that.")
 
@@ -193,9 +195,9 @@ def execute_command(command):
 
     elif command[0] == "open":
         if command[1] == "diary":
-            open_diary()
+            open_diary(current_room["items"])
         elif command[1] == "safe":
-            open_safe()
+            open_safe(current_room["items"])
         else:
             print("open what?")
 
diff --git a/Group_game/level_1.py b/Group_game/level_1.py
index 7cdd48b..86fc5e6 100644
--- a/Group_game/level_1.py
+++ b/Group_game/level_1.py
@@ -2,25 +2,28 @@ from items import *
 from player import *
 from map import *
 
-def open_diary():
+
+def open_diary(room_items):
     if item_diary in inventory:
         print("You opened the diary and found a hidden note.")
-        inventory.append(item_note)
+        room_items.append(item_note)
         item_diary.update({"open": True})
     else:
         print("You cannot open that.")
 
 
-def open_safe():
-    global safe_opened
+def open_safe(room_items):
     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_batteries)
+        room_items.append(item_batteries)
         item_safe.update({"open": True})
+    else:
+        print("you try the code", passcode, "but the safe wouldn't open")
+        print("TRY AGAIN")
 
 
 def use_battery():
@@ -35,9 +38,7 @@ def use_battery():
 
 def use_torch(room):
     if powered_torch in inventory:
-        print(room)
         if room == location_dark_corner:
-            print("true")
             room["items"].append(item_key)
         else:
             print("There is no use for the torch in this room")
-- 
GitLab