I’m trying to set up a movelist for a game I’m creating, and attempting to do this through nested classes to avoid repeating the need to define the name of the move, without activating it immediately.
class moveset:
def __init__(self,move_name):
self.name = name
class move:
def use_move(self,user,target):
user.attack(target)
move_list = [moveset("slash").move]
move_list[0].use_move(user,target)
I’m able to use the nested class without issue, however if I want to call the name of the move it appears undefined (move_list[0].name, or accessing self.name from the move class itself).
After some research I understand that nested classes are difficult in regards to accessing the outer class, however is there any way to have an initialized function for an outer class that inner classes can still access? I’m hoping to use nested classes so that I can create multiple moves and assign them elsewhere.
My apologies if anything is unclear, I’m still fairly inexperienced with Python.