From 3251dbe4a67b4119bf44d67d76d02f3c14423617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Sun, 17 Apr 2022 19:02:11 +0200 Subject: [PATCH] Fix removing item from inventory --- .vscode/launch.json | 4 ++-- lib/game.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7a38d34..7c48476 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,8 +9,8 @@ "type": "python", "request": "launch", "program": "${workspaceFolder}/__main__.py", - "console": "integratedTerminal", - "justMyCode": true + "console": "externalTerminal", + "justMyCode": true, } ] } \ No newline at end of file diff --git a/lib/game.py b/lib/game.py index 04b8378..013d4d3 100644 --- a/lib/game.py +++ b/lib/game.py @@ -107,7 +107,7 @@ class Game: # the game class keeps information about the loaded game # TODO: Remove item from inventory after using it? while need_item[m.selected] != None and all(element not in self.inventory for element in need_item[m.selected]): # until user selects an available prompt, re-prompt again m = HasItemDialogue(actions_desc,self.parse_colors(self.nodes[self.current]["text"]),self.inventory,need_item) - if "has_item" in self.nodes[m.selected].keys(): + if m.selected <= len(actions_desc)-3 and "has_item" in self.nodes[self.nodes[self.current]["actions"][m.selected]].keys(): for item in need_item[m.selected]: self.inventory.remove(item) else: