Instantiate entity attributes in __init__ rather than in the class definition
This commit is contained in:
@ -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:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user