diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue
index f2448bd..0e0d407 100644
--- a/src/components/ShootProgress.vue
+++ b/src/components/ShootProgress.vue
@@ -157,6 +157,10 @@ async function onReceiveMessage(msg) {
key.push(arrow.ring ? `${arrow.ringX ? "X" : arrow.ring}环` : "未上靶");
if (arrow.angle)
key.push(`向${getDirectionText(arrow.angle)}调整`);
+ const shouldPlayTententen =
+ arrow.threeConsecutive10Rings === true ||
+ msg.shootData?.threeConsecutive10Rings === true;
+ if (!props.melee && shouldPlayTententen) key.push("tententen");
audioManager.play(key, false);
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
halfTime.value = true;
diff --git a/src/matchWebsocket.js b/src/matchWebsocket.js
index 9ce0746..cc0b803 100644
--- a/src/matchWebsocket.js
+++ b/src/matchWebsocket.js
@@ -310,6 +310,9 @@ function getShootResultAudioKeys(shootData) {
if (shootData.angle !== null && shootData.angle !== undefined) {
keys.push(`向${getDirectionText(shootData.angle)}调整`);
}
+ if (shootData.threeConsecutive10Rings === true) {
+ keys.push("tententen");
+ }
return keys;
}
diff --git a/src/pages/battle-room.vue b/src/pages/battle-room.vue
index 294823b..d711151 100644
--- a/src/pages/battle-room.vue
+++ b/src/pages/battle-room.vue
@@ -1,6 +1,6 @@
diff --git a/src/pages/melee-battle.vue b/src/pages/melee-battle.vue
index efb56d8..2cc71cc 100644
--- a/src/pages/melee-battle.vue
+++ b/src/pages/melee-battle.vue
@@ -52,8 +52,6 @@ const readyTime = ref(DEFAULT_READY_TIME);
let halfRestTimer = null;
/** 控制设备离线提示弹窗的显示状态 */
const showOfflineModal = ref(false);
-/** 记录每位玩家当前半场连续 10 环及以上次数,key 为 playerId,用于触发 tententen 音效 */
-const xRingStreaks = ref({});
let battleEnded = false;
let skipNextRestoreOnShow = false;
let restoreGeneration = 0;
@@ -319,7 +317,8 @@ function recoverData(battleInfo, { force = false } = {}) {
}
leaveHalfRest();
if (force) {
- const remain = (Date.now() - (battleInfo.current?.startTime || Date.now())) / 1000;
+ const ackTime = normalizeTimestamp(battleInfo.current?.ackTime);
+ const remain = ackTime ? Math.max(0, (Date.now() - ackTime) / 1000) : 0;
console.log(`当前轮已进行${remain}秒`);
if (remain > 0 && remain < 90) {
setTimeout(() => {
@@ -398,32 +397,6 @@ onLoad(async (options) => {
// });
});
-/**
- * 检测指定玩家连续 10 环及以上是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效
- * @param {number|string} playerId - 本次射手的 ID(大乱斗中 ShootResult 保留 playerId)
- * @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
- */
-function isTenPlusRing(shot) {
- return !!(shot?.ringX || Number(shot?.ring) >= 10);
-}
-
-function checkAndPlayTententen(playerId, isTenPlusRingShot) {
- if (!playerId) return;
- const id = parseInt(playerId);
- if (isTenPlusRingShot) {
- xRingStreaks.value[id] = (xRingStreaks.value[id] || 0) + 1;
- // 同一玩家连续 3 箭均为 10 环及以上,追加到环数音效队列尾部播放
- if (xRingStreaks.value[id] >= 3) {
- xRingStreaks.value[id] = 0;
- // nextTick 确保 HeaderProgress 的环数播报已入队后再追加 tententen,避免播放顺序颠倒
- nextTick(() => audioManager.play("tententen", false));
- }
- } else {
- // 低于 10 环或未上靶则重置该玩家的连续计数
- xRingStreaks.value[id] = 0;
- }
-}
-
async function onReceiveMessage(msg) {
if (Array.isArray(msg)) return;
if (msg.type === MESSAGETYPESV2.AboutToStart) {
@@ -432,28 +405,10 @@ async function onReceiveMessage(msg) {
leaveHalfRest();
recoverData(msg);
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
- // 更新前快照各玩家本轮已射箭数,用于事后识别本次射手
- const curRound = playersScores.value[playersScores.value.length - 1] || {};
- const prevCounts = {};
- for (const pid of Object.keys(curRound)) {
- prevCounts[pid] = (curRound[pid] || []).length;
- }
recoverData(msg);
- // 对比更新后数据找出箭数增加的玩家(即本次射手),并读取其最新箭的 ring 数据
- const newRound = playersScores.value[playersScores.value.length - 1] || {};
- let shooterId = null;
- let isTenPlusRingShot = false;
- for (const pid of Object.keys(newRound)) {
- const newLen = (newRound[pid] || []).length;
- if (newLen > (prevCounts[pid] || 0)) {
- shooterId = parseInt(pid);
- const shot = newRound[pid][newLen - 1];
- isTenPlusRingShot = isTenPlusRing(shot);
- break;
- }
+ if (msg.shootData?.threeConsecutive10Rings === true) {
+ nextTick(() => audioManager.play("tententen", false));
}
- // 检测同一玩家连续三箭 10 环及以上,触发 tententen 音效
- checkAndPlayTententen(shooterId, isTenPlusRingShot);
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
halfTimeTip.value = true;
halfRest.value = true;
diff --git a/src/pages/practise-one.vue b/src/pages/practise-one.vue
index fcac288..28390ad 100644
--- a/src/pages/practise-one.vue
+++ b/src/pages/practise-one.vue
@@ -1,5 +1,5 @@