完成排位匹配调试

This commit is contained in:
kron
2026-02-09 10:40:40 +08:00
parent 2044821e4d
commit 1a5a488776
6 changed files with 30 additions and 37 deletions

View File

@@ -260,6 +260,7 @@ export const matchGameAPI = (match, gameType, teamSize) => {
match, match,
gameType, gameType,
teamSize, teamSize,
readyTime: 1.5,
}); });
}; };

View File

@@ -39,6 +39,7 @@ export const MESSAGETYPESV2 = {
BattleEnd: 6, BattleEnd: 6,
HalfRest: 7, HalfRest: 7,
TestDistance: 8, TestDistance: 8,
MatchSuccess: 9,
}; };
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"]; export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];

View File

@@ -31,7 +31,7 @@ function exit() {
onLoad(async (options) => { onLoad(async (options) => {
if (!options.battleId) return; if (!options.battleId) return;
const myId = user.value.id; const myId = user.value.id;
const result = await getBattleAPI(options.battleId || "59090720979554304"); const result = await getBattleAPI(options.battleId || "60049406950510592");
data.value = result; data.value = result;
if (result.winTeam) { if (result.winTeam) {
ifWin.value = result.teams[result.winTeam].players.some( ifWin.value = result.teams[result.winTeam].players.some(
@@ -246,7 +246,7 @@ const checkBowData = () => {
</block> </block>
<view <view
class="battle-e" class="battle-e"
:style="{ marginTop: data.way === 2 ? '20px' : '20vw' }" :style="{ marginTop: data.mode > 3 ? '20px' : '20vw' }"
> >
<image src="../static/row-yellow-bg.png" mode="widthFix" /> <image src="../static/row-yellow-bg.png" mode="widthFix" />
<view class="team-avatar"> <view class="team-avatar">
@@ -257,12 +257,12 @@ const checkBowData = () => {
/> />
<text <text
:style="{ backgroundColor: '#5fadff' }" :style="{ backgroundColor: '#5fadff' }"
v-if="data.way === 1 && myTeam === 1" v-if="data.mode <= 3 && myTeam === 1"
>蓝队</text >蓝队</text
> >
<text <text
:style="{ backgroundColor: '#ff6060' }" :style="{ backgroundColor: '#ff6060' }"
v-if="data.way === 1 && myTeam === 2" v-if="data.mode <= 3 && myTeam === 2"
>红队</text >红队</text
> >
</view> </view>
@@ -273,7 +273,7 @@ const checkBowData = () => {
你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }} 你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
</text> </text>
</view> </view>
<text v-if="data.way === 2" class="description"> <text v-if="data.mode > 3" class="description">
{{ {{
getBattleResultTips(data.way, data.mode, { getBattleResultTips(data.way, data.mode, {
win: ifWin, win: ifWin,

View File

@@ -6,29 +6,21 @@ import Matching from "@/components/Matching.vue";
import RoundEndTip from "@/components/RoundEndTip.vue"; import RoundEndTip from "@/components/RoundEndTip.vue";
import TestDistance from "@/components/TestDistance.vue"; import TestDistance from "@/components/TestDistance.vue";
import { matchGameAPI } from "@/apis"; import { matchGameAPI } from "@/apis";
import { MESSAGETYPES } from "@/constants"; import { MESSAGETYPESV2 } from "@/constants";
const gameType = ref(0); const gameType = ref(0);
const teamSize = ref(0); const teamSize = ref(0);
const onComplete = ref(null); const onComplete = ref(null);
const matchSuccess = ref(false);
async function stopMatch() { async function stopMatch() {
uni.$showHint(3); uni.$showHint(3);
} }
async function onReceiveMessage(messages = []) { async function onReceiveMessage(msg) {
messages.forEach((msg) => { if (msg.type === MESSAGETYPESV2.MatchSuccess) {
if (msg.constructor === MESSAGETYPES.WaitForAllReady) { matchSuccess.value = true;
if (!onComplete.value) {
onComplete.value = () => { onComplete.value = () => {
if (msg.groupUserStatus) {
uni.setStorageSync("red-team", msg.groupUserStatus.redTeam);
uni.setStorageSync("blue-team", msg.groupUserStatus.blueTeam);
uni.setStorageSync("melee-players", [
...msg.groupUserStatus.redTeam,
...msg.groupUserStatus.blueTeam,
]);
}
if (gameType.value == 1) { if (gameType.value == 1) {
uni.redirectTo({ uni.redirectTo({
url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`, url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`,
@@ -40,8 +32,6 @@ async function onReceiveMessage(messages = []) {
} }
}; };
} }
}
});
} }
onLoad(async (options) => { onLoad(async (options) => {
@@ -63,7 +53,7 @@ onBeforeUnmount(() => {
keepScreenOn: false, keepScreenOn: false,
}); });
uni.$off("socket-inbox", onReceiveMessage); uni.$off("socket-inbox", onReceiveMessage);
if (gameType.value && teamSize.value) { if (gameType.value && teamSize.value && !matchSuccess.value) {
matchGameAPI(false, gameType.value, teamSize.value); matchGameAPI(false, gameType.value, teamSize.value);
} }
}); });
@@ -75,7 +65,7 @@ onShow(async () => {
}); });
onHide(() => { onHide(() => {
if (gameType.value && teamSize.value) { if (gameType.value && teamSize.value && !matchSuccess.value) {
matchGameAPI(false, gameType.value, teamSize.value); matchGameAPI(false, gameType.value, teamSize.value);
} }
}); });

View File

@@ -197,22 +197,22 @@ onShow(async () => {
<image <image
src="../static/battle2v2.png" src="../static/battle2v2.png"
mode="widthFix" mode="widthFix"
@click.stop="() => toMatchPage(1, 4)" @click.stop="() => toMatchPage(2, 4)"
/> />
<image <image
src="../static/battle3v3.png" src="../static/battle3v3.png"
mode="widthFix" mode="widthFix"
@click.stop="() => toMatchPage(1, 6)" @click.stop="() => toMatchPage(3, 6)"
/> />
<image <image
src="../static/battle5.png" src="../static/battle5.png"
mode="widthFix" mode="widthFix"
@click.stop="() => toMatchPage(2, 5)" @click.stop="() => toMatchPage(4, 5)"
/> />
<image <image
src="../static/battle10.png" src="../static/battle10.png"
mode="widthFix" mode="widthFix"
@click.stop="() => toMatchPage(2, 10)" @click.stop="() => toMatchPage(5, 10)"
/> />
</view> </view>
<view class="data-progress"> <view class="data-progress">

View File

@@ -104,6 +104,7 @@ async function onReceiveMessage(msg) {
} else if (msg.type === MESSAGETYPESV2.ToSomeoneShoot) { } else if (msg.type === MESSAGETYPESV2.ToSomeoneShoot) {
recoverData(msg); recoverData(msg);
} else if (msg.type === MESSAGETYPESV2.ShootResult) { } else if (msg.type === MESSAGETYPESV2.ShootResult) {
showRoundTip.value = false;
recoverData(msg, { arrowOnly: true }); recoverData(msg, { arrowOnly: true });
} else if (msg.type === MESSAGETYPESV2.NewRound) { } else if (msg.type === MESSAGETYPESV2.NewRound) {
showRoundTip.value = true; showRoundTip.value = true;