完成排位匹配调试

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,
gameType,
teamSize,
readyTime: 1.5,
});
};

View File

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

View File

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

View File

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

View File

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

View File

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