From 0edf259fb01907ffcdd87257cf598fd17423bec0 Mon Sep 17 00:00:00 2001 From: kron Date: Tue, 15 Jul 2025 17:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 11 ++++++ src/components/BattleHeader.vue | 1 + src/components/PlayerSeats.vue | 6 ++-- src/components/ShootProgress.vue | 13 ++++++- src/pages/battle-result.vue | 4 +-- src/pages/battle-room.vue | 60 ++++++++++++++++++++++++-------- src/pages/melee-match.vue | 12 +------ 7 files changed, 76 insertions(+), 31 deletions(-) diff --git a/src/App.vue b/src/App.vue index 670e42c..af5c1c6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -194,4 +194,15 @@ button::after { padding-top: 20px; position: relative; } +.half-time-tip { + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +.half-time-tip > text:last-child { + margin-top: 20px; + color: #fff9; +} diff --git a/src/components/BattleHeader.vue b/src/components/BattleHeader.vue index ef3090c..e231541 100644 --- a/src/components/BattleHeader.vue +++ b/src/components/BattleHeader.vue @@ -42,6 +42,7 @@ defineProps({ > diff --git a/src/components/PlayerSeats.vue b/src/components/PlayerSeats.vue index f9e0ec9..cf0d457 100644 --- a/src/components/PlayerSeats.vue +++ b/src/components/PlayerSeats.vue @@ -17,14 +17,16 @@ const seats = new Array(props.total).fill(1); - {{ players[index].name }} + {{ + players[index].name + }} 虚位以待 创建者 props.tips, @@ -125,6 +134,7 @@ async function onReceiveMessage(messages = []) { (props.battleId && msg.constructor === MESSAGETYPES.ShootResult) || (!props.battleId && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) ) { + if (props.melee && msg.userId !== user.value.id) return; if (msg.target) { currentSound.value = msg.target.ring ? `${msg.target.ring}环` @@ -134,10 +144,11 @@ async function onReceiveMessage(messages = []) { } else if (msg.constructor === MESSAGETYPES.AllReady) { audioManager.play("比赛开始"); } else if (msg.constructor === MESSAGETYPES.MeleeAllReady) { - audioManager.play("比赛开始"); + if (!halfTimeTip.value) audioManager.play("比赛开始"); } else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { currentRoundEnded.value = true; } else if (msg.constructor === MESSAGETYPES.HalfTimeOver) { + halfTimeTip.value = true; audioManager.play("中场休息"); } else if (msg.constructor === MESSAGETYPES.MatchOver) { audioManager.play("比赛结束"); diff --git a/src/pages/battle-result.vue b/src/pages/battle-result.vue index 276dd09..0272688 100644 --- a/src/pages/battle-result.vue +++ b/src/pages/battle-result.vue @@ -19,7 +19,7 @@ onLoad(async (options) => { battleId.value = options.battleId; const result = await getGameAPI( // options.battleId || "BATTLE-1750867490990424058-718" - options.battleId || "BATTLE-1750688536849458226-518" + options.battleId || "BATTLE-1752563964391008873-624" ); data.value = result; if (result.mode === 1 && result.redPlayers[user.value.id]) { @@ -285,8 +285,8 @@ const checkBowData = () => { margin: 0 20px; } .players { - flex-wrap: wrap; display: flex; + flex-direction: column; overflow: auto; width: calc(100% - 60px); color: #fff6; diff --git a/src/pages/battle-room.vue b/src/pages/battle-room.vue index efacd4e..a110ea3 100644 --- a/src/pages/battle-room.vue +++ b/src/pages/battle-room.vue @@ -16,6 +16,7 @@ import SModal from "@/components/SModal.vue"; import ScreenHint from "@/components/ScreenHint.vue"; import RoundEndTip from "@/components/RoundEndTip.vue"; import TestDistance from "@/components/TestDistance.vue"; +import PlayerScore from "@/components/PlayerScore.vue"; import { getRoomAPI, destroyRoomAPI, exitRoomAPI, startRoomAPI } from "@/apis"; import { MESSAGETYPES, roundsName, getMessageTypeName } from "@/constants"; import useStore from "@/store"; @@ -53,7 +54,7 @@ const playersScores = ref({}); const showModal = ref(false); const halfTimeTip = ref(false); const isFinalShoot = ref(false); -const total = ref(90); +const total = ref(15); watch( () => [players.value, playersScores.value], @@ -132,7 +133,7 @@ onLoad(async (options) => { }, 300); } else if (remain > 90 && remain <= 110) { halfTimeTip.value = true; - countDown.value = 20; + total.value = 20; tips.value = "准备下半场"; setTimeout(() => { uni.$emit("update-ramain", 110 - remain); @@ -162,7 +163,6 @@ onLoad(async (options) => { return false; }); if (result.battleType === 1) { - total.value = 15; if (user.value.id !== owner.value.id) { opponent.value = { id: user.value.id, @@ -183,12 +183,21 @@ onLoad(async (options) => { }); } } else if (result.battleType === 2) { - result.members.forEach((m) => { - players.value.push(m.userInfo); + const ownerIndex = result.members.findIndex( + (m) => m.userInfo.id === result.creator + ); + if (ownerIndex !== -1) { + players.value.push(result.members[ownerIndex].userInfo); + } else { + players.value.push({}); + } + result.members.forEach((m, index) => { + if (ownerIndex !== index) players.value.push(m.userInfo); }); } } }); + const startGame = async () => { const result = await startRoomAPI(room.value.number); timerSeq.value += 1; @@ -208,11 +217,19 @@ async function onReceiveMessage(messages = []) { // 这里会掉多次; timerSeq.value += 1; battleId.value = msg.id; + step.value = 2; if (room.value.battleType === 1) { redTeam.value = msg.groupUserStatus.redTeam; blueTeam.value = msg.groupUserStatus.blueTeam; + } else if (room.value.battleType === 2) { + players.value = [ + ...msg.groupUserStatus.redTeam, + ...msg.groupUserStatus.blueTeam, + ]; + players.value.forEach((p) => { + playersScores.value[p.id] = []; + }); } - step.value = 2; } if (msg.roomNumber === roomNumber.value) { if (msg.constructor === MESSAGETYPES.UserEnterRoom) { @@ -232,11 +249,19 @@ async function onReceiveMessage(messages = []) { } } if (room.value.battleType === 2) { - players.value.push({ - id: msg.userId, - name: msg.name, - avatar: msg.avatar, - }); + if (room.value.creator === msg.userId) { + players.value[0] = { + id: msg.userId, + name: msg.name, + avatar: msg.avatar, + }; + } else { + players.value.push({ + id: msg.userId, + name: msg.name, + avatar: msg.avatar, + }); + } } } if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) { @@ -281,14 +306,17 @@ async function onReceiveMessage(messages = []) { redArrows: [], blueArrows: [], }); + total.value = 15; } if (msg.constructor === MESSAGETYPES.MeleeAllReady) { start.value = true; startCount.value = true; + step.value = 3; seq.value += 1; timerSeq.value = 0; tips.value = "请连续射出6支箭"; scores.value = []; + total.value = 90; } if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) { if (room.value.battleType === 1) { @@ -373,6 +401,7 @@ async function onReceiveMessage(messages = []) { } if (msg.constructor === MESSAGETYPES.HalfTimeOver) { startCount.value = false; + total.value = 20; halfTimeTip.value = true; tips.value = "准备下半场"; } @@ -488,7 +517,7 @@ onUnmounted(() => { > 进入大乱斗 @@ -504,7 +533,7 @@ onUnmounted(() => { /> - + { :total="total" :currentRound="currentRound" :battleId="battleId" + :melee="room.battleType === 2" /> { :blueScores="blueScores" /> { :start="start" :tips="tips" :total="countDown" + :melee="true" /> @@ -248,15 +249,4 @@ onUnmounted(() => { width: 100%; height: 100%; } -.half-time-tip { - width: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} -.half-time-tip > text:last-child { - margin-top: 20px; - color: #fff9; -}