Dead is an entity property

This commit is contained in:
Yohann D'ANELLO 2020-11-18 14:29:54 +01:00
parent 6f9317fbc2
commit 61969c46e6

View File

@ -312,7 +312,6 @@ class FightingEntity(Entity):
maxhealth: int
health: int
strength: int
dead: bool
intelligence: int
charisma: int
dexterity: int
@ -322,16 +321,17 @@ class FightingEntity(Entity):
def __init__(self):
super().__init__()
self.health = self.maxhealth
self.dead = False
self.health = 0
self.strength = 0
self.dead = False
self.intelligence = 0
self.charisma = 0
self.dexterity = 0
self.constitution = 0
self.level = 1
@property
def dead(self) -> bool:
return self.health <= 0
def hit(self, opponent: "FightingEntity") -> None:
"""
@ -351,7 +351,6 @@ class FightingEntity(Entity):
"""
If a fighting entity has no more health, it dies and is removed
"""
self.dead = True
self.map.remove_entity(self)
def keys(self) -> list:
@ -371,8 +370,8 @@ class FightingEntity(Entity):
def recover_state(self, d : dict) -> None:
"""
Loads the state of an entity from a dictionnary
Loads the state of an entity from a dictionary
"""
super().recover_state(d)
for name in d.keys():
self.__setattribute__(name, d[name])
setattr(self, name, d[name])