完成决金箭调试

This commit is contained in:
kron
2025-07-06 00:42:10 +08:00
parent a2223d2b10
commit 0d21675013
7 changed files with 67 additions and 29 deletions

View File

@@ -23,7 +23,7 @@ const bubbleTypes = [
<image <image
v-if="!noBg" v-if="!noBg"
:src="bubbleTypes[type]" :src="bubbleTypes[type]"
:style="{ top: type === 2 ? '-5%' : '-12%' }" :style="{ top: type === 2 ? '-6%' : '-12%' }"
mode="widthFix" mode="widthFix"
/> />
<slot /> <slot />

View File

@@ -1,9 +1,9 @@
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from "vue"; import { ref, watch, onMounted, onUnmounted } from "vue";
const props = defineProps({ const props = defineProps({
type: { isFinal: {
type: Number, type: Boolean,
default: 0, default: false,
}, },
round: { round: {
type: Number, type: Number,
@@ -21,15 +21,31 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
onAutoClose: {
type: Function,
default: () => {},
},
}); });
const count = ref(10); const count = ref(3);
const tiemr = ref(null); const tiemr = ref(null);
onMounted(() => { function startCount() {
if (tiemr.value) clearInterval(tiemr.value); if (tiemr.value) clearInterval(tiemr.value);
tiemr.value = setInterval(() => { tiemr.value = setInterval(() => {
if (count.value === 0) clearInterval(tiemr.value); if (count.value === 0) {
else count.value -= 1; clearInterval(tiemr.value);
props.onAutoClose();
} else count.value -= 1;
}, 1000); }, 1000);
}
watch(
() => [props.isFinal, props.roundData],
([n_isFinal, n_roundData]) => {
count.value = n_isFinal ? 10 : 3;
startCount();
}
);
onMounted(() => {
startCount();
}); });
onUnmounted(() => { onUnmounted(() => {
if (tiemr.value) clearInterval(tiemr.value); if (tiemr.value) clearInterval(tiemr.value);
@@ -39,7 +55,7 @@ onUnmounted(() => {
<template> <template>
<view class="round-end-tip"> <view class="round-end-tip">
<text>{{ round }}轮射击结束</text> <text>{{ round }}轮射击结束</text>
<block v-if="type === 0"> <block v-if="!isFinal">
<view class="point-view1"> <view class="point-view1">
<text>本轮红队</text> <text>本轮红队</text>
<text>{{ <text>{{
@@ -76,7 +92,7 @@ onUnmounted(() => {
> >
</text> </text>
</block> </block>
<block v-if="type === 1"> <block v-if="isFinal">
<view class="point-view2"> <view class="point-view2">
<text>蓝队</text> <text>蓝队</text>
<text>{{ bluePoint }}</text> <text>{{ bluePoint }}</text>

View File

@@ -16,7 +16,7 @@ const props = defineProps({
}, },
}); });
const getContentHeight = () => { const getContentHeight = () => {
if (props.mode === "tall") return "47vw"; if (props.mode === "tall") return "50vw";
if (props.mode === "square") return "74vw"; if (props.mode === "square") return "74vw";
return "36vw"; return "36vw";
}; };

View File

@@ -18,6 +18,7 @@ export const MESSAGETYPES = {
SomeoneComplete: 2921416944, SomeoneComplete: 2921416944,
HalfTimeOver: 388606440, HalfTimeOver: 388606440,
BackToGame: 1899960424, BackToGame: 1899960424,
FinalShootResult: 3813452544,
}; };
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"]; export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];

View File

@@ -51,6 +51,7 @@ const showRoundTip = ref(false);
const playersScores = ref({}); const playersScores = ref({});
const showModal = ref(false); const showModal = ref(false);
const halfTimeTip = ref(false); const halfTimeTip = ref(false);
const isFinalShoot = ref(false);
const total = ref(90); const total = ref(90);
onLoad(async (options) => { onLoad(async (options) => {
@@ -225,9 +226,14 @@ async function onReceiveMessage(messages = []) {
seq.value += 1; seq.value += 1;
currentShooterId.value = msg.userId; currentShooterId.value = msg.userId;
if (redTeam.value[0].id === currentShooterId.value) { if (redTeam.value[0].id === currentShooterId.value) {
tips.value = `请红队射箭-${roundsName[currentRound.value]}`; tips.value = "请红队射箭-";
} else { } else {
tips.value = `请蓝队射箭-${roundsName[currentRound.value]}`; tips.value = "请蓝队射箭-";
}
if (isFinalShoot.value) {
tips.value += "决金箭";
} else {
tips.value += `${roundsName[currentRound.value]}`;
} }
} }
} }
@@ -258,17 +264,15 @@ async function onReceiveMessage(messages = []) {
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore; bluePoints.value += result.blueScore;
redPoints.value += result.redScore; redPoints.value += result.redScore;
showRoundTip.value = true; roundResults.value = result.roundResults;
if ( currentRound.value = result.currentRound + 1;
result.currentRound > 0 && if (result.currentRound < 5) showRoundTip.value = true;
result.currentRound < totalRounds.value
) {
// 开始下一轮;
roundResults.value = result.roundResults;
currentRound.value = result.currentRound + 1;
}
} }
} }
if (msg.constructor === MESSAGETYPES.FinalShoot) {
isFinalShoot.value = true;
showRoundTip.value = true;
}
if (msg.constructor === MESSAGETYPES.HalfTimeOver) { if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
startCount.value = false; startCount.value = false;
halfTimeTip.value = true; halfTimeTip.value = true;
@@ -304,7 +308,11 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<Container title="对战" :onBack="() => (showModal = true)"> <Container
title="对战"
:onBack="() => (showModal = true)"
:bgType="battleId ? 1 : 0"
>
<view class="standby-phase" v-if="step === 1"> <view class="standby-phase" v-if="step === 1">
<Guide> <Guide>
<view :style="{ display: 'flex', flexDirection: 'column' }"> <view :style="{ display: 'flex', flexDirection: 'column' }">
@@ -406,10 +414,12 @@ onUnmounted(() => {
<Timer :seq="timerSeq" /> <Timer :seq="timerSeq" />
<ScreenHint :show="showRoundTip" :onClose="() => (showRoundTip = false)"> <ScreenHint :show="showRoundTip" :onClose="() => (showRoundTip = false)">
<RoundEndTip <RoundEndTip
:isFinal="isFinalShoot"
:round="currentRound - 1" :round="currentRound - 1"
:bluePoint="currentBluePoint" :bluePoint="currentBluePoint"
:redPoint="currentRedPoint" :redPoint="currentRedPoint"
:roundData="roundResults[roundResults.length - 1]" :roundData="roundResults[roundResults.length - 1]"
:onAutoClose="() => (showRoundTip = false)"
/> />
</ScreenHint> </ScreenHint>
<ScreenHint <ScreenHint

View File

@@ -56,7 +56,6 @@ onMounted(async () => {
updateConfig(config); updateConfig(config);
console.log("全局配置:", config); console.log("全局配置:", config);
const rankList = await getRankListAPI(); const rankList = await getRankListAPI();
console.log("排位赛数据:", rankList);
updateRank(rankList); updateRank(rankList);
const token = uni.getStorageSync("token"); const token = uni.getStorageSync("token");
if (token) { if (token) {

View File

@@ -44,6 +44,7 @@ const bluePoints = ref(0);
const showRoundTip = ref(false); const showRoundTip = ref(false);
const onComplete = ref(null); const onComplete = ref(null);
const showModal = ref(false); const showModal = ref(false);
const isFinalShoot = ref(false);
onLoad(async (options) => { onLoad(async (options) => {
if (options.battleId) { if (options.battleId) {
@@ -126,9 +127,14 @@ async function onReceiveMessage(messages = []) {
seq.value += 1; seq.value += 1;
currentShooterId.value = msg.userId; currentShooterId.value = msg.userId;
if (redTeam.value[0].id === currentShooterId.value) { if (redTeam.value[0].id === currentShooterId.value) {
tips.value = `请红队射箭-${roundsName[currentRound.value]}`; tips.value = "请红队射箭-";
} else { } else {
tips.value = `请蓝队射箭-${roundsName[currentRound.value]}`; tips.value = "请蓝队射箭-";
}
if (isFinalShoot.value) {
tips.value += "决金箭";
} else {
tips.value += `${roundsName[currentRound.value]}`;
} }
} }
} }
@@ -149,10 +155,13 @@ async function onReceiveMessage(messages = []) {
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore; bluePoints.value += result.blueScore;
redPoints.value += result.redScore; redPoints.value += result.redScore;
showRoundTip.value = true;
// 开始下一轮;
roundResults.value = result.roundResults; roundResults.value = result.roundResults;
currentRound.value = result.currentRound + 1; currentRound.value = result.currentRound + 1;
if (result.currentRound < 5) showRoundTip.value = true;
}
if (msg.constructor === MESSAGETYPES.FinalShoot) {
isFinalShoot.value = true;
showRoundTip.value = true;
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
uni.redirectTo({ uni.redirectTo({
@@ -223,12 +232,15 @@ onUnmounted(() => {
<ScreenHint <ScreenHint
:show="showRoundTip" :show="showRoundTip"
:onClose="() => (showRoundTip = false)" :onClose="() => (showRoundTip = false)"
:mode="isFinalShoot ? 'tall' : 'normal'"
> >
<RoundEndTip <RoundEndTip
:isFinal="isFinalShoot"
:round="currentRound - 1" :round="currentRound - 1"
:bluePoint="currentBluePoint" :bluePoint="currentBluePoint"
:redPoint="currentRedPoint" :redPoint="currentRedPoint"
:roundData="roundResults[roundResults.length - 1]" :roundData="roundResults[roundResults.length - 1]"
:onAutoClose="() => (showRoundTip = false)"
/> />
</ScreenHint> </ScreenHint>
</block> </block>