feat: implement AI Director & Narrative Voting System (Phase 9)

Add complete AI Director system that transforms the survival simulation
into a user-driven interactive story with audience voting.

Backend:
- Add DirectorService for LLM-powered plot generation with fallback templates
- Add VoteManager for dual-channel voting (Twitch + Unity)
- Integrate 4-phase game loop: Simulation → Narrative → Voting → Resolution
- Add vote command parsing (!1, !2, !A, !B) in Twitch service
- Add type-safe LLM output handling with _coerce_int() helper
- Normalize voter IDs for case-insensitive duplicate prevention

Unity Client:
- Add NarrativeUI for cinematic event cards and voting progress bars
- Add 7 new event types and data models for director/voting events
- Add delayed subscription coroutine for NetworkManager timing
- Sync client timer with server's remaining_seconds to prevent drift

Documentation:
- Update README.md with AI Director features, voting commands, and event types

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-02 03:37:41 +08:00
parent 93fed8b9ca
commit 8915a4b074
10 changed files with 2048 additions and 3 deletions

View File

@@ -66,6 +66,15 @@ class EventType(str, Enum):
VFX_EVENT = "vfx_event" # Visual effect trigger
GIFT_EFFECT = "gift_effect" # Twitch bits/sub effect
# AI Director & Narrative Voting (Phase 9)
MODE_CHANGE = "mode_change" # Game mode transition
NARRATIVE_PLOT = "narrative_plot" # Director generated plot point
VOTE_STARTED = "vote_started" # Voting session started
VOTE_UPDATE = "vote_update" # Real-time vote count update
VOTE_ENDED = "vote_ended" # Voting closed
VOTE_RESULT = "vote_result" # Final voting result
RESOLUTION_APPLIED = "resolution_applied" # Plot resolution executed
class GameEvent(BaseModel):
"""