An example of item
This commit is contained in:
parent
343e107b86
commit
2ba7330ff5
|
@ -1,4 +1,4 @@
|
||||||
from ..interfaces import Entity
|
from ..interfaces import Entity, FightingEntity
|
||||||
|
|
||||||
class Item(Entity):
|
class Item(Entity):
|
||||||
held:bool
|
held:bool
|
||||||
|
@ -13,3 +13,21 @@ class Item(Entity):
|
||||||
|
|
||||||
def hold(self):
|
def hold(self):
|
||||||
self.held = True
|
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)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from ..interfaces import FightingEntity
|
from ..interfaces import FightingEntity
|
||||||
|
|
||||||
class Monster(FightingEntity):
|
class Monster(FightingEntity):
|
||||||
def behaviour(self, map):
|
def act(self, map):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Squirrel(Monster):
|
class Squirrel(Monster):
|
||||||
|
|
|
@ -72,6 +72,9 @@ class Entity:
|
||||||
def move(self, x: int, y: int) -> None:
|
def move(self, x: int, y: int) -> None:
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
|
|
||||||
|
def act(self, m:Map):
|
||||||
|
pass
|
||||||
|
|
||||||
class FightingEntity(Entity):
|
class FightingEntity(Entity):
|
||||||
maxhealth: int
|
maxhealth: int
|
||||||
|
|
Loading…
Reference in New Issue