I am trying to make a class with generic __init__ values, but have defaults for its subclasses, as so:
class Enemy:
def __init__(self, difficulty, power, MaxHP, magic, MaxMP, speed, name):
self.power = power + 2*difficulty
self.HP = self.MaxHP = MaxHP + 5*difficulty
self.magic = magic + 2* difficulty
self.MP = self.MaxMP = MaxMP + 5*difficulty
class Goblin(Enemy):
def __init_(self, difficulty = 1, power = 1, MaxHP = 5, magic = 1, MaxMP = 5, speed = 5, name = "Goblin"):
super(Goblin, self).__init__(self, power, MaxHP, magic, MaxMP, speed, name)
However, when I try to make a Goblin object without the full number of default values (like, I'll just put in a value for difficulty), it tells me I need the full 8 arguments even though the rest are given default values. Is there any reason I can't do that or am I doing something wrong here?
__init__. So you should copy and paste the code that is causing the problem. And the full traceback, too. Python's tracebacks are usually very helpful.