I'm currently working on a game in python with pyGame and want to use enums for the different states(gamestate, levelstate etc,) in the game.
I have inherited my own GameState class from Enum class as seen in the code below. I have the enum members set up (mainMenu, inGame etc...) and then put them into a list named allGameStates.
I get a problem when trying to iterate through the list containing all the gamestates in the setter function. I get:
AttributeError: 'GameState' object has no attribute 'allGameStates'
Also, while hovering over the list variable allGameStates it says:
inferred type: GameState
Shouldn't it be a list type?
class GameState(Enum):
    mainMenu = 'MainMenu'
    inGame = 'InGame'
    pause = 'Pause'
    exit = 'Exit'
    allGameStates = list([mainMenu, inGame, pause, exit])
    curgamestate = allGameStates[0]
    def __init__(self, newgamestate, *args):
        super().__init__(*args)
        self.gamestate = newgamestate
    @property
    def gamestate(self):
        """Gets the current game state"""
        return self.curgamestate
    @gamestate.setter
    def gamestate(self, state):
        """Sets the current game state to another"""
        try:
            for gamestates in self.allGameStates:
                if gamestates.name == state:
                    self.curgamestate = state
        except ValueError as err:
            print(err.args)
 
     
    