2020-10-23 16:02:57 +00:00
|
|
|
from ..interfaces import Entity, FightingEntity
|
2020-10-23 14:51:48 +00:00
|
|
|
|
|
|
|
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
|
2020-10-23 16:02:57 +00:00
|
|
|
|
|
|
|
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)
|