This commit is contained in:
Yohann D'ANELLO
2020-11-06 15:33:26 +01:00
parent e00d98739a
commit 8ccb74ea54
8 changed files with 83 additions and 63 deletions

View File

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

View File

@ -1,9 +1,11 @@
from ..interfaces import FightingEntity
from ..interfaces import FightingEntity, Map
class Monster(FightingEntity):
def act(self, map):
def act(self, map: Map) -> None:
pass
class Squirrel(Monster):
maxhealth = 10
strength = 3

View File

@ -1,5 +1,6 @@
from ..interfaces import FightingEntity
class Player(FightingEntity):
maxhealth = 20
strength = 5