Update Items so they can be equippable, create factories for equippable items
This commit is contained in:
parent
159beb98b2
commit
142950e474
@ -79,6 +79,7 @@ class ItemAction(Action):
|
|||||||
|
|
||||||
def perform(self) -> None:
|
def perform(self) -> None:
|
||||||
"""Invoke the item's ability, this action will be given to provide context."""
|
"""Invoke the item's ability, this action will be given to provide context."""
|
||||||
|
if self.item.consumable:
|
||||||
self.item.consumable.activate(self)
|
self.item.consumable.activate(self)
|
||||||
|
|
||||||
|
|
||||||
|
11
entity.py
11
entity.py
@ -9,6 +9,7 @@ from render_order import RenderOrder
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from components.ai import BaseAI
|
from components.ai import BaseAI
|
||||||
from components.consumable import Consumable
|
from components.consumable import Consumable
|
||||||
|
from components.equippable import Equippable
|
||||||
from components.fighter import Fighter
|
from components.fighter import Fighter
|
||||||
from components.inventory import Inventory
|
from components.inventory import Inventory
|
||||||
from components.level import Level
|
from components.level import Level
|
||||||
@ -134,7 +135,8 @@ class Item(Entity):
|
|||||||
char: str = "?",
|
char: str = "?",
|
||||||
color: Tuple[int, int, int] = (255, 255, 255),
|
color: Tuple[int, int, int] = (255, 255, 255),
|
||||||
name: str = "<Unamed>",
|
name: str = "<Unamed>",
|
||||||
consumable: Consumable,
|
consumable: Optional[Consumable] = None,
|
||||||
|
equippable: Optional[Equippable] = None,
|
||||||
):
|
):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
x=x,
|
x=x,
|
||||||
@ -147,4 +149,11 @@ class Item(Entity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.consumable = consumable
|
self.consumable = consumable
|
||||||
|
|
||||||
|
if self.consumable:
|
||||||
self.consumable.parent = self
|
self.consumable.parent = self
|
||||||
|
|
||||||
|
self.equippable = equippable
|
||||||
|
|
||||||
|
if self.equippable:
|
||||||
|
self.equippable.parent = self
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from components.ai import HostileEnemy
|
from components.ai import HostileEnemy
|
||||||
from components import consumable
|
from components import consumable, equippable
|
||||||
from components.fighter import Fighter
|
from components.fighter import Fighter
|
||||||
from components.inventory import Inventory
|
from components.inventory import Inventory
|
||||||
from components.level import Level
|
from components.level import Level
|
||||||
@ -58,3 +58,31 @@ lightning_scroll = Item(
|
|||||||
name="Lightning Scroll",
|
name="Lightning Scroll",
|
||||||
consumable=consumable.LightningDamageConsumable(damage=20, maximum_range=5),
|
consumable=consumable.LightningDamageConsumable(damage=20, maximum_range=5),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dagger = Item(
|
||||||
|
char="/",
|
||||||
|
color=(0, 191, 255),
|
||||||
|
name="Dagger",
|
||||||
|
equippable=equippable.Dagger(),
|
||||||
|
)
|
||||||
|
|
||||||
|
sword = Item(
|
||||||
|
char="/",
|
||||||
|
color=(0, 191, 244),
|
||||||
|
name="Sword",
|
||||||
|
equippable=equippable.Sword(),
|
||||||
|
)
|
||||||
|
|
||||||
|
leather_armor = Item(
|
||||||
|
char="[",
|
||||||
|
color=(139, 69, 19),
|
||||||
|
name="Leather Armor",
|
||||||
|
equippable=equippable.LeatherArmor(),
|
||||||
|
)
|
||||||
|
|
||||||
|
chain_mail = Item(
|
||||||
|
char="[",
|
||||||
|
color=(139, 69, 19),
|
||||||
|
name="Chain Mail",
|
||||||
|
equippable=equippable.ChainMail(),
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user