个人12支练习流程修改

This commit is contained in:
kron
2025-11-13 19:57:44 +08:00
parent be0d3a9e3c
commit 66705ae9b1
3 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
import audioManager from "@/audioManager";
import { MESSAGETYPES } from "@/constants";
import { getDirectionText } from "@/util";
@@ -48,6 +48,7 @@ const currentRound = ref(props.currentRound);
const currentRoundEnded = ref(false);
const ended = ref(false);
const halfTime = ref(false);
const wait = ref(0);
watch(
() => props.tips,
@@ -108,6 +109,13 @@ watch(
}
);
const tipContent = computed(() => {
if (halfTime.value) {
return props.battleId ? "中场休息" : `中场休息(${wait.value}秒)`;
}
return props.start && remain.value === 0 ? "时间到!" : props.tips;
});
const updateRemain = (value) => {
if (timer.value) clearInterval(timer.value);
remain.value = Math.round(value);
@@ -154,8 +162,21 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentRoundEnded.value = true;
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
halfTime.value = true;
audioManager.play("中场休息");
if (props.battleId) {
halfTime.value = true;
audioManager.play("中场休息");
return;
}
if (wait.value !== msg.wait) {
wait.value = msg.wait;
if (msg.wait === 20) {
halfTime.value = true;
audioManager.play("中场休息");
}
if (msg.wait === 0) {
halfTime.value = false;
}
}
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
audioManager.play("比赛结束");
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
@@ -188,7 +209,7 @@ onBeforeUnmount(() => {
<view class="container" :style="{ display: show ? 'block' : 'none' }">
<view>
<image src="../static/shooter.png" mode="widthFix" />
<text>{{ start && remain === 0 ? "时间到!" : tips }}</text>
<text>{{ tipContent }}</text>
<button hover-class="none" @click="updateSound">
<image
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"