diff --git a/src/apis.js b/src/apis.js index 9651c7c..9f7f8bc 100644 --- a/src/apis.js +++ b/src/apis.js @@ -311,6 +311,13 @@ export const getPractiseAPI = async (id) => { return request("GET", `/user/practice/get?id=${id}`); }; +export const getPractiseDetailAPI = async (id) => { + return request( + "GET", + `/user/practice/detail?id=${encodeURIComponent(id)}` + ); +}; + export const createRoomAPI = (gameType, teamSize, targetType) => { return request("POST", "/user/createroom", { gameType, @@ -344,12 +351,12 @@ export const startRoomAPI = (number) => { return request("POST", "/user/room/start", {number}); }; -export const getPractiseResultListAPI = async (page = 1, page_size = 15) => { - const reuslt = await request( +export const getPractiseResultListAPI = async (page = 1, pageSize = 15) => { + const result = await request( "GET", - `/user/practice/list?page=${page}&page_size=${page_size}` + `/user/practice/mylist?page=${page}&pageSize=${pageSize}&status=0` ); - return reuslt.list; + return Array.isArray(result?.list) ? result.list : []; }; export const matchGameAPI = (match, gameType, teamSize) => { diff --git a/src/audioManager.js b/src/audioManager.js index 1bf8f31..35d9de5 100644 --- a/src/audioManager.js +++ b/src/audioManager.js @@ -52,6 +52,12 @@ export const audioFils = { "https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrl5u0iromqhf.mp3", 射击无效: "https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%E6%A3%80%E6%9F%A5%E8%B7%9D%E7%A6%BB%E5%92%8C%E9%9D%B6%E7%BA%B8.mp3", + "射箭无效,距离不足": + "https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E8%B7%9D%E7%A6%BB%E4%B8%8D%E8%B6%B3.MP3", + "射箭无效,未识别到靶纸": + "https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E6%9C%AA%E8%AF%86%E5%88%AB%E5%88%B0%E9%9D%B6%E7%BA%B8.MP3", + "射箭无效,靶纸错误": + "https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E9%9D%B6%E7%BA%B8%E9%94%99%E8%AF%AF.mp3.MP3", 未上靶: "https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3", "1环": @@ -117,6 +123,9 @@ const AUDIO_WARM_PRIORITY_KEYS = [ "轮到你了", "比赛结束", "射击无效", + "射箭无效,距离不足", + "射箭无效,未识别到靶纸", + "射箭无效,靶纸错误", "中场休息", "下半场开始", "决金箭轮", diff --git a/src/components/BowTarget.vue b/src/components/BowTarget.vue index f3801e6..ebd37d2 100644 --- a/src/components/BowTarget.vue +++ b/src/components/BowTarget.vue @@ -67,6 +67,10 @@ const props = defineProps({ type: Boolean, default: false, }, + enableShotEffect: { + type: Boolean, + default: true, + }, }); const pMode = ref(true); @@ -113,7 +117,13 @@ function hasShotPoint(shot) { } function shouldPlayShotEffect(shot) { - return props.isSvip && !!shot && Number(shot.ring) > 0 && hasShotPoint(shot); + return ( + props.enableShotEffect && + props.isSvip && + !!shot && + Number(shot.ring) > 0 && + hasShotPoint(shot) + ); } function clearTipTimer() { @@ -276,7 +286,7 @@ watch( const latestShot = props.scores[newLen - 1]; if (shouldPlayShotEffect(latestShot)) { void prepareShotEffect("red", latestShot, newLen - 1); - } else { + } else if (props.enableShotEffect) { shotEffectRequestGeneration += 1; pendingShotEffect.value = null; showShotTip("red", latestShot); @@ -301,7 +311,7 @@ watch( const latestShot = props.blueScores[newLen - 1]; if (shouldPlayShotEffect(latestShot)) { void prepareShotEffect("blue", latestShot, newLen - 1); - } else { + } else if (props.enableShotEffect) { shotEffectRequestGeneration += 1; pendingShotEffect.value = null; showShotTip("blue", latestShot); diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue index 464d31d..b01472b 100644 --- a/src/components/HeaderProgress.vue +++ b/src/components/HeaderProgress.vue @@ -2,7 +2,7 @@ import { ref, watch, onMounted, onBeforeUnmount } from "vue"; import audioManager from "@/audioManager"; import { MESSAGETYPESV2 } from "@/constants"; -import { getDirectionText } from "@/util"; +import { getDirectionText, getInvalidShotAudioKey } from "@/util"; import useStore from "@/store"; import { storeToRefs } from "pinia"; @@ -91,7 +91,7 @@ async function onReceiveMessage(message) { title: "距离不足,无效", icon: "none", }); - audioManager.play("射击无效"); + audioManager.play(getInvalidShotAudioKey(shootData)); } } diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue index 6f4f91c..cd0912b 100644 --- a/src/components/ShootProgress.vue +++ b/src/components/ShootProgress.vue @@ -2,7 +2,7 @@ import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue"; import audioManager from "@/audioManager"; import { MESSAGETYPESV2 } from "@/constants"; -import { getDirectionText } from "@/util"; +import { getDirectionText, getInvalidShotAudioKey } from "@/util"; import useStore from "@/store"; import { storeToRefs } from "pinia"; @@ -174,7 +174,7 @@ async function onReceiveMessage(msg) { title: "距离不足,无效", icon: "none", }); - audioManager.play("射击无效"); + audioManager.play(getInvalidShotAudioKey(msg.shootData)); } } diff --git a/src/components/TargetCanvas.vue b/src/components/TargetCanvas.vue index f699158..fd3478a 100644 --- a/src/components/TargetCanvas.vue +++ b/src/components/TargetCanvas.vue @@ -1,8 +1,18 @@ diff --git a/src/pages/training/components/ScorePanel2.vue b/src/components/TrainingScorePanel.vue similarity index 59% rename from src/pages/training/components/ScorePanel2.vue rename to src/components/TrainingScorePanel.vue index fe96acd..30636f6 100644 --- a/src/pages/training/components/ScorePanel2.vue +++ b/src/components/TrainingScorePanel.vue @@ -10,6 +10,14 @@ const props = defineProps({ type: Number, default: 0, }, + trainingType: { + type: String, + default: "", + }, + recordMode: { + type: Boolean, + default: false, + }, }); const getDisplayText = (arrow = {}) => { @@ -18,15 +26,16 @@ const getDisplayText = (arrow = {}) => { return arrow.ringX ? "X" : String(arrow.ring); }; -const isLowScore = (arrow = {}) => { - if (!arrow || arrow.ringX) return false; - return Number(arrow.ring) < 6; +const isFailed = (arrow = {}) => { + if (!arrow) return false; + if (props.recordMode && props.trainingType !== "precision") return false; + return arrow.ok !== true; }; const displayArrows = computed(() => { const list = [...props.arrows]; // total 是达标箭数,不是实际射箭上限;训练中始终预留下一箭空框。 - list.push(null); + if (!props.recordMode) list.push(null); return list; }); @@ -39,10 +48,28 @@ const displayArrows = computed(() => { :key="index" class="score-card" > - + + {{ getDisplayText(arrow) }} @@ -87,6 +114,13 @@ const displayArrows = computed(() => { height: 56rpx; } +.score-result-icon { + position: relative; + z-index: 1; + width: 30rpx; + height: 30rpx; +} + .score-value { position: relative; z-index: 1; diff --git a/src/matchWebsocket.js b/src/matchWebsocket.js index dd86531..73ebe9c 100644 --- a/src/matchWebsocket.js +++ b/src/matchWebsocket.js @@ -9,7 +9,7 @@ import { getServerMessageTypeName, } from "@/utils/matchProtocol"; import { MESSAGETYPESV2 } from "@/constants"; -import { getDirectionText } from "@/util"; +import { getDirectionText, getInvalidShotAudioKey } from "@/util"; import { normalizeId, normalizeMatchInfo, @@ -378,7 +378,7 @@ function getAckAudioKeys(message, businessMessage) { case ServerMessageType.SERVER_MSG_CHECK: return getTestDistanceAudioKeys(businessMessage?.shootData); case ServerMessageType.SERVER_MSG_NOT_ENOUGH_DISTANCE: - return ["射击无效"]; + return [getInvalidShotAudioKey(businessMessage?.shootData)]; default: return []; } diff --git a/src/mock/index.js b/src/mock/index.js deleted file mode 100644 index c716202..0000000 --- a/src/mock/index.js +++ /dev/null @@ -1,104 +0,0 @@ -// 首页一周打卡展示数据,直接对应顶部 7 个日期卡片。 -export const trainingHomeWeekSchedule = [ - { - key: "mon", - label: "周一", - status: "done", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png", - }, - { - key: "tue", - label: "周二", - status: "done", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png", - }, - { - key: "wed", - label: "周三", - status: "missed", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png", - }, - { - key: "thu", - label: "周四", - status: "missed", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png", - }, - { - key: "fri", - label: "周五", - status: "done", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png", - }, - { - key: "sat", - label: "周六", - status: "done", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png", - }, - { - key: "sun", - label: "周日", - status: "missed", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png", - }, -]; - -// 首页统计卡数据,按设计稿从左到右展示。 -export const trainingHomeStats = [ - { key: "days", value: "12", unit: "天", label: "共训练" }, - { key: "shots", value: "112", unit: "支", label: "累计射箭" }, - { key: "hitRate", value: "30", unit: "%", label: "命中率" }, - { key: "endurance", value: "6", unit: "支/分钟", label: "耐力射击" }, - { key: "calories", value: "31W", unit: "卡路里", label: "共消耗" }, -]; - -// 雷达图区文案与数值配置。 -export const trainingHomeRadar = { - labels: ["基础", "精准", "力量", "节奏", "耐力"], - values: [5.5, 6.3, 10, 4.5, 6], - maxValue: 10, - surpassValue: '80%' -}; - -// 首页主推荐训练卡数据。 -export const trainingHomeFeatured = { - title: "基础训练", - progressText: "当前进度 LV7 >", -}; - -// 首页四个训练入口卡片数据。 -export const trainingHomeModes = [ - { - key: "endurance", - title: "耐力训练", - progressText: "当前进度 LV5 >", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_3.png", - recommended: true, - disabled: false, - }, - { - key: "precision", - title: "精准训练", - progressText: "当前进度 LV3 >", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_4.png", - recommended: false, - disabled: false, - }, - { - key: "rhythm", - title: "节奏训练", - progressText: "当前进度 LV6 >", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_5.png", - recommended: false, - disabled: false, - }, - { - key: "power", - title: "力量训练", - progressText: "Coming! LV10", - icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_6.png", - recommended: false, - disabled: true, - }, -]; diff --git a/src/mock/trainingDifficulty.js b/src/mock/trainingDifficulty.js deleted file mode 100644 index f6bd42d..0000000 --- a/src/mock/trainingDifficulty.js +++ /dev/null @@ -1,113 +0,0 @@ -// 难度页当前用于保存“开始训练前上下文”的本地存储 key。 -export const trainingDifficultyStorageKey = "training-selection"; - -// 当前是页面联调用的模拟数据: -// 1. 总难度 20 级 -// 2. 已解锁到 Lv3 -// 3. 前三关展示不同完成进度 -const totalDifficultyLevel = 20; -const mockedUnlockedDifficultyId = "lv3"; -const mockedDifficultyProgressMap = { - lv1: 100, - lv2: 90, - lv3: 70, -}; - -const modeList = [ - { - key: "endurance", - title: "耐力训练", - }, - { - key: "precision", - title: "精准训练", - }, - { - key: "rhythm", - title: "节奏训练", - }, - { - key: "basic", - title: "基础训练", - }, - { - key: "power", - title: "力量训练", - }, - { - key: "focus", - title: "专注训练", - }, -]; - -const createDifficultyId = (level) => `lv${level}`; - -const createDifficultyLabel = (level) => `Lv${level}`; - -// 根据等级生成模拟文案,方便一次性扩展到更多关卡。 -const createDifficultySummary = (level) => { - return [ - `箭靶划分为${Math.min(1 + Math.floor((level - 1) / 5), 4)}个区域`, - `需${4 + level}次命中目标`, - `${100 + Math.floor((level - 1) / 2) * 10}秒内完成所有射击`, - "需使用20CM全环靶", - ]; -}; - -// 难度页的节点位置已经在页面内统一计算, -// 这里保留最核心的 id / label 即可,不再维护无效的 left / top / style 字段。 -const createDifficultyNode = (level) => { - return { - id: createDifficultyId(level), - label: createDifficultyLabel(level), - }; -}; - -const createDifficultyDetail = (level) => { - const id = createDifficultyId(level); - const label = createDifficultyLabel(level); - - return { - id, - label, - title: `${label}难度`, - summary: createDifficultySummary(level), - startText: "开始", - targetPaperType: "20CM全环靶", - }; -}; - -// 所有训练模式当前共用同一套难度定义。 -const sharedDifficultyNodes = Array.from( - { length: totalDifficultyLevel }, - (_, index) => createDifficultyNode(index + 1) -); - -const sharedDifficultyDetails = Object.fromEntries( - Array.from({ length: totalDifficultyLevel }, (_, index) => { - const detail = createDifficultyDetail(index + 1); - return [detail.id, detail]; - }) -); - -const createModeConfig = ({ key, title, reward = null }) => { - return { - key, - title, - nodes: sharedDifficultyNodes, - details: sharedDifficultyDetails, - activeDifficultyId: mockedUnlockedDifficultyId, - progressMap: mockedDifficultyProgressMap, - reward, - }; -}; - -// 难度页数据源入口: -// 页面通过 getTrainingDifficultyModeConfig(modeKey) 获取当前模式完整配置。 -export const trainingDifficultyModeMap = Object.fromEntries( - modeList.map((mode) => [mode.key, createModeConfig(mode)]) -); - -export const getTrainingDifficultyModeConfig = (modeKey) => { - return trainingDifficultyModeMap[modeKey] || trainingDifficultyModeMap.precision; -}; diff --git a/src/pages/audio-test.vue b/src/pages/audio-test.vue index 2bef875..31c6f55 100644 --- a/src/pages/audio-test.vue +++ b/src/pages/audio-test.vue @@ -9,17 +9,23 @@ const playAudio = (key) => { audioManager.play(key); }; +const onAudioLoaded = (key) => { + loaded.value = { + ...loaded.value, + [key]: true, + }; +}; + onMounted(() => { const loadedAudioKeys = uni.getStorageSync("loadedAudioKeys") || {}; loaded.value = loadedAudioKeys; - uni.$on("audioLoaded", (key) => { - loaded.value[key] = true; - }); + uni.$on("audioLoaded", onAudioLoaded); + void audioManager.initAudios(); }); onBeforeUnmount(() => { - uni.$off("audioLoaded"); + uni.$off("audioLoaded", onAudioLoaded); }); @@ -40,8 +46,10 @@ onBeforeUnmount(() => { {{ key }} - 未加载 - + {{ loaded[key] ? "已加载" : "未加载" }} + diff --git a/src/pages/mine-bow-data.vue b/src/pages/mine-bow-data.vue index 22a57cb..1217819 100644 --- a/src/pages/mine-bow-data.vue +++ b/src/pages/mine-bow-data.vue @@ -1,25 +1,70 @@ @@ -35,22 +80,29 @@ onLoad(async (options) => { --> + + {{ targetTypeText }} + {{ trainingTypeName }} + {{ difficultyText }} + - + {{ arrows.length }} 支箭,共 - {{ arrows.reduce((a, b) => a + b.ring, 0) }} + {{ totalRings }} - @@ -63,6 +115,20 @@ onLoad(async (options) => { justify-content: center; align-items: center; } +.practice-meta { + width: 100%; + display: flex; + justify-content: center; + align-items: center; + color: #fff; + font-size: 26rpx; + font-weight: 600; + line-height: 40rpx; + padding: 16rpx 0; +} +.practice-meta > text + text { + margin-left: 24rpx; +} .header { display: flex; justify-content: space-between; diff --git a/src/pages/my-growth.vue b/src/pages/my-growth.vue index 5a2e3b8..35f4e3d 100644 --- a/src/pages/my-growth.vue +++ b/src/pages/my-growth.vue @@ -15,6 +15,25 @@ const selectedIndex = ref(0); const matchList = ref([]); const battleList = ref([]); const practiseList = ref([]); +const trainingTypeNameMap = Object.freeze({ + base: "基础训练", + endurance: "耐力训练", + precision: "精准训练", + rhythm: "节奏训练", +}); + +const getTrainingTypeName = (trainingType) => { + const normalizedType = String(trainingType || "").trim().toLowerCase(); + return trainingTypeNameMap[normalizedType] || "自由训练"; +}; + +const formatPractiseTime = (value) => { + const normalizedTime = String(value || "").trim(); + const matchedTime = normalizedTime.match( + /^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2})/ + ); + return matchedTime ? `${matchedTime[1]} ${matchedTime[2]}` : normalizedTime; +}; const toMatchDetail = (id) => { uni.navigateTo({ @@ -81,7 +100,7 @@ onLoad((options) => { getPractiseDetail(item.id)" > {{ item.completed_arrows === 36 ? "耐力挑战" : "单组练习" }} - {{ item.createTime }}{{ getTrainingTypeName(item.trainingType) }} + {{ formatPractiseTime(item.createTime) }} diff --git a/src/pages/team-battle/index.vue b/src/pages/team-battle/index.vue index 65998e4..239cad1 100644 --- a/src/pages/team-battle/index.vue +++ b/src/pages/team-battle/index.vue @@ -20,7 +20,7 @@ import { MATCH_WS_STATE_EVENT, } from "@/matchWebsocket"; import { MESSAGETYPESV2 } from "@/constants"; -import { getDirectionText } from "@/util"; +import { getDirectionText, getInvalidShotAudioKey } from "@/util"; import { takeMatchReturnSnapshot } from "@/utils/matchReturn"; import audioManager, { AUDIO_INTERRUPTION_BEGIN_EVENT, @@ -1136,7 +1136,9 @@ async function runInvalidShotTask(task, runId) { title: "距离不足,无效", icon: "none", }); - await playAudioKeys("射击无效", { interrupt: false }); + await playAudioKeys(getInvalidShotAudioKey(task.message?.shootData), { + interrupt: false, + }); notifyMatchAudioAck(task); } diff --git a/src/pages/training/components/BowTarget.vue b/src/pages/training/components/BowTarget.vue index 550a43d..719a150 100644 --- a/src/pages/training/components/BowTarget.vue +++ b/src/pages/training/components/BowTarget.vue @@ -44,6 +44,10 @@ const props = defineProps({ type: Number, default: 0, }, + highlightRefreshToken: { + type: Number, + default: 0, + }, mode: { type: String, default: "solo", // solo 单排,team 双排 @@ -530,6 +534,7 @@ onBeforeUnmount(() => { :sectorCount="sectorCount" :activeSector="activeSector" :activeRing="activeRing" + :highlightRefreshToken="highlightRefreshToken" :showSectorLabels="showSectorLabels" /> diff --git a/src/pages/training/components/ShootProgress.vue b/src/pages/training/components/ShootProgress.vue index bba3816..7de4571 100644 --- a/src/pages/training/components/ShootProgress.vue +++ b/src/pages/training/components/ShootProgress.vue @@ -2,7 +2,7 @@ import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue"; import audioManager from "@/audioManager"; import { MESSAGETYPESV2 } from "@/constants"; -import { getDirectionText } from "@/util"; +import { getDirectionText, getInvalidShotAudioKey } from "@/util"; import Avatar from "@/components/Avatar.vue"; import useStore from "@/store"; @@ -241,7 +241,7 @@ async function onReceiveMessage(msg) { title: "距离不足,无效", icon: "none", }); - audioManager.play("射击无效"); + audioManager.play(getInvalidShotAudioKey(msg.shootData)); } } diff --git a/src/pages/training/components/TestDistance.vue b/src/pages/training/components/TestDistance.vue index 2c43ade..75e893b 100644 --- a/src/pages/training/components/TestDistance.vue +++ b/src/pages/training/components/TestDistance.vue @@ -55,8 +55,13 @@ onBeforeUnmount(() => { async function onReceiveMessage(msg) { if (Array.isArray(msg)) return; if (msg.type === MESSAGETYPESV2.TestDistance) { - distance.value = Number((msg.shootData.distance / 100).toFixed(2)); - if (distance.value >= 5) audioManager.play("距离合格"); + const rawDistance = Number(msg.shootData?.distance); + distance.value = Number.isFinite(rawDistance) + ? Number((rawDistance / 100).toFixed(2)) + : 0; + if (rawDistance === 0) { + audioManager.play("未发现靶纸,请瞄准靶纸射箭"); + } else if (distance.value >= 5) audioManager.play("距离合格"); else audioManager.play("距离不足"); } } @@ -94,7 +99,7 @@ onBeforeUnmount(() => { 模拟射箭 - 当前靶子为{{ targetType }}cm全环靶,请更换靶子 + 当前靶纸为{{ targetType }}cm全环靶 当前距离{{ distance }} 已达到距离要求 diff --git a/src/pages/training/difficulty.vue b/src/pages/training/difficulty.vue index fb6b9d2..6320012 100644 --- a/src/pages/training/difficulty.vue +++ b/src/pages/training/difficulty.vue @@ -107,30 +107,27 @@ const createDifficultySummary = (item = {}) => { const timeLimit = toNumber(item.time_limit); const hitReq = toNumber(item.hit_req); const totalReq = toNumber(item.total_req); - const blocks = toNumber(item.blocks); const promoteCnt = toNumber(item.promote_cnt); - const timeText = timeLimit > 0 ? `${timeLimit}秒内完成` : "不限时完成"; + const shootingTimeText = + timeLimit > 0 ? `在${timeLimit}秒内进行射箭` : "不限时进行射箭"; + const enduranceTimeText = + timeLimit > 0 + ? `在${timeLimit}秒内完成${arrows}箭` + : `不限时完成${arrows}箭`; const promoteText = promoteCnt > 0 ? `完成${promoteCnt}次晋级` : ""; const summaryMap = { base: [ - desc || (hitReq > 0 ? `每箭命中${hitReq}环以上` : "上靶即可"), - [`${arrows}箭`, promoteText].filter(Boolean).join(" · "), + shootingTimeText, + `需要有${arrows}箭命中${hitReq}环内`, ], endurance: [ - desc || `${timeText}${arrows}箭`, - [`累计${totalReq}环`, promoteText].filter(Boolean).join(" · "), + enduranceTimeText, + `且累计环数大于${totalReq}环`, ], precision: [ - desc || `命中${blocks}个指定区域`, - [ - `${arrows}箭`, - timeText, - getDifficultyModeText(item.mode), - promoteText, - ] - .filter(Boolean) - .join(" · "), + shootingTimeText, + `需要有${arrows}箭命中高亮区域`, ], rhythm: [ desc || `间隔${timeLimit}秒射击`, diff --git a/src/pages/training/index.vue b/src/pages/training/index.vue index 3687fe0..50f7e4b 100644 --- a/src/pages/training/index.vue +++ b/src/pages/training/index.vue @@ -64,8 +64,8 @@ const createDefaultTrainingData = () => ({ stats: { total_training_days: 0, total_arrows: 0, - hit_rate: 0, - endurance_shoot_speed: 0, + target_rate: 0, + ten_ring_count: 0, total_calories: 0, }, beat_percent: 0, @@ -286,8 +286,8 @@ const loadPersonalTrainingData = async () => { stats: { total_training_days: result?.stats?.total_training_days ?? 0, total_arrows: result?.stats?.total_arrows ?? 0, - hit_rate: result?.stats?.hit_rate ?? 0, - endurance_shoot_speed: result?.stats?.endurance_shoot_speed ?? 0, + target_rate: result?.stats?.target_rate ?? 0, + ten_ring_count: result?.stats?.ten_ring_count ?? 0, total_calories: result?.stats?.total_calories ?? 0, }, beat_percent: result?.beat_percent ?? 0, @@ -431,26 +431,26 @@ onShow(async () => { - {{ formatValue(trainingData.stats.hit_rate) }} + {{ formatValue(trainingData.stats.target_rate) }} % - 命中率 + 上靶率 - {{ formatValue(trainingData.stats.endurance_shoot_speed, 0) }} + {{ formatValue(trainingData.stats.ten_ring_count, 0) }} - 支/分钟 + - 耐力射击 + 10环数 diff --git a/src/pages/training/practise-one.vue b/src/pages/training/practise-one.vue index d91e292..ed17c61 100644 --- a/src/pages/training/practise-one.vue +++ b/src/pages/training/practise-one.vue @@ -4,7 +4,7 @@ import { onHide, onLoad, onShow, onUnload } from "@dcloudio/uni-app"; import Container from "@/components/Container.vue"; import ShootProgress from "./components/ShootProgress.vue"; import BowTarget from "./components/BowTarget.vue"; -import ScorePanel2 from "./components/ScorePanel2.vue"; +import ScorePanel2 from "@/components/TrainingScorePanel.vue"; import ScoreResult from "./components/ScoreResult.vue"; import Avatar from "@/components/Avatar.vue"; import BowPower from "@/components/BowPower.vue"; @@ -48,6 +48,8 @@ const pageStage = ref(pageStages.LOADING); const scores = ref([]); // 只在实时 ShootResult 新增一箭时递增,避免同步快照重播飞箭特效。 const shotEffectToken = ref(0); +// 可见区域每次正式提交都递增,同一区域连续刷新也能触发动效。 +const precisionTargetRefreshToken = ref(0); const defaultTotal = 12; const defaultTargetType = 1; const total = ref(defaultTotal); @@ -253,17 +255,23 @@ const trainingCopy = computed(() => { practiceInfo.value.hitReq, trainingParams.value.hitReq ); - const arrowsLeft = getPracticeNumber( - practiceInfo.value.arrowsLeft, - total.value + const targetArrows = getPositiveInteger(total.value); + const arrowsLeft = Math.min( + targetArrows, + Math.max( + 0, + getPracticeNumber(practiceInfo.value.arrowsLeft, targetArrows) + ) ); + const completedArrows = targetArrows - arrowsLeft; return { - title: `每箭命中${hitReq}环之上`, + inline: true, details: [ - { text: "剩余" }, - { text: arrowsLeft, highlight: true }, - { text: "箭达到条件" }, + { text: "计时结束前需要有" }, + { text: `(${completedArrows}/${targetArrows})`, highlight: true }, + { text: "箭命中" }, + { text: `${hitReq}环`, highlight: true }, ], }; } @@ -281,35 +289,33 @@ const trainingCopy = computed(() => { const currentRings = getPracticeNumber(practiceInfo.value.currentRings); return { - title: `完成${targetArrows}箭并累计${targetRings}环`, + inline: true, details: [ - { text: "已完成" }, - { text: currentArrows, highlight: true }, - { text: "箭,累计" }, - { text: currentRings, highlight: true }, + { text: "计时结束前完成" }, + { text: `(${currentArrows}/${targetArrows})`, highlight: true }, + { text: "箭且累计命中" }, + { text: `(${currentRings}/${targetRings})`, highlight: true }, { text: "环" }, ], }; } if (trainingType.value === "precision") { - const block = precisionRandomBlock.value; - const ring = precisionRandomRingArea.value; - const arrowsLeft = getPracticeNumber( - practiceInfo.value.arrowsLeft, - total.value + const targetArrows = getPositiveInteger(total.value); + const arrowsLeft = Math.min( + targetArrows, + Math.max( + 0, + getPracticeNumber(practiceInfo.value.arrowsLeft, targetArrows) + ) ); - const title = block - ? ring - ? `请命中区域${block}的${ring}环` - : `请命中区域${block}` - : "等待目标区域"; + const completedArrows = targetArrows - arrowsLeft; return { - title, + inline: true, details: [ - { text: "剩余" }, - { text: arrowsLeft, highlight: true }, + { text: "射箭命中高亮区域需完成" }, + { text: `(${completedArrows}/${targetArrows})`, highlight: true }, { text: "箭" }, ], }; @@ -563,7 +569,10 @@ const commitPrecisionTargetAfterPresentation = async ({ ) { return; } - visiblePrecisionTarget.value = target; + applyVisiblePrecisionTarget(target); + if (precisionRandomBlock.value > 0) { + precisionTargetRefreshToken.value += 1; + } }; const createPracticeEndSnapshot = (message = {}) => { @@ -1329,6 +1338,7 @@ onBeforeUnmount(() => { :sectorCount="precisionBlocks" :activeSector="precisionRandomBlock" :activeRing="precisionRandomRingArea" + :highlightRefreshToken="precisionTargetRefreshToken" :showSectorLabels="precisionBlocks > 0" stable-shot-effect @shot-effect-complete="onShotEffectComplete" @@ -1349,7 +1359,7 @@ onBeforeUnmount(() => { 重置高亮 --> - + + + { - {{ trainingCopy.title }} - + {{ part.text }} + + {{ trainingCopy.title }} + + {{ part.text }} + + @@ -1386,7 +1407,11 @@ onBeforeUnmount(() => { :enhanced="true" :show-scrollbar="false" > - + { margin-left: 16rpx; } +.sound-row { + height: 70rpx; + padding: 0 56rpx; + display: flex; + align-items: center; +} .sound-text-box{ height: 125rpx; padding: 0 56rpx; @@ -1503,6 +1534,9 @@ onBeforeUnmount(() => { .sound-btn { width: 76rpx; height: 70rpx; + padding: 0; + margin: 0; + background: transparent; border: none; } @@ -1515,7 +1549,7 @@ onBeforeUnmount(() => { height: 70rpx; } .bat-text-big-box{ - flex: 1; + width: 100%; position: relative; } .dao-icon{ @@ -1530,11 +1564,13 @@ onBeforeUnmount(() => { } .bat-text-box{ display: flex; + width: 100%; } .bat-text-small-box{ background: rgba(0, 0, 0, 0.5); - width: auto; + width: 100%; min-width: 100rpx; + box-sizing: border-box; border-radius: 16rpx 60rpx 60rpx 16rpx; display: flex; flex-direction: column; @@ -1545,6 +1581,15 @@ onBeforeUnmount(() => { font-size: 30rpx; color: #E7BA80; } +.training-copy-inline { + width: 100%; + color: #FFFFFF; + font-size: 26rpx; + font-weight: 400; + line-height: 40rpx; + white-space: normal; + word-break: break-all; +} .text1{ font-size: 30rpx; font-weight: 400; diff --git a/src/static/my-practise.png b/src/static/my-practise.png index cc608ce..a6a0722 100644 Binary files a/src/static/my-practise.png and b/src/static/my-practise.png differ diff --git a/src/static/training-home/img_22.png b/src/static/training-home/img_22.png index 5caeef0..4d9d63f 100644 Binary files a/src/static/training-home/img_22.png and b/src/static/training-home/img_22.png differ diff --git a/src/util.js b/src/util.js index 484b686..0de566a 100644 --- a/src/util.js +++ b/src/util.js @@ -329,6 +329,18 @@ export const getDirectionText = (angle = 0) => { } }; +// 正式射箭阶段的距离单位为厘米,按距离异常类型选择对应语音。 +export const getInvalidShotAudioKey = (shootData) => { + if (!shootData || typeof shootData !== "object") return "射击无效"; + // protobuf 会省略值为 0 的标量字段;消息体存在且距离缺失时按 0 处理。 + const rawDistance = Number(shootData.distance ?? shootData.dst ?? 0); + if (!Number.isFinite(rawDistance)) return "射击无效"; + if (rawDistance < 0) return "射箭无效,靶纸错误"; + if (rawDistance === 0) return "射箭无效,未识别到靶纸"; + if (rawDistance / 100 < 5) return "射箭无效,距离不足"; + return "射击无效"; +}; + export const wxLogin = () => { return new Promise((resolve, reject) => { uni.login({ diff --git a/src/utils/match.min.js b/src/utils/match.min.js index 4803dfe..87f6493 100644 --- a/src/utils/match.min.js +++ b/src/utils/match.min.js @@ -1,4 +1,4 @@ /* eslint-disable */ import * as $protobuf from "protobufjs"; -const $root=$protobuf.Root.create({"nested":{"rpc":{"nested":{"ServerMessageType":{"SERVER_MSG_UNKNOWN":0,"SERVER_MSG_MATCH_READY":1,"SERVER_MSG_MATCH_START":2,"SERVER_MSG_NOW_YOU":3,"SERVER_MSG_SHOT":4,"SERVER_MSG_NEW_ROUND":5,"SERVER_MSG_MATCH_END":6,"SERVER_MSG_TIMEOUT":7,"SERVER_MSG_CHECK":8,"SERVER_MSG_RAND":9,"SERVER_MSG_NOT_ENOUGH_DISTANCE":10,"SERVER_MSG_PLAYER_LEFT":11,"SERVER_MSG_HEARTBEAT":12,"SERVER_MSG_PRACTICE_END":13,"SERVER_MSG_SYNC_PRACTICE_INFO":14,"SERVER_MSG_SYNC_MATCH_INFO":15},"ClientMessageType":{"CLIENT_MSG_UNKNOWN":0,"CLIENT_MSG_HEARTBEAT_ACK":1,"CLIENT_MSG_SHOOT_DATA":2,"CLIENT_MSG_ACK":3,"CLIENT_MSG_LEAVE":4,"CLIENT_MSG_SYNC_PRACTICE_INFO":5,"CLIENT_MSG_SYNC_MATCH_INFO":6},"MatchStatus":{"MATCH_STATUS_READY":0,"MATCH_STATUS_STARTED":1,"MATCH_STATUS_END":2,"MATCH_STATUS_TIMEOUT":3,"MATCH_STATUS_UNEXPECTEDLY":4},"MatchPlayerStatus":{"MATCH_PLAYER_STATUS_READY":0,"MATCH_PLAYER_STATUS_STARTED":1,"MATCH_PLAYER_STATUS_END":2},"MatchShoot":{"fields":{"playerId":{"type":"int64","id":1,"protoName":"player_id"},"status":{"type":"int32","id":2},"x":{"type":"float","id":3},"y":{"type":"float","id":4},"ring":{"type":"int32","id":5},"ringX":{"type":"bool","id":6,"protoName":"ring_x"},"angle":{"type":"float","id":7},"distance":{"type":"float","id":8},"threeConsecutive_10Rings":{"type":"bool","id":9,"protoName":"three_consecutive_10_rings"}}},"MatchShootList":{"fields":{"items":{"type":"MatchShoot","id":1,"rule":"repeated"}}},"RoundScore":{"fields":{"totalRing":{"type":"int32","id":1,"protoName":"total_ring"},"score":{"type":"int32","id":2},"ifWin":{"type":"bool","id":3,"protoName":"if_win"}}},"MatchRound":{"fields":{"shoots":{"type":"MatchShootList","id":1,"keyType":"int64"},"scores":{"type":"RoundScore","id":2,"keyType":"int32"},"round":{"type":"int32","id":3},"ifGold":{"type":"bool","id":4,"protoName":"if_gold"},"status":{"type":"int32","id":5},"goldRound":{"type":"int32","id":6,"protoName":"gold_round"}}},"PlayerMatchResult":{"fields":{"totalRing":{"type":"int32","id":1,"protoName":"total_ring"},"userId":{"type":"int64","id":2,"protoName":"user_id"},"tenRingCount":{"type":"int32","id":3,"protoName":"ten_ring_count"},"averageRing":{"type":"float","id":4,"protoName":"average_ring"}}},"PlayerFull":{"fields":{"id":{"type":"int64","id":1},"name":{"type":"string","id":2},"avatar":{"type":"string","id":3},"exp":{"type":"int32","id":4},"score":{"type":"int32","id":5},"level":{"type":"int32","id":6},"beforeLevel":{"type":"int32","id":7,"protoName":"before_level"},"beforeExp":{"type":"int32","id":8,"protoName":"before_exp"},"currentExp":{"type":"int32","id":9,"protoName":"current_exp"},"upgradeExp":{"type":"int32","id":10,"protoName":"upgrade_exp"},"active":{"type":"int32","id":11},"deviceId":{"type":"string","id":12,"protoName":"device_id"},"sVip":{"type":"bool","id":13,"protoName":"s_vip"},"vip":{"type":"bool","id":14},"playerMatchResult":{"type":"PlayerMatchResult","id":15,"protoName":"player_match_result"}}},"TeamInfo":{"fields":{"players":{"type":"PlayerFull","id":1,"rule":"repeated"},"id":{"type":"int32","id":2},"name":{"type":"string","id":3},"score":{"type":"int32","id":4}}},"CurrentShoot":{"fields":{"round":{"type":"int32","id":1},"roundId":{"type":"int64","id":2,"protoName":"round_id"},"index":{"type":"int32","id":3},"startTime":{"type":"int64","id":4,"protoName":"start_time"},"playerId":{"type":"int64","id":5,"protoName":"player_id"},"goldRound":{"type":"bool","id":6,"protoName":"gold_round"},"startTimeText":{"type":"string","id":7,"protoName":"start_time_text"},"myIndex":{"type":"int32","id":8,"protoName":"my_index"},"indexMap":{"type":"int32","id":9,"keyType":"int64","protoName":"index_map"},"ackTime":{"type":"int64","id":10,"protoName":"ack_time"}}},"ShootData":{"fields":{"x":{"type":"float","id":1},"y":{"type":"float","id":2},"r":{"type":"float","id":3},"dst":{"type":"float","id":4},"m":{"type":"string","id":5},"adc":{"type":"float","id":6},"deviceId":{"type":"string","id":7,"protoName":"device_id"},"shootId":{"type":"string","id":8,"protoName":"shoot_id"},"threeConsecutive_10Rings":{"type":"bool","id":9,"protoName":"three_consecutive_10_rings"}}},"PracticeInfo":{"fields":{"id":{"type":"int64","id":1},"userId":{"type":"int64","id":2,"protoName":"user_id"},"status":{"type":"int32","id":3},"statusText":{"type":"string","id":4,"protoName":"status_text"},"startTime":{"type":"int64","id":5,"protoName":"start_time"},"targetType":{"type":"int32","id":6,"protoName":"target_type"},"vip":{"type":"bool","id":7},"sVip":{"type":"bool","id":8,"protoName":"s_vip"},"deviceId":{"type":"string","id":9,"protoName":"device_id"},"shootData":{"type":"MatchShoot","id":10,"protoName":"shoot_data"},"details":{"type":"MatchShoot","id":11,"rule":"repeated"},"trainingType":{"type":"string","id":12,"protoName":"training_type"},"difficultyLevel":{"type":"int32","id":13,"protoName":"difficulty_level"},"hitReq":{"type":"int32","id":14,"protoName":"hit_req"},"arrowsLeft":{"type":"int32","id":15,"protoName":"arrows_left"},"targetArrows":{"type":"int32","id":16,"protoName":"target_arrows"},"targetRings":{"type":"int32","id":17,"protoName":"target_rings"},"currentArrows":{"type":"int32","id":18,"protoName":"current_arrows"},"currentRings":{"type":"int32","id":19,"protoName":"current_rings"},"blocks":{"type":"int32","id":20},"randomBlock":{"type":"int32","id":21,"protoName":"random_block"},"randomRingArea":{"type":"int32","id":22,"protoName":"random_ring_area"},"timeLimit":{"type":"int32","id":23,"protoName":"time_limit"},"completed":{"type":"bool","id":24},"totalArrows":{"type":"int32","id":25,"protoName":"total_arrows"},"duration":{"type":"int32","id":26},"averageRing":{"type":"float","id":27,"protoName":"average_ring"},"stability":{"type":"float","id":28},"maxCombo":{"type":"int32","id":29,"protoName":"max_combo"},"totalHits":{"type":"int32","id":30,"protoName":"total_hits"},"deltaTotalHits":{"type":"int32","id":31,"protoName":"delta_total_hits"},"deltaDuration":{"type":"int32","id":32,"protoName":"delta_duration"},"deltaMaxCombo":{"type":"int32","id":33,"protoName":"delta_max_combo"},"deltaTotalRings":{"type":"int32","id":34,"protoName":"delta_total_rings"},"deltaTotalArrows":{"type":"int32","id":35,"protoName":"delta_total_arrows"},"deltaAverageRing":{"type":"float","id":36,"protoName":"delta_average_ring"},"deltaStability":{"type":"float","id":37,"protoName":"delta_stability"},"beforeExp":{"type":"int32","id":38,"protoName":"before_exp"},"beforeLevel":{"type":"int32","id":39,"protoName":"before_level"},"currentExp":{"type":"int32","id":40,"protoName":"current_exp"},"level":{"type":"int32","id":41},"upgradeExp":{"type":"int32","id":42,"protoName":"upgrade_exp"},"calories":{"type":"double","id":43}}},"MatchInfo":{"fields":{"matchId":{"type":"string","id":1,"protoName":"match_id"},"createTime":{"type":"int64","id":2,"protoName":"create_time"},"startTime":{"type":"int64","id":3,"protoName":"start_time"},"serverTime":{"type":"int64","id":4,"protoName":"server_time"},"shootTime":{"type":"int32","id":5,"protoName":"shoot_time"},"shootNumber":{"type":"int32","id":6,"protoName":"shoot_number"},"readyTime":{"type":"int32","id":7,"protoName":"ready_time"},"way":{"type":"int32","id":8},"mode":{"type":"int32","id":9},"status":{"type":"MatchStatus","id":10},"statusText":{"type":"string","id":11,"protoName":"status_text"},"rounds":{"type":"MatchRound","id":12,"rule":"repeated"},"teams":{"type":"TeamInfo","id":13,"keyType":"int32"},"current":{"type":"CurrentShoot","id":14},"next":{"type":"CurrentShoot","id":15},"shootData":{"type":"MatchShoot","id":16,"protoName":"shoot_data"},"winTeam":{"type":"int32","id":17,"protoName":"win_team"},"mvp":{"type":"PlayerFull","id":18},"roomId":{"type":"string","id":19,"protoName":"room_id"},"resultList":{"type":"PlayerMatchResult","id":20,"rule":"repeated","protoName":"result_list"},"timeoutTime":{"type":"int64","id":21,"protoName":"timeout_time"},"targetType":{"type":"int32","id":22,"protoName":"target_type"},"eventType":{"type":"int32","id":23,"protoName":"event_type"},"timeout":{"type":"int32","id":24},"serverAddr":{"type":"string","id":25,"protoName":"server_addr"},"countdownStartTime":{"type":"int64","id":26,"protoName":"countdown_start_time"}}},"ServerMessage":{"fields":{"type":{"type":"ServerMessageType","id":1},"matchId":{"type":"string","id":2,"protoName":"match_id"},"timestamp":{"type":"int64","id":3},"matchInfo":{"type":"MatchInfo","id":4,"protoName":"match_info"},"shootData":{"type":"ShootData","id":5,"protoName":"shoot_data"},"practiceInfo":{"type":"PracticeInfo","id":6,"protoName":"practice_info"},"sequence":{"type":"int64","id":7}}},"ClientMessage":{"fields":{"type":{"type":"ClientMessageType","id":1},"matchId":{"type":"string","id":2,"protoName":"match_id"},"userId":{"type":"int64","id":3,"protoName":"user_id"},"sequence":{"type":"int64","id":4},"data":{"type":"bytes","id":5}}}}}}}); +const $root=$protobuf.Root.create({"nested":{"rpc":{"ServerMessageType":{"SERVER_MSG_UNKNOWN":0,"SERVER_MSG_MATCH_READY":1,"SERVER_MSG_MATCH_START":2,"SERVER_MSG_NOW_YOU":3,"SERVER_MSG_SHOT":4,"SERVER_MSG_NEW_ROUND":5,"SERVER_MSG_MATCH_END":6,"SERVER_MSG_TIMEOUT":7,"SERVER_MSG_CHECK":8,"SERVER_MSG_RAND":9,"SERVER_MSG_NOT_ENOUGH_DISTANCE":10,"SERVER_MSG_PLAYER_LEFT":11,"SERVER_MSG_HEARTBEAT":12,"SERVER_MSG_PRACTICE_END":13,"SERVER_MSG_SYNC_PRACTICE_INFO":14,"SERVER_MSG_SYNC_MATCH_INFO":15},"ClientMessageType":{"CLIENT_MSG_UNKNOWN":0,"CLIENT_MSG_HEARTBEAT_ACK":1,"CLIENT_MSG_SHOOT_DATA":2,"CLIENT_MSG_ACK":3,"CLIENT_MSG_LEAVE":4,"CLIENT_MSG_SYNC_PRACTICE_INFO":5,"CLIENT_MSG_SYNC_MATCH_INFO":6},"MatchStatus":{"MATCH_STATUS_READY":0,"MATCH_STATUS_STARTED":1,"MATCH_STATUS_END":2,"MATCH_STATUS_TIMEOUT":3,"MATCH_STATUS_UNEXPECTEDLY":4},"MatchPlayerStatus":{"MATCH_PLAYER_STATUS_READY":0,"MATCH_PLAYER_STATUS_STARTED":1,"MATCH_PLAYER_STATUS_END":2},"MatchShoot":{"fields":{"player_id":{"type":"int64","id":1},"status":{"type":"int32","id":2},"x":{"type":"float","id":3},"y":{"type":"float","id":4},"ring":{"type":"int32","id":5},"ring_x":{"type":"bool","id":6},"angle":{"type":"float","id":7},"distance":{"type":"float","id":8},"three_consecutive_10_rings":{"type":"bool","id":9},"ok":{"type":"bool","id":10}}},"MatchShootList":{"fields":{"items":{"type":"MatchShoot","id":1,"rule":"repeated"}}},"RoundScore":{"fields":{"total_ring":{"type":"int32","id":1},"score":{"type":"int32","id":2},"if_win":{"type":"bool","id":3}}},"MatchRound":{"fields":{"shoots":{"type":"MatchShootList","id":1,"keytype":"int64"},"scores":{"type":"RoundScore","id":2,"keytype":"int32"},"round":{"type":"int32","id":3},"if_gold":{"type":"bool","id":4},"status":{"type":"int32","id":5},"gold_round":{"type":"int32","id":6}}},"PlayerMatchResult":{"fields":{"total_ring":{"type":"int32","id":1},"user_id":{"type":"int64","id":2},"ten_ring_count":{"type":"int32","id":3},"average_ring":{"type":"float","id":4}}},"PlayerFull":{"fields":{"id":{"type":"int64","id":1},"name":{"type":"string","id":2},"avatar":{"type":"string","id":3},"exp":{"type":"int32","id":4},"score":{"type":"int32","id":5},"level":{"type":"int32","id":6},"before_level":{"type":"int32","id":7},"before_exp":{"type":"int32","id":8},"current_exp":{"type":"int32","id":9},"upgrade_exp":{"type":"int32","id":10},"active":{"type":"int32","id":11},"device_id":{"type":"string","id":12},"s_vip":{"type":"bool","id":13},"vip":{"type":"bool","id":14},"player_match_result":{"type":"PlayerMatchResult","id":15},"rank_lvl":{"type":"int32","id":16},"rank_name":{"type":"string","id":17},"rank_icon":{"type":"string","id":18}}},"TeamInfo":{"fields":{"players":{"type":"PlayerFull","id":1,"rule":"repeated"},"id":{"type":"int32","id":2},"name":{"type":"string","id":3},"score":{"type":"int32","id":4}}},"CurrentShoot":{"fields":{"round":{"type":"int32","id":1},"round_id":{"type":"int64","id":2},"index":{"type":"int32","id":3},"start_time":{"type":"int64","id":4},"player_id":{"type":"int64","id":5},"gold_round":{"type":"bool","id":6},"start_time_text":{"type":"string","id":7},"my_index":{"type":"int32","id":8},"index_map":{"type":"int32","id":9,"keytype":"int64"},"ack_time":{"type":"int64","id":10}}},"ShootData":{"fields":{"x":{"type":"float","id":1},"y":{"type":"float","id":2},"r":{"type":"float","id":3},"dst":{"type":"float","id":4},"m":{"type":"string","id":5},"adc":{"type":"float","id":6},"device_id":{"type":"string","id":7},"shoot_id":{"type":"string","id":8},"three_consecutive_10_rings":{"type":"bool","id":9}}},"PracticeInfo":{"fields":{"id":{"type":"int64","id":1},"user_id":{"type":"int64","id":2},"status":{"type":"int32","id":3},"status_text":{"type":"string","id":4},"start_time":{"type":"int64","id":5},"target_type":{"type":"int32","id":6},"vip":{"type":"bool","id":7},"s_vip":{"type":"bool","id":8},"device_id":{"type":"string","id":9},"shoot_data":{"type":"MatchShoot","id":10},"details":{"type":"MatchShoot","id":11,"rule":"repeated"},"training_type":{"type":"string","id":12},"difficulty_level":{"type":"int32","id":13},"hit_req":{"type":"int32","id":14},"arrows_left":{"type":"int32","id":15},"target_arrows":{"type":"int32","id":16},"target_rings":{"type":"int32","id":17},"current_arrows":{"type":"int32","id":18},"current_rings":{"type":"int32","id":19},"blocks":{"type":"int32","id":20},"random_block":{"type":"int32","id":21},"random_ring_area":{"type":"int32","id":22},"score_slot":{"type":"int32","id":44},"current_energy":{"type":"int32","id":45},"energy_cost_per_sec":{"type":"int32","id":46},"energy_per_hit":{"type":"int32","id":47},"energy_req_percent":{"type":"int32","id":48},"round_time":{"type":"int32","id":50},"shoot_time":{"type":"int32","id":53},"shoot_window_start":{"type":"int64","id":51},"in_shoot_window":{"type":"bool","id":52},"time_limit":{"type":"int32","id":23},"completed":{"type":"bool","id":24},"total_arrows":{"type":"int32","id":25},"duration":{"type":"int32","id":26},"average_ring":{"type":"float","id":27},"stability":{"type":"float","id":28},"max_combo":{"type":"int32","id":29},"total_hits":{"type":"int32","id":30},"delta_total_hits":{"type":"int32","id":31},"delta_duration":{"type":"int32","id":32},"delta_max_combo":{"type":"int32","id":33},"delta_total_rings":{"type":"int32","id":34},"delta_total_arrows":{"type":"int32","id":35},"delta_average_ring":{"type":"float","id":36},"delta_stability":{"type":"float","id":37},"delta_current_energy":{"type":"int32","id":49},"before_exp":{"type":"int32","id":38},"before_level":{"type":"int32","id":39},"current_exp":{"type":"int32","id":40},"level":{"type":"int32","id":41},"upgrade_exp":{"type":"int32","id":42},"calories":{"type":"double","id":43}}},"MatchInfo":{"fields":{"match_id":{"type":"string","id":1},"create_time":{"type":"int64","id":2},"start_time":{"type":"int64","id":3},"server_time":{"type":"int64","id":4},"shoot_time":{"type":"int32","id":5},"shoot_number":{"type":"int32","id":6},"ready_time":{"type":"int32","id":7},"way":{"type":"int32","id":8},"mode":{"type":"int32","id":9},"status":{"type":"MatchStatus","id":10},"status_text":{"type":"string","id":11},"rounds":{"type":"MatchRound","id":12,"rule":"repeated"},"teams":{"type":"TeamInfo","id":13,"keytype":"int32"},"current":{"type":"CurrentShoot","id":14},"next":{"type":"CurrentShoot","id":15},"shoot_data":{"type":"MatchShoot","id":16},"win_team":{"type":"int32","id":17},"mvp":{"type":"PlayerFull","id":18},"room_id":{"type":"string","id":19},"result_list":{"type":"PlayerMatchResult","id":20,"rule":"repeated"},"timeout_time":{"type":"int64","id":21},"target_type":{"type":"int32","id":22},"event_type":{"type":"int32","id":23},"timeout":{"type":"int32","id":24},"server_addr":{"type":"string","id":25},"countdown_start_time":{"type":"int64","id":26}}},"ServerMessage":{"fields":{"type":{"type":"ServerMessageType","id":1},"match_id":{"type":"string","id":2},"timestamp":{"type":"int64","id":3},"match_info":{"type":"MatchInfo","id":4},"shoot_data":{"type":"ShootData","id":5},"practice_info":{"type":"PracticeInfo","id":6},"sequence":{"type":"int64","id":7}}},"ClientMessage":{"fields":{"type":{"type":"ClientMessageType","id":1},"match_id":{"type":"string","id":2},"user_id":{"type":"int64","id":3},"sequence":{"type":"int64","id":4},"data":{"type":"bytes","id":5}}}}}}); export default $root; diff --git a/src/utils/matchProtocol.js b/src/utils/matchProtocol.js index c6134a4..68fadfb 100644 --- a/src/utils/matchProtocol.js +++ b/src/utils/matchProtocol.js @@ -7,8 +7,8 @@ const { Reader, Writer } = protobuf; // 所以这里使用 minimal Reader/Writer 做静态字段解码和客户端消息编码。 // // 此区块由 scripts/generate-match-schema.mjs 自动生成,请勿手动修改。 -// 来源:src/utils/match.min.js(sha256: b4f272aad40fb951) -// 协议命名空间:rpc;消息数:12;字段数:137 +// 来源:src/utils/match.min.js(sha256: 150812589c2e6f7a) +// 协议命名空间:rpc;消息数:12;字段数:151 export const ServerMessageType = { SERVER_MSG_UNKNOWN: 0, @@ -50,6 +50,7 @@ const SCHEMAS = { 7: { name: "angle", kind: "float" }, 8: { name: "distance", kind: "float" }, 9: { name: "three_consecutive_10_rings", kind: "bool" }, + 10: { name: "ok", kind: "bool" }, }, MatchShootList: { 1: { name: "items", kind: "message", type: "MatchShoot", repeated: true }, @@ -101,6 +102,9 @@ const SCHEMAS = { 13: { name: "s_vip", kind: "bool" }, 14: { name: "vip", kind: "bool" }, 15: { name: "player_match_result", kind: "message", type: "PlayerMatchResult" }, + 16: { name: "rank_lvl", kind: "int32" }, + 17: { name: "rank_name", kind: "string" }, + 18: { name: "rank_icon", kind: "string" }, }, TeamInfo: { 1: { name: "players", kind: "message", type: "PlayerFull", repeated: true }, @@ -180,6 +184,16 @@ const SCHEMAS = { 41: { name: "level", kind: "int32" }, 42: { name: "upgrade_exp", kind: "int32" }, 43: { name: "calories", kind: "double" }, + 44: { name: "score_slot", kind: "int32" }, + 45: { name: "current_energy", kind: "int32" }, + 46: { name: "energy_cost_per_sec", kind: "int32" }, + 47: { name: "energy_per_hit", kind: "int32" }, + 48: { name: "energy_req_percent", kind: "int32" }, + 49: { name: "delta_current_energy", kind: "int32" }, + 50: { name: "round_time", kind: "int32" }, + 51: { name: "shoot_window_start", kind: "int64" }, + 52: { name: "in_shoot_window", kind: "bool" }, + 53: { name: "shoot_time", kind: "int32" }, }, MatchInfo: { 1: { name: "match_id", kind: "string" },