Added a scroll object that deals damage based on the player intelligence. Related to #60

This commit is contained in:
eichhornchen 2021-01-08 11:54:39 +01:00
parent ea58d5b426
commit 5736c2300b
3 changed files with 27 additions and 1 deletions

View File

@ -34,6 +34,7 @@ class TexturePack:
RABBIT: str RABBIT: str
RING_OF_CRITICAL_DAMAGE: str RING_OF_CRITICAL_DAMAGE: str
RING_OF_MORE_EXPERIENCE: str RING_OF_MORE_EXPERIENCE: str
SCROLL_OF_DAMAGE: str
SHIELD: str SHIELD: str
SUNFLOWER: str SUNFLOWER: str
SWORD: str SWORD: str
@ -95,6 +96,7 @@ TexturePack.ASCII_PACK = TexturePack(
TIGER='n', TIGER='n',
TRUMPET='/', TRUMPET='/',
WALL='#', WALL='#',
SCROLL_OF_DAMAGE=']',
) )
TexturePack.SQUIRREL_PACK = TexturePack( TexturePack.SQUIRREL_PACK = TexturePack(
@ -131,4 +133,5 @@ TexturePack.SQUIRREL_PACK = TexturePack(
TIGER='🐅', TIGER='🐅',
TRUMPET='🎺', TRUMPET='🎺',
WALL='🧱', WALL='🧱',
SCROLL_OF_DAMAGE='📜',
) )

View File

@ -422,3 +422,24 @@ class RingXP(Ring):
experience: float = 2, *args, **kwargs): experience: float = 2, *args, **kwargs):
super().__init__(name=name, price=price, experience=experience, super().__init__(name=name, price=price, experience=experience,
*args, **kwargs) *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)

View File

@ -629,7 +629,8 @@ class Entity:
from squirrelbattle.entities.friendly import Merchant, Sunflower, \ from squirrelbattle.entities.friendly import Merchant, Sunflower, \
Trumpet Trumpet
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \
Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP Heart, Sword, Shield, Chestplate, Helmet, RingCritical, RingXP, \
ScrollofDamage
return { return {
"Tiger": Tiger, "Tiger": Tiger,
"Bomb": Bomb, "Bomb": Bomb,
@ -649,6 +650,7 @@ class Entity:
"Helmet": Helmet, "Helmet": Helmet,
"RingCritical": RingCritical, "RingCritical": RingCritical,
"RingXP": RingXP, "RingXP": RingXP,
"ScrollofDamage": ScrollofDamage,
} }
def save_state(self) -> dict: def save_state(self) -> dict: