from enum import Enum, auto class GameState(Enum): START_MENU = auto() PLAYING = auto() PAUSED = auto() GAME_OVER = auto() VICTORY = auto() class StateMachine: def __init__(self, game): self.game = game self.current_state = GameState.START_MENU def transition_to(self, new_state): print(f"[state] Transitioning from {self.current_state} to {new_state}") self.current_state = new_state # Sincronizzazione per compatibilità con KeyBindings e logica esistente if new_state == GameState.PLAYING: self.game.game_status = "game" self.game.menu_screen = None elif new_state == GameState.PAUSED: self.game.game_status = "paused" self.game.menu_screen = None elif new_state == GameState.START_MENU: self.game.game_status = "start_menu" self.game.menu_screen = "start" elif new_state in [GameState.GAME_OVER, GameState.VICTORY]: self.game.game_status = "paused" # Legacy status used for key handling in end screens self.game.menu_screen = None def update(self): # Dispatch alla logica originale ripristinata in MiceMaze/Graphics if self.current_state == GameState.START_MENU: self.game.graphics.render_start_menu() elif self.current_state == GameState.PAUSED: self.game.graphics.render_pause_menu() elif self.current_state in [GameState.GAME_OVER, GameState.VICTORY]: # Delega al metodo game_over originale che gestisce i dialoghi specifici self.game.game_over()