Added a second scroll object closes #60

This commit is contained in:
eichhornchen
2021-01-08 16:14:40 +01:00
parent 5736c2300b
commit bde33e9232
4 changed files with 45 additions and 3 deletions

View File

@ -80,7 +80,8 @@ class Item(Entity):
Returns the list of all item classes.
"""
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\
Chestplate, Helmet, RingCritical, RingXP]
Chestplate, Helmet, RingCritical, RingXP, \
ScrollofDamage, ScrollofWeakening]
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
"""
@ -443,3 +444,25 @@ class ScrollofDamage(Item):
self.held_by.map.logs.add_message(entity.take_damage(\
self.held_by, self.held_by.intelligence))
self.held_by.inventory.remove(self)
class ScrollofWeakening(Item):
"""
A scroll that, when used, reduces the damage of the ennemies for 3 turn.
"""
def __init__(self, name: str = "scroll_of_weakening", price: int = 13,
*args, **kwargs):
super().__init__(name=name, price=price, *args, **kwargs)
def use(self) -> None:
"""
Find all entities and reduce their damage.
"""
for entity in self.held_by.map.entities:
if entity.is_fighting_entity(): #and not entity == self.held_by:
entity.strength = entity.strength - max(1, self.held_by.intelligence//2)
entity.effects.append(["strength", \
-max(1, self.held_by.intelligence//2), 3])
self.held_by.map.logs.add_message(\
_(f"The ennemies have -{max(1, self.held_by.intelligence//2)} strength for 3 turns"))
self.held_by.inventory.remove(self)

View File

@ -31,6 +31,7 @@ class Monster(FightingEntity):
By default, a monster will move randomly where it is possible
If the player is closeby, the monster runs to the player.
"""
super().act(m)
target = None
for entity in m.entities:
if self.distance_squared(entity) <= 25 and \