save code

This commit is contained in:
xsl
2026-05-24 12:35:35 +08:00
parent af3a23520d
commit b3384499e3
6 changed files with 121 additions and 167 deletions
+24 -7
View File
@@ -52,10 +52,10 @@ class GameEngine {
if (!el) return;
const H = {
idle: '',
notification: '单击 播放 · 双击 跳过',
ringing: '单击 接听 · 左滑 拒接',
notification: '单击 播放 · 双击/左滑 跳过',
ringing: '单击/右滑 接听 · 左滑/双击 拒接',
playing: '双击 跳过 · 长按 重播',
choosing: '→温暖 ←冷淡 ↑追问 ↓沉默',
choosing: '单击回应 · →温暖 ←冷淡 ↑追问 ↓沉默 · 双击跳过',
responding: '双击 跳过',
reacting: '双击 跳过',
paused: '单击 继续 · 三指点击 退出',
@@ -286,9 +286,13 @@ class GameEngine {
this._skipRequested = false;
// 文字消息(TTS 朗读)
// 文字消息(TTS 朗读,不可用时播放提示音
if (msg.type === 'wechat_text' && msg.text) {
await TTS.speak(msg.text);
const ok = await TTS.speak(msg.text);
if (!ok) {
SFX_UI.notify();
await sleep(600);
}
}
// 语音消息
else if (msg.audio?.length > 0) {
@@ -546,6 +550,9 @@ class GameEngine {
this._playMessage(this.currentMsg);
} else if (s === 'choosing') {
this._handleChoice('tap');
} else if (s === 'idle') {
SFX_UI.error();
Haptic.error();
}
}
@@ -598,6 +605,11 @@ class GameEngine {
this._skipChoice();
return;
}
if (s === 'idle') {
SFX_UI.error();
Haptic.error();
}
}
_onSwipe(dir) {
@@ -626,6 +638,11 @@ class GameEngine {
this._handleChoice(dir);
return;
}
if (s === 'idle') {
SFX_UI.error();
Haptic.error();
}
}
// ── 长按:重播 / 状态广播 ──
@@ -642,13 +659,13 @@ class GameEngine {
if (this.currentMsg.audio?.length > 0) {
this._playVoiceAsync(this.currentMsg.audio);
} else if (this.currentMsg.type === 'wechat_text' && this.currentMsg.text) {
TTS.speak(this.currentMsg.text);
TTS.speak(this.currentMsg.text).then(ok => { if (!ok) SFX_UI.notify(); });
}
return;
}
// idle/notification → 广播未读数
TTS.speak(`当前未读${this.vars.UNREAD}条消息`);
TTS.speak(`当前未读${this.vars.UNREAD}条消息`).then(ok => { if (!ok) SFX_UI.error(); });
}
// ── 暂停 ──