From f887a1f0aacbf5410073007d79111c92cdd5289e Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 5 Dec 2020 14:25:22 +0100 Subject: [PATCH] Entity name is a parameter since it can be changed through body snatch potion --- squirrelbattle/entities/items.py | 14 +++++++------- squirrelbattle/entities/monsters.py | 24 ++++++++++++------------ squirrelbattle/entities/player.py | 11 ++++++----- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 8953b39..943b0c8 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -67,8 +67,8 @@ class Heart(Item): """ healing: int - def __init__(self, healing: int = 5, *args, **kwargs): - super().__init__(name="heart", *args, **kwargs) + def __init__(self, name: str = "heart", healing: int = 5, *args, **kwargs): + super().__init__(name=name, *args, **kwargs) self.healing = healing def hold(self, player: "Player") -> None: @@ -96,9 +96,9 @@ class Bomb(Item): owner: Optional["Player"] tick: int - def __init__(self, damage: int = 5, exploding: bool = False, - *args, **kwargs): - super().__init__(name="bomb", *args, **kwargs) + def __init__(self, name: str = "bomb", damage: int = 5, + exploding: bool = False, *args, **kwargs): + super().__init__(name=name, *args, **kwargs) self.damage = damage self.exploding = exploding self.tick = 4 @@ -151,8 +151,8 @@ class BodySnatchPotion(Item): other entity. """ - def __init__(self, *args, **kwargs): - super().__init__(name="body_snatch_potion", *args, **kwargs) + def __init__(self, name: str = "body_snatch_potion", *args, **kwargs): + super().__init__(name=name, *args, **kwargs) def use(self) -> None: """ diff --git a/squirrelbattle/entities/monsters.py b/squirrelbattle/entities/monsters.py index 9c151ad..feff81a 100644 --- a/squirrelbattle/entities/monsters.py +++ b/squirrelbattle/entities/monsters.py @@ -63,9 +63,9 @@ class Tiger(Monster): """ A tiger monster """ - def __init__(self, strength: int = 2, maxhealth: int = 20, - *args, **kwargs) -> None: - super().__init__(name="tiger", strength=strength, + def __init__(self, name: str = "tiger", strength: int = 2, + maxhealth: int = 20, *args, **kwargs) -> None: + super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) @@ -73,9 +73,9 @@ class Hedgehog(Monster): """ A really mean hedgehog monster """ - def __init__(self, strength: int = 3, maxhealth: int = 10, - *args, **kwargs) -> None: - super().__init__(name="hedgehog", strength=strength, + def __init__(self, name: str = "hedgehog", strength: int = 3, + maxhealth: int = 10, *args, **kwargs) -> None: + super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) @@ -83,9 +83,9 @@ class Rabbit(Monster): """ A rabbit monster """ - def __init__(self, strength: int = 1, maxhealth: int = 15, - *args, **kwargs) -> None: - super().__init__(name="rabbit", strength=strength, + def __init__(self, name: str = "rabbit", strength: int = 1, + maxhealth: int = 15, *args, **kwargs) -> None: + super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) @@ -93,7 +93,7 @@ class TeddyBear(Monster): """ A cute teddybear monster """ - def __init__(self, strength: int = 0, maxhealth: int = 50, - *args, **kwargs) -> None: - super().__init__(name="teddy_bear", strength=strength, + def __init__(self, name: str = "teddy_bear", strength: int = 0, + maxhealth: int = 50, *args, **kwargs) -> None: + super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) diff --git a/squirrelbattle/entities/player.py b/squirrelbattle/entities/player.py index e452c8d..02a6d8c 100644 --- a/squirrelbattle/entities/player.py +++ b/squirrelbattle/entities/player.py @@ -16,11 +16,12 @@ class Player(FightingEntity): inventory: list paths: Dict[Tuple[int, int], Tuple[int, int]] - 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, + def __init__(self, name: str = "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, *args, **kwargs) \ + -> None: + super().__init__(name=name, maxhealth=maxhealth, strength=strength, intelligence=intelligence, charisma=charisma, dexterity=dexterity, constitution=constitution, level=level, *args, **kwargs)