Go to file
hant 7308af1c1b Fix web state management: handleInput now returns structured data
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>
2025-12-07 13:14:48 +08:00
.idea Fix web state management: handleInput now returns structured data 2025-12-07 13:14:48 +08:00
bin 法术 2025-12-02 23:13:38 +08:00
src Fix web state management: handleInput now returns structured data 2025-12-07 13:14:48 +08:00
test Implement Server-Sent Events (SSE) for real-time battle streaming 2025-12-07 10:50:30 +08:00
web Fix web state management: handleInput now returns structured data 2025-12-07 13:14:48 +08:00
.DS_Store first 2025-12-05 09:38:15 +08:00
.gitignore 技能优化 2025-12-05 17:38:10 +08:00
box.json first 2025-12-01 18:13:15 +08:00
build-phar.php first 2025-12-01 18:13:15 +08:00
build.sh first 2025-12-01 18:13:15 +08:00
composer.json Implement WebSocket real-time communication for game 2025-12-07 12:21:30 +08:00
composer.lock Implement WebSocket real-time communication for game 2025-12-07 12:21:30 +08:00
save.json Implement WebSocket real-time communication for game 2025-12-07 12:21:30 +08:00
start-server.sh first 2025-12-01 18:13:15 +08:00
websocket-server.php Implement WebSocket real-time communication for game 2025-12-07 12:21:30 +08:00