diff --git a/src/components/BattleFooter.vue b/src/components/BattleFooter.vue index f92493b..e4e869e 100644 --- a/src/components/BattleFooter.vue +++ b/src/components/BattleFooter.vue @@ -41,7 +41,13 @@ defineProps({ - + + Round + + + + + @@ -62,7 +68,13 @@ defineProps({ - + + Round + + + + + diff --git a/src/components/RoundEndTip.vue b/src/components/RoundEndTip.vue index 043fd21..1ad4284 100644 --- a/src/components/RoundEndTip.vue +++ b/src/components/RoundEndTip.vue @@ -56,7 +56,7 @@ onUnmounted(() => { 第{{ round }}轮射击结束 - + 本轮蓝队 {{ (roundData.blueArrows || []).reduce( @@ -73,10 +73,13 @@ onUnmounted(() => { }} - - 本场比赛无人射箭,已取消 + + 连续3个来回无人射箭,比赛被取消 - + 红队、蓝队各得{{ redPoint }} { - if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) { - scores.value = battleInfo.roundResults[ - battleInfo.roundResults.length - 1 - ].redArrows.filter((item) => !!item.playerId); - blueScores.value = battleInfo.roundResults[ - battleInfo.roundResults.length - 1 - ].blueArrows.filter((item) => !!item.playerId); - } - }, 300); + if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) { + scores.value = battleInfo.roundResults[ + battleInfo.roundResults.length - 1 + ].redArrows.filter((item) => !!item.playerId); + blueScores.value = battleInfo.roundResults[ + battleInfo.roundResults.length - 1 + ].blueArrows.filter((item) => !!item.playerId); + } if ( battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] || battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound] @@ -152,16 +150,36 @@ function recoverData(battleInfo) { blueArrows: [], }); } + if (battleInfo.goldenRound) { + const { ShotCount, RedRecords, BlueRecords } = battleInfo.goldenRound; + const roundCount = Math.max(RedRecords.length, BlueRecords.length); + currentRound.value += roundCount; + isFinalShoot.value = true; + for (let i = 0; i < roundCount; i++) { + const roundData = { + redArrows: + RedRecords && RedRecords[i] ? RedRecords[i].Arrows || [] : [], + blueArrows: + BlueRecords && BlueRecords[i] ? BlueRecords[i].Arrows || [] : [], + }; + if (roundResults.value[5 + i]) { + roundResults.value[5 + i] = roundData; + } else { + roundResults.value.push(roundData); + } + } + } } // 这个状态不准 // if (battleInfo.status !== 11) return; if (battleInfo.firePlayerIndex) { currentShooterId.value = battleInfo.firePlayerIndex; - if (redTeam.value[0].id === currentShooterId.value) { - tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`; - } else { - tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`; - } + if (redTeam.value[0].id === currentShooterId.value) + tips.value = "请红队射箭"; + else tips.value = "请蓝队射箭"; + tips.value += isFinalShoot.value + ? "决金箭" + : `第${roundsName[currentRound.value]}轮`; } if (battleInfo.fireTime > 0) { const remain = Date.now() / 1000 - battleInfo.fireTime; @@ -396,26 +414,15 @@ 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); - if (roundResults.value[currentRound.value - 1]) { - if (isRed && roundResults.value[currentRound.value - 1].redArrows) { - roundResults.value[currentRound.value - 1].redArrows.push( - msg.target - ); - } - if ( - !isRed && - roundResults.value[currentRound.value - 1].blueArrows - ) { - roundResults.value[currentRound.value - 1].blueArrows.push( - msg.target - ); - } - } else { + if (!roundResults.value[currentRound.value - 1]) { roundResults.value.push({ redArrows: [], blueArrows: [], }); } + roundResults.value[currentRound.value - 1][ + isRed ? "redArrows" : "blueArrows" + ].push(msg.target); } if (battleType.value === 2 && msg.userId === user.value.id) { scores.value.push({ ...msg.target }); @@ -434,9 +441,9 @@ async function onReceiveMessage(messages = []) { currentRedPoint.value = result.redScore; bluePoints.value += result.blueScore; redPoints.value += result.redScore; - currentRound.value = result.currentRound + 1; uni.$emit("update-ramain", 0); if (result.currentRound < 5) { + currentRound.value += 1; roundResults.value.push({ redArrows: [], blueArrows: [], @@ -446,6 +453,12 @@ async function onReceiveMessage(messages = []) { } } if (msg.constructor === MESSAGETYPES.FinalShoot) { + currentShooterId.value = 0; + currentRound.value += 1; + roundResults.value.push({ + redArrows: [], + blueArrows: [], + }); if (!isFinalShoot.value) { isFinalShoot.value = true; showRoundTip.value = true; @@ -467,15 +480,14 @@ async function onReceiveMessage(messages = []) { } if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.endStatus.noSaved) { - // uni.showToast({ - // title: "本场比赛无人射箭,已取消", - // icon: "none", - // }); + // 正常每回合结束通知,回合会加上1 + currentRound.value += 1; currentBluePoint.value = 0; currentRedPoint.value = 0; + showRoundTip.value = true; setTimeout(() => { uni.navigateBack(); - }, 1500); + }, 3000); } else { isEnded.value = true; uni.setStorageSync("last-battle", msg.endStatus); @@ -559,7 +571,11 @@ onHide(() => {