fix:修复箭数展示问题
This commit is contained in:
@@ -65,8 +65,12 @@ 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;
|
||||||
// 从 indexMap 按当前用户 id 取已射箭数,由后端维护准确值,不在前端自增
|
// 从 indexMap 按当前用户 id 取已射箭数,由后端维护准确值,不在前端自增。
|
||||||
if (current.playerId === user.value.id) currentShot.value = current.indexMap?.[user.value.id] ?? currentShot.value;
|
// 注意:后端在 ShootResult 中会将 playerId 重置为 0(无当前射手),
|
||||||
|
// 因此不能依赖 playerId === user.id 判断,改为直接读取 indexMap[user.id]。
|
||||||
|
// indexMap[user.id] 只在本人射箭后才增加,队友射箭时该值不变,逻辑等价且更准确。
|
||||||
|
const myShot = current.indexMap?.[user.value.id];
|
||||||
|
if (myShot !== undefined) currentShot.value = myShot;
|
||||||
if (message.shootData) {
|
if (message.shootData) {
|
||||||
let key = [];
|
let key = [];
|
||||||
key.push(
|
key.push(
|
||||||
|
|||||||
Reference in New Issue
Block a user