From 171b9b13c8fea2112c78260f6b8664161c796f9a Mon Sep 17 00:00:00 2001 From: Cheri Dawn Date: Sun, 1 Sep 2024 05:55:02 +0300 Subject: [PATCH] qol: take multiple items at once --- setage.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setage.py b/setage.py index 618b990..c17c73f 100755 --- a/setage.py +++ b/setage.py @@ -453,6 +453,19 @@ class SetageShell(Cmd): if arg == "": print("> What should I take?") return + elif len(arg.split(",")) > 1: + for item in [a.strip() for a in arg.split(",")]: + 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 item in cur_room["items"].keys(): + inventory.update({item: cur_room["items"].pop(item)}) + print(f"{item} added to inventory.") + else: + print("> I don't see anything like that...") elif arg: if "items" not in cur_room: print("> I don't see anything that I could take...") @@ -477,6 +490,7 @@ class SetageShell(Cmd): if not text: return list(items) else: + # FIXME: handle multiple items return [comp for comp in items if comp.startswith(text)] def do_inventory(self, arg):