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("比赛结束");
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
audioManager.play("决金箭轮");
tips.value = '即将开始...'
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
ended.value = true;
} else if (msg.constructor === MESSAGETYPES.MatchOver) {

View File

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

View File

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