Commit Graph

6 Commits

Author SHA1 Message Date
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
hantao
1e336cffcd Merge remote-tracking branch 'origin/main'
# Conflicts:
#	.idea/php.xml
2025-12-05 09:39:28 +08:00
hantao
2a4d3c08a5 first 2025-12-05 09:38:15 +08:00
0e6351d328 抽象:统一法术显示逻辑到 SpellDisplay.php
- ItemDisplay.php:移除 formatSpellCompact() 方法(已在 SpellDisplay 中实现)
- ItemDisplay.php:简化 renderSlot() 方法,移除法术特定逻辑
- ItemDisplay.php:更新 renderListItem() 注释,说明法术由 SpellDisplay 处理
- InventoryPanel.php:增强列表显示,对法术使用 SpellDisplay::formatSpellCompact()
- StatsPanel.php:技能槽位显示改用 SpellDisplay::renderSlot()

结果:
✓ 所有法术显示逻辑已集中到 SpellDisplay.php
✓ ItemDisplay.php 专注于装备显示逻辑
✓ 调用者正确路由:法术→SpellDisplay, 装备→ItemDisplay
✓ 保持向后兼容性,同时提高代码组织性

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 00:02:15 +08:00
9a5eb6433f 优化 2025-12-03 23:41:55 +08:00
hantao
0c6cbd669a first 2025-12-01 18:13:15 +08:00