2020-10-23 14:17:48 +00:00
|
|
|
from ..interfaces import FightingEntity
|
2020-10-16 15:58:00 +00:00
|
|
|
|
2020-11-06 14:33:26 +00:00
|
|
|
|
2020-10-16 15:58:00 +00:00
|
|
|
class Player(FightingEntity):
|
2020-11-06 20:23:17 +00:00
|
|
|
maxhealth: int = 20
|
|
|
|
strength: int = 5
|
|
|
|
level: int = 1
|
|
|
|
current_xp: int = 0
|
|
|
|
max_xp: int = 10
|
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 16:48:47 +00:00
|
|
|
|
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 16:48:47 +00:00
|
|
|
|
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 16:48:47 +00:00
|
|
|
|
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 19:04:24 +00:00
|
|
|
|
2020-11-06 20:15:09 +00:00
|
|
|
def level_up(self) -> None:
|
2020-11-06 20:23:17 +00:00
|
|
|
while self.current_xp > self.max_xp:
|
2020-11-06 20:15:09 +00:00
|
|
|
self.level += 1
|
2020-11-06 20:23:17 +00:00
|
|
|
self.current_xp -= self.max_xp
|
2020-11-06 20:15:09 +00:00
|
|
|
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()
|