Skip to content

Commit

Permalink
Update input_handlers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EmperorPenguin18 committed Aug 11, 2021
1 parent 195a233 commit b8b851a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions input_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,15 @@ def on_render(self, console: tcod.Console) -> None:
if number_of_items_in_inventory > 0:
for i, item in enumerate(self.engine.player.inventory.items):
item_key = chr(ord("a") + i)
console.print(x + 1, y + i + 1, f"({item_key}) {item.name}")

is_equipped = self.engine.player.equipment.item_is_equipped(item)

item_string = f"({item_key}) {item.name}"

if is_equipped:
item_string = f"{item_string} (E)"

console.print(x + 1, y + i + 1, item_string)
else:
console.print(x + 1, y + 1, "(Empty)")

Expand Down Expand Up @@ -379,8 +387,13 @@ class InventoryActivateHandler(InventoryEventHandler):
TITLE = "Select an item to use"

def on_item_selected(self, item: Item) -> Optional[ActionOrHandler]:
"""Return the action for the selected item."""
return item.consumable.get_action(self.engine.player)
if item.consumable:
# Return the action for the selected item.
return item.consumable.get_action(self.engine.player)
elif item.equippable:
return actions.EquipAction(self.engine.player, item)
else:
return None


class InventoryDropHandler(InventoryEventHandler):
Expand Down

0 comments on commit b8b851a

Please sign in to comment.