32 lines
779 B
Python
32 lines
779 B
Python
from ..interfaces import FightingEntity
|
|
|
|
|
|
class Player(FightingEntity):
|
|
maxhealth = 20
|
|
strength = 5
|
|
|
|
def move_up(self) -> bool:
|
|
return self.check_move(self.y - 1, self.x, True)
|
|
|
|
def move_down(self) -> bool:
|
|
return self.check_move(self.y + 1, self.x, True)
|
|
|
|
def move_left(self) -> bool:
|
|
return self.check_move(self.y, self.x - 1, True)
|
|
|
|
def move_right(self) -> bool:
|
|
return self.check_move(self.y, self.x + 1, True)
|
|
|
|
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
|
|
self.level_up()
|