Problem
In GameScreen.initialize_game() you set hero=Rogue() , but the Rogue constructor takes Rogue as an argument. (In other words, __init__ of Rogue requires passing Rogue .) You probably have the same problem if you set hero=Mage and hero=Barbarian .
Decision
Fortunately, the fix is ββsimple; you can simply change hero=Rogue() to hero=Rogue("MyRogueName") . Perhaps you can ask the user for a name in initialize_game , and then use that name.
Notes on "at least 2 arguments (1 given)"
When you see such errors, it means that you called a function or method without passing enough arguments to it. ( __init__ is a special method that is called when an object is initialized.) Therefore, when you debug things like this in the future, look where you call the function / method and where you define it, and make sure the two have the same number of parameters.
One thing that poses a difficult problem with such errors is self , which is passed in.
>>> class MyClass: ... def __init__(self): ... self.foo = 'foo' ... >>> myObj = MyClass()
In this example, you might think: "Strange, I initialized myObj , so MyClass.__init__ was called, why didnβt I have to pass something for self ?" The answer is that self effectively passed whenever the notation "object.method ()" is used. Hope this helps resolve the error and explains how to debug it in the future.
Matthew adams
source share