diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index 6c4d991..4e08436 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -172,6 +172,7 @@ class PlayerInventoryDisplay(MenuDisplay): and self.selected else f" {rep} " self.addstr(self.pad, i + 1, 0, selection + " " + item.translated_name.capitalize() + + (f" ({item.description})" if item.description else "") + (": " + str(item.price) + " Hazels" if self.store_mode else "")) @@ -217,6 +218,7 @@ class StoreInventoryDisplay(MenuDisplay): and self.selected else f" {rep} " self.addstr(self.pad, i + 1, 0, selection + " " + item.translated_name.capitalize() + + (f" ({item.description})" if item.description else "") + ": " + str(item.price) + " Hazels") price = f"{self.pack.HAZELNUT} {self.menu.merchant.hazel} Hazels" diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 0436e37..9828fb6 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -24,6 +24,13 @@ class Item(Entity): self.held_by = held_by self.price = price + @property + def description(self) -> str: + """ + In the inventory, indicate the usefulness of the item. + """ + return "" + def drop(self) -> None: """ The item is dropped from the inventory onto the floor. @@ -109,6 +116,10 @@ class Heart(Item): super().__init__(name=name, price=price, *args, **kwargs) self.healing = healing + @property + def description(self) -> str: + return "HP+5" + def hold(self, entity: InventoryHolder) -> None: """ When holding a heart, the player is healed and @@ -217,6 +228,10 @@ class Weapon(Item): super().__init__(*args, **kwargs) self.damage = damage + @property + def description(self) -> str: + return f"STR+{self.damage}" if self.damage else super().description + def save_state(self) -> dict: """ Saves the state of the weapon into a dictionary @@ -261,6 +276,11 @@ class Armor(Item): super().__init__(*args, **kwargs) self.constitution = constitution + @property + def description(self) -> str: + return f"CON+{self.constitution}" if self.constitution \ + else super().description + def equip(self) -> None: super().equip() self.held_by.constitution += self.constitution @@ -375,6 +395,14 @@ class Ring(Item): self.critical = critical self.experience = experience + @property + def description(self) -> str: + fields = [("MAX HP", self.maxhealth), ("STR", self.strength), + ("INT", self.intelligence), ("CHR", self.charisma), + ("DEX", self.dexterity), ("CON", self.constitution), + ("CRI", self.critical), ("XP", self.experience)] + return ", ".join(f"{key}+{value}" for key, value in fields if value) + def equip(self) -> None: super().equip() self.held_by.maxhealth += self.maxhealth