Ensure that the inventory is not empty before interacting with an item

This commit is contained in:
Yohann D'ANELLO 2020-12-04 17:01:00 +01:00
parent c7545e53f7
commit 056ca5cca8
1 changed files with 12 additions and 6 deletions

View File

@ -123,12 +123,18 @@ class Game:
self.inventory_menu.go_up() self.inventory_menu.go_up()
elif key == KeyValues.DOWN: elif key == KeyValues.DOWN:
self.inventory_menu.go_down() self.inventory_menu.go_down()
elif key == KeyValues.USE: if self.inventory_menu.values:
self.inventory_menu.validate().use() if key == KeyValues.USE:
elif key == KeyValues.EQUIP: self.inventory_menu.validate().use()
self.inventory_menu.validate().equip() elif key == KeyValues.EQUIP:
elif key == KeyValues.DROP: self.inventory_menu.validate().equip()
self.inventory_menu.validate().use() elif key == KeyValues.DROP:
self.inventory_menu.validate().use()
# Ensure that the cursor has a good position
self.inventory_menu.position = min(self.inventory_menu.position,
len(self.inventory_menu.values)
- 1)
def handle_key_pressed_main_menu(self, key: KeyValues) -> None: def handle_key_pressed_main_menu(self, key: KeyValues) -> None:
""" """