fix:比赛射箭数取后端动态值

This commit is contained in:
2026-05-13 14:58:36 +08:00
parent c298e258cc
commit 4761206a6e
2 changed files with 7 additions and 8 deletions

View File

@@ -60,8 +60,8 @@ async function onReceiveMessage(message) {
audioManager.play("比赛结束", false); audioManager.play("比赛结束", false);
} else if (type === MESSAGETYPESV2.ShootResult) { } else if (type === MESSAGETYPESV2.ShootResult) {
if (melee.value && current.playerId !== user.value.id) return; if (melee.value && current.playerId !== user.value.id) return;
// 仅计用户自己的命中箭,并加上限防护,防止超过 totalShot如重入时 currentShot 初始值偏高) // 直接使用后端返回的 myIndex当前用户已射箭数不在前端自增
if (current.playerId === user.value.id && currentShot.value < totalShot.value) currentShot.value++; if (current.playerId === user.value.id) currentShot.value = current.myIndex ?? currentShot.value;
if (message.shootData) { if (message.shootData) {
let key = []; let key = [];
key.push( key.push(

View File

@@ -196,9 +196,9 @@ function onBattleEnd() {
function onNewRound(msg, prevRound) { function onNewRound(msg, prevRound) {
showRoundTip.value = true; showRoundTip.value = true;
isFinalShoot.value = msg.current.goldRound; isFinalShoot.value = msg.current.goldRound;
// 决金箭轮每人只射一箭,重置箭数显示为 (0/1) // 决金轮箭数不确定(平局后可能再加一箭),清零 totalShot 隐藏箭数显示
if (msg.current.goldRound) { if (msg.current.goldRound) {
store.updateShotInfo(0, 1); store.updateShotInfo(0, 0);
} }
// 用传入的 prevRound捕获时刻的旧轮次展示结算 Tip与进度条 currentRound 解耦 // 用传入的 prevRound捕获时刻的旧轮次展示结算 Tip与进度条 currentRound 解耦
roundTipRound.value = prevRound; roundTipRound.value = prevRound;
@@ -290,10 +290,9 @@ onShow(async () => {
} else { } else {
if (result.status !== 0) { if (result.status !== 0) {
// 比赛进行中,从后端恢复箭数(测距阶段不展示) // 比赛进行中,从后端恢复箭数(测距阶段不展示)
if (result.shootNumber) { // 决金轮不展示箭数;其余轮次使用后端 myIndex 恢复已射箭数
// current.index 为 0 基的已射箭数0=尚未射出),与 ShootResult 累加语义一致 if (result.shootNumber && !result.current?.goldRound) {
// 注意:不再 +1避免重进时与后续 ShootResult 自增形成双重计数导致超出 totalShot store.updateShotInfo(result.current?.myIndex ?? 0, result.shootNumber);
store.updateShotInfo(result.current?.index ?? 0, result.shootNumber);
} }
} else { } else {
// 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值 // 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值