update:修复大乱斗显示问题,修复连续3次10环播报
This commit is contained in:
@@ -49,7 +49,7 @@ const battleWay = ref(0);
|
||||
const lastToSomeoneShootKey = ref("");
|
||||
/** 控制设备离线提示弹窗的显示状态 */
|
||||
const showOfflineModal = ref(false);
|
||||
/** 记录每位玩家当前轮连续 X 环数,key 为 playerId,用于触发 tententen 音效 */
|
||||
/** 记录每位玩家当前轮连续 10 环及以上次数,key 为 playerId,用于触发 tententen 音效 */
|
||||
const xRingStreaks = ref({});
|
||||
|
||||
/**
|
||||
@@ -234,22 +234,26 @@ function onNewRound(msg, prevRound) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测指定射手连续 X 环是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效
|
||||
* 检测指定射手连续 10 环及以上是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效
|
||||
* @param {number} shooterId - 本次射手的 ID(取自 currentShooterId.value)
|
||||
* @param {boolean} isXRing - 本次射击是否为 X 环
|
||||
* @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
|
||||
*/
|
||||
function checkAndPlayTententen(shooterId, isXRing) {
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function checkAndPlayTententen(shooterId, isTenPlusRingShot) {
|
||||
if (!shooterId) return;
|
||||
if (isXRing) {
|
||||
if (isTenPlusRingShot) {
|
||||
xRingStreaks.value[shooterId] = (xRingStreaks.value[shooterId] || 0) + 1;
|
||||
// 同一玩家连续 3 箭均为 X 环,追加到环数音效队列尾部播放
|
||||
// 同一玩家连续 3 箭均为 10 环及以上,追加到环数音效队列尾部播放
|
||||
if (xRingStreaks.value[shooterId] >= 3) {
|
||||
xRingStreaks.value[shooterId] = 0;
|
||||
// nextTick 确保 HeaderProgress 的环数播报已入队后再追加 tententen,避免播放顺序颠倒
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else {
|
||||
// 非 X 环则重置该玩家的连续计数
|
||||
// 低于 10 环或未上靶则重置该玩家的连续计数
|
||||
xRingStreaks.value[shooterId] = 0;
|
||||
}
|
||||
}
|
||||
@@ -268,9 +272,9 @@ async function onReceiveMessage(msg) {
|
||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
showRoundTip.value = false;
|
||||
recoverData(msg, {arrowOnly: true});
|
||||
// 检测同一玩家三箭全 X 环,触发 tententen 音效
|
||||
// 检测同一玩家连续三箭 10 环及以上,触发 tententen 音效
|
||||
// currentShooterId 在 ToSomeoneShoot 时写入,ShootResult 不会覆盖,可靠识别本次射手
|
||||
checkAndPlayTententen(currentShooterId.value, !!(msg.shootData?.ringX && msg.shootData?.ring));
|
||||
checkAndPlayTententen(currentShooterId.value, isTenPlusRing(msg.shootData));
|
||||
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
||||
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
||||
const prevRound = currentRound.value;
|
||||
|
||||
Reference in New Issue
Block a user