squirrel-battle/dungeonbattle/entities/player.py

32 lines
779 B
Python
Raw Normal View History

from ..interfaces import FightingEntity
2020-11-06 14:33:26 +00:00
class Player(FightingEntity):
maxhealth = 20
strength = 5
2020-11-06 17:12:17 +00:00
2020-11-06 17:03:30 +00:00
def move_up(self) -> bool:
return self.check_move(self.y - 1, self.x, True)
2020-11-06 17:03:30 +00:00
def move_down(self) -> bool:
return self.check_move(self.y + 1, self.x, True)
2020-11-06 17:03:30 +00:00
def move_left(self) -> bool:
return self.check_move(self.y, self.x - 1, True)
2020-11-06 17:03:30 +00:00
def move_right(self) -> bool:
return self.check_move(self.y, self.x + 1, True)
2020-11-06 20:15:09 +00:00
current_xp: int
max_xp: int
def level_up(self) -> None:
if self.current_xp > self.max_xp:
self.level += 1
self.current_xp = 0
self.max_xp = self.level * 10
def add_xp(self, xp: int) -> None:
self.current_xp += xp
2020-11-06 17:12:17 +00:00
self.level_up()