diff --git a/squirrelbattle/display/texturepack.py b/squirrelbattle/display/texturepack.py index 81302b3..80a20a3 100644 --- a/squirrelbattle/display/texturepack.py +++ b/squirrelbattle/display/texturepack.py @@ -34,6 +34,7 @@ class TexturePack: RABBIT: str RING_OF_CRITICAL_DAMAGE: str RING_OF_MORE_EXPERIENCE: str + SCROLL_OF_DAMAGE: str SHIELD: str SUNFLOWER: str SWORD: str @@ -95,6 +96,7 @@ TexturePack.ASCII_PACK = TexturePack( TIGER='n', TRUMPET='/', WALL='#', + SCROLL_OF_DAMAGE=']', ) TexturePack.SQUIRREL_PACK = TexturePack( @@ -131,4 +133,5 @@ TexturePack.SQUIRREL_PACK = TexturePack( TIGER='🐅', TRUMPET='🎺', WALL='🧱', + SCROLL_OF_DAMAGE='📜', ) diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 0436e37..6909fc8 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -422,3 +422,24 @@ class RingXP(Ring): experience: float = 2, *args, **kwargs): super().__init__(name=name, price=price, experience=experience, *args, **kwargs) + +class ScrollofDamage(Item): + """ + A scroll that, when used, deals damage to all entities in a certain radius. + """ + + def __init__(self, name: str = "scroll_of_damage", price: int = 18, + *args, **kwargs): + super().__init__(name=name, price=price, *args, **kwargs) + + def use(self) -> None: + """ + Find all entities within a radius of 5, and deal damage based on the + player's intelligence. + """ + for entity in self.held_by.map.entities: + if entity.is_fighting_entity() and not entity == self.held_by: + if entity.distance(self.held_by)<=5: + self.held_by.map.logs.add_message(entity.take_damage(\ + self.held_by, self.held_by.intelligence)) + self.held_by.inventory.remove(self) diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index f1f740b..1dff831 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -629,7 +629,8 @@ class Entity: from squirrelbattle.entities.friendly import Merchant, Sunflower, \ Trumpet from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ - Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP + Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \ + ScrollofDamage return { "Tiger": Tiger, "Bomb": Bomb, @@ -649,6 +650,7 @@ class Entity: "Helmet": Helmet, "RingCritical": RingCritical, "RingXP": RingXP, + "ScrollofDamage": ScrollofDamage, } def save_state(self) -> dict: