Issues fixed:
- GameSession.handleInput() was returning plain text, causing WebSocket frontend
to lose state information after each input
- GameWebSocketServer.handleGameInput() was calling unnecessary getStateInfo()
- Duplicate state saves in runCurrentState() and handleInput()
Changes:
1. GameSession.php:
- handleInput() now returns structured array with output + state info
- runCurrentState() no longer saves state (already done in handleInput)
- Consistent return format: { output, state, stateName, playerInfo }
2. GameWebSocketServer.php:
- handleGameInput() simplified to use handleInput() return value
- Direct merge of result into WebSocket message
3. web/server.php:
- handleGameInput() simplified to just return handleInput() result
- No duplicate getStateInfo() call
Results:
- Web frontend now receives complete state info after each input
- State transitions in submenus now work correctly
- No more state desynchronization between client and server
Testing:
- Input in level 3+ menus now executes correctly
- State name updates properly in header
- Player info (HP, etc) stays synchronized
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>