Fight other entities

This commit is contained in:
Yohann D'ANELLO
2020-11-11 00:50:47 +01:00
parent 5addd42535
commit 9909b12501
3 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,5 @@
from random import randint
from ..interfaces import FightingEntity
@ -26,7 +28,22 @@ class Player(FightingEntity):
self.level += 1
self.current_xp -= self.max_xp
self.max_xp = self.level * 10
self.health = self.maxhealth
def add_xp(self, xp: int) -> None:
self.current_xp += xp
self.level_up()
def fight(self) -> bool:
"""
Fight all f
"""
one_fight = False
for entity in self.map.entities:
if entity != self and isinstance(entity, FightingEntity) and\
self.distance_squared(entity) <= 1:
self.hit(entity)
one_fight = True
if entity.dead:
self.add_xp(randint(3, 7))
return one_fight