添加X环显示,比赛过程完善

This commit is contained in:
kron
2026-02-09 17:27:44 +08:00
parent b355f4e009
commit a3fea0bb1f
18 changed files with 82 additions and 104 deletions

View File

@@ -56,7 +56,7 @@ const props = defineProps({
:completeEffect="false"
:rowCount="arrows.length === 12 ? 6 : 9"
:total="total"
:scores="arrows.map((a) => a.ring)"
:arrows="arrows"
:margin="arrows.length === 12 ? 4 : 1"
:fontSize="arrows.length === 12 ? 25 : 22"
/>

View File

@@ -92,8 +92,10 @@ const simulShoot = async () => {
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
};
const simulShoot2 = async () => {
if (device.value.deviceId)
await simulShootAPI(device.value.deviceId, 0.01, 0.01);
if (device.value.deviceId) {
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
await simulShootAPI(device.value.deviceId, r1, r1);
}
};
const env = computed(() => {

View File

@@ -69,7 +69,7 @@ async function onReceiveMessage(message) {
? `${shootData.ringX ? "X" : shootData.ring}`
: "未上靶"
);
if (!shootData.ring)
if (shootData.angle !== null)
key.push(`${getDirectionText(shootData.angle)}调整`);
audioManager.play(key, false);
}

View File

@@ -9,7 +9,7 @@ const props = defineProps({
type: Number,
default: 0,
},
scores: {
arrows: {
type: Array,
default: () => [],
},
@@ -51,7 +51,7 @@ onBeforeUnmount(() => {
<template>
<view class="container">
<image
v-if="total > 0 && scores.length === total && completeEffect"
v-if="total > 0 && arrows.length === total && completeEffect"
:src="bgImages[bgIndex]"
class="complete-light"
:style="{
@@ -79,8 +79,10 @@ onBeforeUnmount(() => {
>
<image src="../static/score-bg.png" mode="widthFix" />
<text
:style="{ fontWeight: scores[index] !== undefined ? 'bold' : 'normal' }"
>{{ scores[index] !== undefined ? scores[index] : "-" }}</text
:style="{ fontWeight: arrows[index] !== undefined ? 'bold' : 'normal' }"
>{{
!arrows[index] ? "-" : arrows[index].ringX ? "X" : arrows[index].ring
}}</text
>
</view>
</view>

View File

@@ -1,6 +1,6 @@
<script setup>
const props = defineProps({
scores: {
arrows: {
type: Array,
default: () => [],
},
@@ -10,37 +10,34 @@ const getSum = (a, b, c) => {
return sum > 0 ? sum + "环" : "-";
};
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
const getShowText = (arrow = {}) => {
return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-";
};
</script>
<template>
<view class="container">
<view>
<text :style="{ transform: 'translateX(-10%)' }">总成绩</text>
<text>{{ scores.reduce((last, next) => last + next, 0) }}</text>
<text>{{ arrows.reduce((last, next) => last + next.ring, 0) }}</text>
</view>
<view
v-for="(_, index) in new Array(
Math.min(
Math.ceil(scores.length / 3) + (scores.length % 3 === 0 ? 1 : 0),
Math.ceil(arrows.length / 3) + (arrows.length % 3 === 0 ? 1 : 0),
4
)
).fill(1)"
:key="index"
>
<text>{{ roundsName[index] }}</text>
<text>{{
scores[index * 3 + 0] ? scores[index * 3 + 0] + "环" : "-"
}}</text>
<text>{{
scores[index * 3 + 1] ? scores[index * 3 + 1] + "环" : "-"
}}</text>
<text>{{
scores[index * 3 + 2] ? scores[index * 3 + 2] + "环" : "-"
}}</text>
<text>{{ getShowText(arrows[index * 3 + 0]) }}</text>
<text>{{ getShowText(arrows[index * 3 + 1]) }}</text>
<text>{{ getShowText(arrows[index * 3 + 2]) }}</text>
<text :style="{ width: '40%', transform: 'translateX(20%)' }">{{
getSum(
scores[index * 3 + 0],
scores[index * 3 + 1],
scores[index * 3 + 2]
arrows[index * 3 + 0],
arrows[index * 3 + 1],
arrows[index * 3 + 2]
)
}}</text>
</view>

View File

@@ -63,8 +63,8 @@ const validArrows = computed(() => {
});
const getRing = (arrow) => {
if (arrow && arrow.x !== -30 && arrow.y !== -30) return arrow.ring;
return "-";
if (arrow.ringX) return "X";
return arrow.ring ? arrow.ring + "环" : "-";
};
</script>
@@ -160,7 +160,7 @@ const getRing = (arrow) => {
</view>
</ScreenHint>
<BowData
:total="result.completed_arrows"
:total="result.details.length"
:arrows="result.details"
:show="showBowData"
:onClose="() => (showBowData = false)"

View File

@@ -137,7 +137,8 @@ async function onReceiveMessage(msg) {
}
let key = [];
key.push(arrow.ring ? `${arrow.ringX ? "X" : arrow.ring}` : "未上靶");
if (!arrow.ring) key.push(`${getDirectionText(arrow.angle)}调整`);
if (arrow.angle !== null)
key.push(`${getDirectionText(arrow.angle)}调整`);
audioManager.play(key, false);
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
halfTime.value = true;