Fix removing item from inventory

This commit is contained in:
Matyáš Caras 2022-04-17 19:02:11 +02:00
parent b347fd7585
commit 3251dbe4a6
2 changed files with 3 additions and 3 deletions

4
.vscode/launch.json vendored
View file

@ -9,8 +9,8 @@
"type": "python", "type": "python",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/__main__.py", "program": "${workspaceFolder}/__main__.py",
"console": "integratedTerminal", "console": "externalTerminal",
"justMyCode": true "justMyCode": true,
} }
] ]
} }

View file

@ -107,7 +107,7 @@ class Game: # the game class keeps information about the loaded game
# TODO: Remove item from inventory after using it? # 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 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) 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]: for item in need_item[m.selected]:
self.inventory.remove(item) self.inventory.remove(item)
else: else: