feat(game): 添加PUA激励台——AI评分打鸡血,触发攻击/攻速/HC/狂暴/翻车等游戏效果;移除静音按钮BGM默认开启

This commit is contained in:
Cloud Bot
2026-03-24 08:14:51 +00:00
parent e922c8fdf6
commit adda7ae57c
4 changed files with 558 additions and 95 deletions

View File

@@ -0,0 +1,71 @@
import { NextResponse } from 'next/server'
import { llmClient } from '@/app/api/llm-client'
const SYSTEM_PROMPT = `你是一个专门分析互联网大厂老板PUA话术的AI裁判。
用户输入一段老板/领导对员工说的"打鸡血"或"PUA"的话,你需要分析这段话并给出评分和游戏效果。
评分标准1-10分
1-3分废话/没营养("大家加油"之类)→ 轻微效果
4-6分标准大厂黑话"对齐""闭环""狼性")→ 中等效果
7-8分强力PUA"996是福报""不拼搏对不起父母")→ 强力效果
9-10分终极毒鸡汤极限施压/情感绑架)→ 全场爆发
只返回如下JSON不要其他内容
{
"score": 数字(1-10),
"title": "效果名称2-6个汉字有创意",
"desc": "对话语的一句话点评15字以内带点讽刺",
"effect": "attack_boost" | "speed_boost" | "money_rain" | "rage_mode" | "backfire"
}
effect说明
- attack_boost: 攻击力提升score 4-6
- speed_boost: 攻击速度提升score 7-8
- money_rain: HC暴增score 5-7话语中强调利益
- rage_mode: 全场狂暴score 9-10
- backfire: 话太废了反而debuffscore 1-2`
export async function POST(req: Request) {
try {
const { text } = await req.json()
if (!text || typeof text !== 'string' || text.trim().length < 2) {
return NextResponse.json({ error: '输入内容太短了' }, { status: 400 })
}
const resp = await llmClient.chat({
model: 'gpt-4o-mini',
messages: [
{ role: 'system', content: SYSTEM_PROMPT },
{ role: 'user', content: text.slice(0, 200) },
],
maxTokens: 150,
temperature: 0.7,
})
const raw = resp.choices?.[0]?.message?.content ?? ''
// 提取 JSON防止 LLM 多输出文字)
const match = raw.match(/\{[\s\S]*\}/)
if (!match) throw new Error('LLM 返回格式异常')
const result = JSON.parse(match[0])
const score = Math.max(1, Math.min(10, Number(result.score) || 5))
return NextResponse.json({
score,
title: result.title || '打鸡血',
desc: result.desc || '还行吧',
effect: result.effect || 'attack_boost',
})
} catch (e) {
console.error('[pua-score]', e)
// 降级:随机给个分数
const score = Math.floor(Math.random() * 7) + 3
return NextResponse.json({
score,
title: '随机鸡血',
desc: 'AI开小差了随机发力',
effect: 'attack_boost',
})
}
}