diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index f9f8881..ed576ed 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -123,12 +123,18 @@ class Game: self.inventory_menu.go_up() elif key == KeyValues.DOWN: self.inventory_menu.go_down() - elif key == KeyValues.USE: - self.inventory_menu.validate().use() - elif key == KeyValues.EQUIP: - self.inventory_menu.validate().equip() - elif key == KeyValues.DROP: - self.inventory_menu.validate().use() + if self.inventory_menu.values: + if key == KeyValues.USE: + self.inventory_menu.validate().use() + elif key == KeyValues.EQUIP: + self.inventory_menu.validate().equip() + 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: """