squirrel-battle/dungeonbattle/entities/items.py
2020-10-23 18:02:57 +02:00

34 lines
854 B
Python

from ..interfaces import Entity, FightingEntity
class Item(Entity):
held:bool
def __init__(self, *args, **kwargs):
super().__init__(self, *args, **kwargs)
self.held = False
def drop(self, x:int, y:int):
self.held = False
self.move(x, y)
def hold(self):
self.held = True
class Bomb(Item):
damage:int = 5
exploding:bool
def __init__(self, *args, **kwargs):
super().__init__(self, *args, **kwargs)
self.exploding = False
def drop(self, x:int, y:int):
super.drop(self, x, y)
self.exploding = True
def act(self, map):
if self.exploding:
for e in map.entities:
if abs (e.x - self.x) + abs (e.y - self.y) <= 1 and isinstance(e,FightingEntity):
e.take_damage(self, self.damage)