feat: add MMGame backend and frontend source code
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from app.agents.ai import dm_generate
|
||||
|
||||
|
||||
class DMAgent:
|
||||
def __init__(self, script: dict):
|
||||
self.script = script
|
||||
self.current_phase_index = 0
|
||||
self.released_clues = []
|
||||
|
||||
def get_opening(self) -> str:
|
||||
title = self.script["title"]
|
||||
bg = self.script.get("background", "")
|
||||
return f"欢迎来到【{title}】。{bg}"
|
||||
|
||||
async def act(self, phase_index: int, player_progress: str = "", context: str = "") -> dict:
|
||||
result = await dm_generate(self.script, phase_index, self.released_clues, context)
|
||||
if result:
|
||||
return result
|
||||
phases = self.script.get("phases", [])
|
||||
phase = phases[phase_index] if phase_index < len(phases) else phases[-1]
|
||||
return {"action": "narrate", "content": f"【{phase['name']}】{phase['description']}"}
|
||||
|
||||
def get_replay_summary(self) -> str:
|
||||
return f"剧本:{self.script['title']}\n真相:{self.script.get('truth', '')}"
|
||||
Reference in New Issue
Block a user