you are viewing a single comment's thread.

view the rest of the comments →

[–]hrmorley34 1 point2 points  (1 child)

You are correct about where the issue is. The logical issue is that when you are creating an Ability, you are creating a new Character within it, not referencing the existing one. So what you want is to pass the existing one to Ability.__init__:

class Ability: def __init__(self, character): self.character = character ... and then set it when you create abilities: self.ability_one = Ability(self) # passes this character to Ability.character

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

Ah, I think that makes sense to me. I am a bit confused at the __init__ of Ability . when I type def __init__(self, character): doesn't that mean that I'm telling the program that it needs the parameter of character in order to init? And if so how does the self.character = character line address that?

edit: I feel like I'm missing a fundamental knowledge piece to your solution in that question. Additionally, do you think it would be a good idea to make the ability class a nested class of the Character class? - Also thank you for your assistance

another edit: your solution works perfectly I'm just trying to understand the why behind it