Instantiate entity attributes in __init__ rather than in the class definition

This commit is contained in:
Yohann D'ANELLO
2020-11-18 14:54:21 +01:00
parent 61969c46e6
commit a6cd075b8c
4 changed files with 82 additions and 60 deletions

View File

@ -8,22 +8,23 @@ class Player(FightingEntity):
"""
The class of the player
"""
name = "player"
maxhealth: int = 20
strength: int = 5
intelligence: int = 1
charisma: int = 1
dexterity: int = 1
constitution: int = 1
level: int = 1
current_xp: int = 0
max_xp: int = 10
inventory: list
paths: Dict[Tuple[int, int], Tuple[int, int]]
def __init__(self):
super().__init__()
def __init__(self, maxhealth: int = 20, strength: int = 5,
intelligence: int = 1, charisma: int = 1, dexterity: int = 1,
constitution: int = 1, level: int = 1, current_xp: int = 0,
max_xp: int = 10, *args, **kwargs) -> None:
super().__init__(name="player", maxhealth=maxhealth, strength=strength,
intelligence=intelligence, charisma=charisma,
dexterity=dexterity, constitution=constitution,
level=level, *args, **kwargs)
self.current_xp = current_xp
self.max_xp = max_xp
self.inventory = list()
self.paths = dict()
def move(self, y: int, x: int) -> None:
"""