From a151f2f2937fce272eeccd2c38ffc782aff6a1fc Mon Sep 17 00:00:00 2001 From: chenlimao Date: Tue, 19 May 2026 18:16:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=AF=B9=E6=8A=97=E8=B5=9B?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=B8=89=E7=AE=ADx=E7=8E=AF=E9=9F=B3?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/team-battle.vue | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index 1a0b832..466319d 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -49,6 +49,8 @@ const battleWay = ref(0); const lastToSomeoneShootKey = ref(""); /** 控制设备离线提示弹窗的显示状态 */ const showOfflineModal = ref(false); +/** 记录每位玩家当前轮连续 X 环数,key 为 playerId,用于触发 tententen 音效 */ +const xRingStreaks = ref({}); /** * 监听设备在线状态,比赛进行中设备离线时弹窗提示用户 @@ -231,6 +233,27 @@ function onNewRound(msg, prevRound) { } } +/** + * 检测指定射手连续 X 环是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效 + * @param {number} shooterId - 本次射手的 ID(取自 currentShooterId.value) + * @param {boolean} isXRing - 本次射击是否为 X 环 + */ +function checkAndPlayTententen(shooterId, isXRing) { + if (!shooterId) return; + if (isXRing) { + xRingStreaks.value[shooterId] = (xRingStreaks.value[shooterId] || 0) + 1; + // 同一玩家连续 3 箭均为 X 环,追加到环数音效队列尾部播放 + if (xRingStreaks.value[shooterId] >= 3) { + xRingStreaks.value[shooterId] = 0; + // nextTick 确保 HeaderProgress 的环数播报已入队后再追加 tententen,避免播放顺序颠倒 + nextTick(() => audioManager.play("tententen", false)); + } + } else { + // 非 X 环则重置该玩家的连续计数 + xRingStreaks.value[shooterId] = 0; + } +} + async function onReceiveMessage(msg) { if (Array.isArray(msg)) return; if (msg.type === MESSAGETYPESV2.BattleStart) { @@ -245,6 +268,9 @@ async function onReceiveMessage(msg) { } else if (msg.type === MESSAGETYPESV2.ShootResult) { showRoundTip.value = false; recoverData(msg, {arrowOnly: true}); + // 检测同一玩家三箭全 X 环,触发 tententen 音效 + // currentShooterId 在 ToSomeoneShoot 时写入,ShootResult 不会覆盖,可靠识别本次射手 + checkAndPlayTententen(currentShooterId.value, !!(msg.shootData?.ringX && msg.shootData?.ring)); } else if (msg.type === MESSAGETYPESV2.NewRound) { // 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮 const prevRound = currentRound.value;