diff --git a/Group_game/game.py b/Group_game/game.py index 68f020cee85ae5e096d0d3ae8654ca7bf89101f0..76bbf92a6e6934df1513fc206dcfb2795e08c0f7 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 7cdd48bb9a9e66be399f5af06d0f88a039bb0f7d..86fc5e60cb296f01bed3e415f3a706883907f52c 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")