Spawn new entities on each level (will be removed, only for tests)

This commit is contained in:
Yohann D'ANELLO 2020-11-11 01:07:19 +01:00
parent c5e6459d37
commit 6e8cfdcb1a
1 changed files with 9 additions and 0 deletions

View File

@ -24,13 +24,22 @@ class Player(FightingEntity):
self.map.currentx = x
def level_up(self) -> None:
"""
Add levels to the player as much as it is possible.
"""
while self.current_xp > self.max_xp:
self.level += 1
self.current_xp -= self.max_xp
self.max_xp = self.level * 10
self.health = self.maxhealth
# TODO Remove it, that's only fun
self.map.spawn_random_entities(randint(self.level, self.level * 5))
def add_xp(self, xp: int) -> None:
"""
Add some experience to the player.
If the required amount is reached, level up.
"""
self.current_xp += xp
self.level_up()