Commit Graph

7 Commits

Author SHA1 Message Date
cb4b955bca Implement Server-Sent Events (SSE) for real-time battle streaming
Redesign web battle system from buffered to streaming architecture:

Backend Changes:
- New SSEOutput class for real-time event streaming to clients
- GameSession::streamBattle() for SSE-based battle execution
- Enhanced Screen::delay() to support SSE timing and buffering modes
- New /api/game/battle-stream endpoint handling SSE connections

Frontend Changes:
- Enhanced sendInput() to detect battle command (input "1")
- New streamBattle() function using EventSource for SSE connections
- Real-time log display matching terminal experience
- Event handlers for start, message, complete, error events

Benefits:
✓ Real-time streaming instead of waiting for complete battle
✓ Web frontend experience identical to terminal
✓ Lightweight implementation without WebSocket
✓ Automatic browser reconnection support
✓ ANSI colors fully preserved
✓ Backward compatible for non-battle screens

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 10:50:30 +08:00
0658960b70 优化 2025-12-06 22:59:52 +08:00
hantao
c77620127d 技能优化 2025-12-05 17:38:10 +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
c2a2e93ff3 优化 2025-12-04 23:52:50 +08:00
hantao
9d9af5f96c 逻辑优化 2025-12-04 18:11:28 +08:00
9a5eb6433f 优化 2025-12-03 23:41:55 +08:00