Spawn new entities on each level (will be removed, only for tests)
This commit is contained in:
parent
c5e6459d37
commit
6e8cfdcb1a
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue