Dead is an entity property
This commit is contained in:
parent
6f9317fbc2
commit
61969c46e6
|
@ -312,7 +312,6 @@ class FightingEntity(Entity):
|
||||||
maxhealth: int
|
maxhealth: int
|
||||||
health: int
|
health: int
|
||||||
strength: int
|
strength: int
|
||||||
dead: bool
|
|
||||||
intelligence: int
|
intelligence: int
|
||||||
charisma: int
|
charisma: int
|
||||||
dexterity: int
|
dexterity: int
|
||||||
|
@ -322,16 +321,17 @@ class FightingEntity(Entity):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.health = self.maxhealth
|
self.health = self.maxhealth
|
||||||
self.dead = False
|
|
||||||
self.health = 0
|
self.health = 0
|
||||||
self.strength = 0
|
self.strength = 0
|
||||||
self.dead = False
|
|
||||||
self.intelligence = 0
|
self.intelligence = 0
|
||||||
self.charisma = 0
|
self.charisma = 0
|
||||||
self.dexterity = 0
|
self.dexterity = 0
|
||||||
self.constitution = 0
|
self.constitution = 0
|
||||||
self.level = 1
|
self.level = 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dead(self) -> bool:
|
||||||
|
return self.health <= 0
|
||||||
|
|
||||||
def hit(self, opponent: "FightingEntity") -> None:
|
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
|
If a fighting entity has no more health, it dies and is removed
|
||||||
"""
|
"""
|
||||||
self.dead = True
|
|
||||||
self.map.remove_entity(self)
|
self.map.remove_entity(self)
|
||||||
|
|
||||||
def keys(self) -> list:
|
def keys(self) -> list:
|
||||||
|
@ -371,8 +370,8 @@ class FightingEntity(Entity):
|
||||||
|
|
||||||
def recover_state(self, d : dict) -> None:
|
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)
|
super().recover_state(d)
|
||||||
for name in d.keys():
|
for name in d.keys():
|
||||||
self.__setattribute__(name, d[name])
|
setattr(self, name, d[name])
|
||||||
|
|
Loading…
Reference in New Issue