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:
@@ -74,6 +74,18 @@ class TwitchBot(commands.Bot):
|
||||
# Log the message for debugging
|
||||
logger.info(f"Twitch chat [{username}]: {content}")
|
||||
|
||||
# Phase 9: Check for vote commands first (!1, !2, !A, !B)
|
||||
vote_index = self._game_engine.parse_vote_command(content)
|
||||
if vote_index is not None:
|
||||
try:
|
||||
voted = await self._game_engine.process_vote(username, vote_index, "twitch")
|
||||
if voted:
|
||||
logger.info(f"Vote recorded: {username} -> option {vote_index + 1}")
|
||||
return # Don't process as regular command
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing vote: {e}")
|
||||
return
|
||||
|
||||
# Forward to game engine for command processing
|
||||
try:
|
||||
await self._game_engine.process_command(username, content)
|
||||
|
||||
Reference in New Issue
Block a user