From 0705441b8a35f529164cd93e5cce473a360276fc Mon Sep 17 00:00:00 2001 From: Cheri Dawn Date: Tue, 21 May 2024 23:35:44 +0300 Subject: [PATCH] even more bugfixing --- setage.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/setage.py b/setage.py index 96b0843..5d8735d 100755 --- a/setage.py +++ b/setage.py @@ -123,20 +123,34 @@ class SetageShell(Cmd): print(manifest["items"][arg]["examine"]) else: print("It doesn't seem to be all that interesting...") - elif "items" in cur_room: + elif arg: + if "items" not in cur_room and "interactables" not in cur_room: + print("> I don't see anything to examine here...") + return + no_items = False + if "items" in cur_room: + if len(cur_room["items"]) == 0: + no_items = True + no_interactables = False + if "interactables" in cur_room: + if len(cur_room["interactables"]) == 0: + no_interactables = True + if no_items and no_interactables: + print("> I don't see anything to examine here...") if arg in cur_room["items"].keys(): manifest["items"][arg]["hidden"] = False if "examine" in manifest["items"][arg]: print(manifest["items"][arg]["examine"]) else: print("It doesn't seem to be all that interesting...") - elif "interactables" in cur_room: - if arg in cur_room["interactables"].keys(): + elif arg in cur_room["interactables"].keys(): cur_room["interactables"][arg]["hidden"] = False if "examine" in cur_room["interactables"][arg]: print(cur_room["interactables"][arg]["examine"]) else: print("It doesn't seem to be all that interesting...") + else: + print("> I don't see anything like that...") else: print("> I don't see anything like that...") @@ -358,9 +372,18 @@ class SetageShell(Cmd): if arg == "": print("> What should I take?") return - elif arg in cur_room["items"].keys(): - inventory.append((arg, cur_room["items"].pop(arg))) - print(f"{arg} added to inventory.") + elif arg: + if "items" not in cur_room: + print("> I don't see anything that I could take...") + return + if len(cur_room["items"]) == 0: + print("> I don't see anything that I could take...") + return + if arg in cur_room["items"].keys(): + inventory.append((arg, cur_room["items"].pop(arg))) + print(f"{arg} added to inventory.") + else: + print("> I don't see anything like that...") else: print("> I don't see anything like that...") return self.check_win()