BUG修复

This commit is contained in:
kron
2025-08-20 18:30:02 +08:00
parent f19b9b1f9d
commit 70b3a25369
3 changed files with 38 additions and 48 deletions

View File

@@ -77,6 +77,7 @@ async function onReceiveMessage(messages = []) {
audioManager.play("比赛结束"); audioManager.play("比赛结束");
} else if (msg.constructor === MESSAGETYPES.FinalShoot) { } else if (msg.constructor === MESSAGETYPES.FinalShoot) {
audioManager.play("决金箭轮"); audioManager.play("决金箭轮");
tips.value = '即将开始...'
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) { } else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
ended.value = true; ended.value = true;
} else if (msg.constructor === MESSAGETYPES.MatchOver) { } else if (msg.constructor === MESSAGETYPES.MatchOver) {

View File

@@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, watch, onMounted, onUnmounted } from "vue"; import { ref, onMounted, onUnmounted } from "vue";
const props = defineProps({ const props = defineProps({
isFinal: { isFinal: {
type: Boolean, type: Boolean,
@@ -26,7 +26,7 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}); });
const count = ref(3); const count = ref(props.isFinal ? 10 : 3);
const tiemr = ref(null); const tiemr = ref(null);
function startCount() { function startCount() {
if (tiemr.value) clearInterval(tiemr.value); if (tiemr.value) clearInterval(tiemr.value);
@@ -37,13 +37,6 @@ function startCount() {
} else count.value -= 1; } else count.value -= 1;
}, 1000); }, 1000);
} }
watch(
() => [props.isFinal, props.roundData],
([n_isFinal, n_roundData]) => {
count.value = n_isFinal ? 10 : 3;
startCount();
}
);
onMounted(() => { onMounted(() => {
startCount(); startCount();
}); });
@@ -54,7 +47,7 @@ onUnmounted(() => {
<template> <template>
<view class="round-end-tip"> <view class="round-end-tip">
<text>{{ round }}轮射结束</text> <text>{{ round }}轮射结束</text>
<block v-if="!isFinal"> <block v-if="!isFinal">
<view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0"> <view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
<text>本轮蓝队</text> <text>本轮蓝队</text>

View File

@@ -65,7 +65,7 @@ function recoverData(battleInfo) {
redPoints.value = 0; redPoints.value = 0;
currentRound.value = battleInfo.currentRound; currentRound.value = battleInfo.currentRound;
totalRounds.value = battleInfo.maxRound; totalRounds.value = battleInfo.maxRound;
roundResults.value = battleInfo.roundResults; roundResults.value = [...battleInfo.roundResults];
battleInfo.roundResults.forEach((round) => { battleInfo.roundResults.forEach((round) => {
const blueTotal = round.blueArrows.reduce( const blueTotal = round.blueArrows.reduce(
(last, next) => last + next.ring, (last, next) => last + next.ring,
@@ -84,31 +84,40 @@ function recoverData(battleInfo) {
redPoints.value += 2; redPoints.value += 2;
} }
}); });
const hasCurrentRoundData =
battleInfo.redTeam.some(
(item) => !!item.shotHistory[battleInfo.currentRound]
) ||
battleInfo.blueTeam.some(
(item) => !!item.shotHistory[battleInfo.currentRound]
);
if ( if (
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] || battleInfo.currentRound > battleInfo.roundResults.length &&
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound] hasCurrentRoundData
) { ) {
const blueArrows = [];
const redArrows = [];
battleInfo.redTeam.forEach((item) =>
item.shotHistory[battleInfo.currentRound]
.filter((item) => !!item.playerId)
.forEach((item) => redArrows.push(item))
);
battleInfo.blueTeam.forEach((item) =>
item.shotHistory[battleInfo.currentRound]
.filter((item) => !!item.playerId)
.forEach((item) => blueArrows.push(item))
);
roundResults.value.push({ roundResults.value.push({
redArrows: battleInfo.redTeam[0].shotHistory[ redArrows,
battleInfo.currentRound blueArrows,
].filter((item) => !!item.playerId),
blueArrows: battleInfo.blueTeam[0].shotHistory[
battleInfo.currentRound
].filter((item) => !!item.playerId),
});
} else if (battleInfo.currentRound < 5) {
roundResults.value.push({
redArrows: [],
blueArrows: [],
}); });
} }
if (battleInfo.goldenRound) { if (battleInfo.goldenRound) {
const { ShotCount, RedRecords, BlueRecords } = battleInfo.goldenRound; const { ShotCount, RedRecords, BlueRecords } = battleInfo.goldenRound;
const roundCount = Math.max(RedRecords.length, BlueRecords.length); currentRound.value += ShotCount;
currentRound.value += roundCount; goldenRound.value += ShotCount;
goldenRound.value += roundCount;
isFinalShoot.value = true; isFinalShoot.value = true;
for (let i = 0; i < roundCount; i++) { for (let i = 0; i < ShotCount; i++) {
const roundData = { const roundData = {
redArrows: redArrows:
RedRecords && RedRecords[i] ? RedRecords[i].Arrows || [] : [], RedRecords && RedRecords[i] ? RedRecords[i].Arrows || [] : [],
@@ -116,13 +125,9 @@ function recoverData(battleInfo) {
BlueRecords && BlueRecords[i] ? BlueRecords[i].Arrows || [] : [], BlueRecords && BlueRecords[i] ? BlueRecords[i].Arrows || [] : [],
gold: true, gold: true,
}; };
if (roundResults.value[5 + i]) {
roundResults.value[5 + i] = roundData;
} else {
roundResults.value.push(roundData); roundResults.value.push(roundData);
} }
} }
}
const lastIndex = roundResults.value.length - 1; const lastIndex = roundResults.value.length - 1;
if (roundResults.value[lastIndex]) { if (roundResults.value[lastIndex]) {
const redArrows = roundResults.value[lastIndex].redArrows; const redArrows = roundResults.value[lastIndex].redArrows;
@@ -157,12 +162,6 @@ async function onReceiveMessage(messages = []) {
if (msg.constructor === MESSAGETYPES.AllReady) { if (msg.constructor === MESSAGETYPES.AllReady) {
start.value = true; start.value = true;
totalRounds.value = msg.groupUserStatus.config.maxRounds; totalRounds.value = msg.groupUserStatus.config.maxRounds;
roundResults.value = [
{
redArrows: [],
blueArrows: [],
},
];
} }
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) { if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
if (currentShooterId.value !== msg.userId) { if (currentShooterId.value !== msg.userId) {
@@ -184,6 +183,7 @@ async function onReceiveMessage(messages = []) {
const isRed = redTeam.value.find((item) => item.id === msg.userId); const isRed = redTeam.value.find((item) => item.id === msg.userId);
if (isRed) scores.value.push({ ...msg.target }); if (isRed) scores.value.push({ ...msg.target });
else blueScores.value.push({ ...msg.target }); else blueScores.value.push({ ...msg.target });
// 下标从0开始的要减1
if (!roundResults.value[currentRound.value - 1]) { if (!roundResults.value[currentRound.value - 1]) {
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
@@ -204,17 +204,14 @@ async function onReceiveMessage(messages = []) {
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore; bluePoints.value += result.blueScore;
redPoints.value += result.redScore; redPoints.value += result.redScore;
if (result.currentRound < 5) {
currentRound.value = result.currentRound + 1; currentRound.value = result.currentRound + 1;
roundResults.value.push({ if (!result.goldenRound) {
redArrows: [],
blueArrows: [],
});
showRoundTip.value = true; showRoundTip.value = true;
} }
} }
if (msg.constructor === MESSAGETYPES.FinalShoot) { if (msg.constructor === MESSAGETYPES.FinalShoot) {
currentShooterId.value = 0; currentShooterId.value = 0;
currentRound.value = msg.groupUserStatus.currentRound + 1;
goldenRound.value += 1; goldenRound.value += 1;
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
@@ -234,6 +231,7 @@ async function onReceiveMessage(messages = []) {
currentBluePoint.value = 0; currentBluePoint.value = 0;
currentRedPoint.value = 0; currentRedPoint.value = 0;
showRoundTip.value = true; showRoundTip.value = true;
isFinalShoot.value = false;
setTimeout(() => { setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 3000); }, 3000);
@@ -349,9 +347,7 @@ onHide(() => {
:bluePoint="currentBluePoint" :bluePoint="currentBluePoint"
:redPoint="currentRedPoint" :redPoint="currentRedPoint"
:roundData=" :roundData="
roundResults[roundResults.length - 2] roundResults[currentRound - 2] ? roundResults[currentRound - 2] : []
? roundResults[roundResults.length - 2]
: []
" "
:onAutoClose="() => (showRoundTip = false)" :onAutoClose="() => (showRoundTip = false)"
/> />