Files
mice/engine/state_machine.py
T
enne2 486cd6b7c5 Add non-regression test states and Bluetooth diagnostic script
- Introduced a new JSON file containing non-regression test states with detailed unit information, including positions, ages, and movement directions across multiple frames.
- Added a shell script for Bluetooth diagnostics that checks system information, Bluetooth binaries, running processes, D-Bus status, Bluetooth controller details, and audio stack status, providing a comprehensive overview for troubleshooting.
2026-05-17 23:36:24 +02:00

43 lines
1.6 KiB
Python

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()