Added a scroll object that deals damage based on the player intelligence. Related to #60
This commit is contained in:
parent
ea58d5b426
commit
5736c2300b
|
@ -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='📜',
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue