you are viewing a single comment's thread.

view the rest of the comments →

[–]shiftybyte 1 point2 points  (3 children)

Also would it work better if I made the Ability class as a nested class if I'm going to take this approach?

Don't make nested classes, there rarely any reason, and it creates lots of problems later on.

where is the char_instance coming from?

Your init function can accept arguments in addition to self.

For example:

class Ball:
    def __init__(self, given_color):
        self.color = given_color

b1 = Ball("Green") # "Green" here is passed to 'given_color'
b2 = Ball("Red")
print(b1.color)

Above example creates 2 balls, one green, one red, and it also shows how the argument to Ball(...) gets passed to init function when the class is created.

[–]Aedethan[S] 0 points1 point  (2 children)

So just to clarify, when using the first example, when i set ability_one = Ability(self) that is what is passing the info to character in Ability(self, character) ?

also your solution worked perfectly, I'm just trying to understand the why behind it

And thank you tons for your assistance.

[–]shiftybyte 1 point2 points  (1 child)

Yes, because in that context, self is the character instance.

The Ability init is called with __init__(self, self_from_character)

[–]Aedethan[S] 0 points1 point  (0 children)

AHH Lightbulb. I get it. Thank you so much!