比赛逻辑代码统一
This commit is contained in:
@@ -23,10 +23,6 @@ const props = defineProps({
|
||||
type: Number,
|
||||
default: 120,
|
||||
},
|
||||
seq: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
currentRound: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -47,7 +43,7 @@ const timer = ref(null);
|
||||
const sound = ref(true);
|
||||
const currentSound = ref("");
|
||||
const currentRound = ref(props.currentRound);
|
||||
const currentRoundEnded = ref(!props.battleId);
|
||||
const currentRoundEnded = ref(false);
|
||||
const ended = ref(false);
|
||||
const halfTime = ref(false);
|
||||
|
||||
@@ -79,24 +75,19 @@ watch(
|
||||
watch(
|
||||
() => props.tips,
|
||||
(newVal) => {
|
||||
let key = "";
|
||||
if (newVal.includes("红队")) barColor.value = "#FF6060";
|
||||
if (newVal.includes("蓝队")) barColor.value = "#5FADFF";
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [props.seq],
|
||||
() => {
|
||||
if (newVal.includes("红队") || newVal.includes("蓝队")) {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = props.total;
|
||||
timer.value = setInterval(() => {
|
||||
if (remain.value > 0) remain.value--;
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
{
|
||||
"path": "pages/index"
|
||||
},
|
||||
{
|
||||
"path": "pages/match-page"
|
||||
},
|
||||
{
|
||||
"path": "pages/image-share"
|
||||
},
|
||||
|
||||
@@ -4,222 +4,23 @@ import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import PlayerSeats from "@/components/PlayerSeats.vue";
|
||||
import Guide from "@/components/Guide.vue";
|
||||
import Timer from "@/components/Timer.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import BattleHeader from "@/components/BattleHeader.vue";
|
||||
import BattleFooter from "@/components/BattleFooter.vue";
|
||||
import BowPower from "@/components/BowPower.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
import PlayersRow from "@/components/PlayersRow.vue";
|
||||
import SModal from "@/components/SModal.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import RoundEndTip from "@/components/RoundEndTip.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import PlayerScore from "@/components/PlayerScore.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import {
|
||||
getRoomAPI,
|
||||
destroyRoomAPI,
|
||||
exitRoomAPI,
|
||||
startRoomAPI,
|
||||
getCurrentGameAPI,
|
||||
} from "@/apis";
|
||||
import { isGameEnded } from "@/util";
|
||||
import { MESSAGETYPES, roundsName, getMessageTypeName } from "@/constants";
|
||||
import { getRoomAPI, destroyRoomAPI, exitRoomAPI, startRoomAPI } from "@/apis";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const step = ref(1);
|
||||
const seq = ref(0);
|
||||
const battleId = ref("");
|
||||
const room = ref({});
|
||||
const roomNumber = ref("");
|
||||
const owner = ref({});
|
||||
const opponent = ref({});
|
||||
const redTeam = ref([]);
|
||||
const blueTeam = ref([]);
|
||||
const currentShooterId = ref(0);
|
||||
const players = ref([]);
|
||||
const playersSorted = ref([]);
|
||||
const currentRound = ref(1);
|
||||
const totalRounds = ref(0);
|
||||
const start = ref(false);
|
||||
const startCount = ref(true);
|
||||
const power = ref(0);
|
||||
const scores = ref([]);
|
||||
const blueScores = ref([]);
|
||||
const tips = ref("即将开始...");
|
||||
const roundResults = ref([]);
|
||||
const redPoints = ref(0);
|
||||
const bluePoints = ref(0);
|
||||
const currentRedPoint = ref(0);
|
||||
const currentBluePoint = ref(0);
|
||||
const showRoundTip = ref(false);
|
||||
const playersScores = ref({});
|
||||
|
||||
const showModal = ref(false);
|
||||
const halfTimeTip = ref(false);
|
||||
const isFinalShoot = ref(false);
|
||||
const total = ref(15);
|
||||
const battleType = ref(0);
|
||||
const isEnded = ref(false);
|
||||
const refreshRoomTimer = ref(null);
|
||||
const refreshTimer = ref(null);
|
||||
|
||||
watch(
|
||||
() => [players.value, playersScores.value],
|
||||
([n_players, n_scores]) => {
|
||||
if (n_players.length) {
|
||||
playersSorted.value = Object.keys(n_scores)
|
||||
.sort((a, b) => n_scores[b].length - n_scores[a].length)
|
||||
.map((pid) => n_players.find((p) => p.id == pid));
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true, // 添加深度监听
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
function recoverData(battleInfo) {
|
||||
uni.removeStorageSync("last-awake-time");
|
||||
battleId.value = battleInfo.id;
|
||||
battleType.value = battleInfo.config.mode;
|
||||
step.value = 2;
|
||||
if (battleInfo.status === 0) {
|
||||
const readyRemain = Date.now() / 1000 - battleInfo.startTime;
|
||||
console.log(`当前局已进行${readyRemain}秒`);
|
||||
if (readyRemain > 0) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-timer", 15 - readyRemain);
|
||||
}, 200);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
step.value = 3;
|
||||
start.value = true;
|
||||
}
|
||||
if (battleInfo.config.mode === 1) {
|
||||
redTeam.value = battleInfo.redTeam;
|
||||
blueTeam.value = battleInfo.blueTeam;
|
||||
if (battleInfo.status !== 0) {
|
||||
bluePoints.value = 0;
|
||||
redPoints.value = 0;
|
||||
currentRound.value = battleInfo.currentRound;
|
||||
totalRounds.value = battleInfo.maxRound;
|
||||
roundResults.value = battleInfo.roundResults;
|
||||
battleInfo.roundResults.forEach((round) => {
|
||||
const blueTotal = round.blueArrows.reduce(
|
||||
(last, next) => last + next.ring,
|
||||
0
|
||||
);
|
||||
const redTotal = round.redArrows.reduce(
|
||||
(last, next) => last + next.ring,
|
||||
0
|
||||
);
|
||||
if (blueTotal === redTotal) {
|
||||
bluePoints.value += 1;
|
||||
redPoints.value += 1;
|
||||
} else if (blueTotal > redTotal) {
|
||||
bluePoints.value += 2;
|
||||
} else {
|
||||
redPoints.value += 2;
|
||||
}
|
||||
});
|
||||
if (
|
||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
) {
|
||||
roundResults.value.push({
|
||||
redArrows: battleInfo.redTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
blueArrows: battleInfo.blueTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
});
|
||||
} else if (battleInfo.currentRound < 5) {
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
}
|
||||
if (battleInfo.goldenRound) {
|
||||
const { ShotCount, RedRecords, BlueRecords } = battleInfo.goldenRound;
|
||||
const roundCount = Math.max(RedRecords.length, BlueRecords.length);
|
||||
currentRound.value += roundCount;
|
||||
isFinalShoot.value = true;
|
||||
for (let i = 0; i < roundCount; i++) {
|
||||
const roundData = {
|
||||
redArrows:
|
||||
RedRecords && RedRecords[i] ? RedRecords[i].Arrows || [] : [],
|
||||
blueArrows:
|
||||
BlueRecords && BlueRecords[i] ? BlueRecords[i].Arrows || [] : [],
|
||||
};
|
||||
if (roundResults.value[5 + i]) {
|
||||
roundResults.value[5 + i] = roundData;
|
||||
} else {
|
||||
roundResults.value.push(roundData);
|
||||
}
|
||||
}
|
||||
}
|
||||
const lastIndex = roundResults.value.length - 1;
|
||||
if (roundResults.value[lastIndex]) {
|
||||
const redArrows = roundResults.value[lastIndex].redArrows;
|
||||
scores.value = [...redArrows].filter((item) => !!item.playerId);
|
||||
const blueArrows = roundResults.value[lastIndex].blueArrows;
|
||||
blueScores.value = [...blueArrows].filter((item) => !!item.playerId);
|
||||
}
|
||||
}
|
||||
// 这个状态不准
|
||||
// if (battleInfo.status !== 11) return;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
tips.value =
|
||||
redTeam.value[0].id === currentShooterId.value
|
||||
? "请红队射箭 - "
|
||||
: "请蓝队射箭 - ";
|
||||
tips.value += isFinalShoot.value
|
||||
? "决金箭"
|
||||
: `第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
if (battleInfo.fireTime > 0) {
|
||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||
console.log(`当前箭已过${remain}秒`);
|
||||
if (remain > 0 && remain < 15) {
|
||||
// 等渲染好再通知
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", 15 - remain);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
} else if (battleInfo.config.mode === 2) {
|
||||
total.value = 90;
|
||||
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = [...p.arrows];
|
||||
if (p.id === user.value.id) scores.value = [...p.arrows];
|
||||
});
|
||||
if (battleInfo.status === 2) {
|
||||
startCount.value = true;
|
||||
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||
console.log(`当前局已进行${remain}秒`);
|
||||
tips.value = battleInfo.halfGame
|
||||
? "下半场:请再射6箭"
|
||||
: "上半场:请先射6箭";
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", 90 - remain);
|
||||
}, 300);
|
||||
} else if (battleInfo.status === 9) {
|
||||
startCount.value = false;
|
||||
tips.value = "准备下半场";
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", 0);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshRoomData() {
|
||||
if (!roomNumber.value) return;
|
||||
@@ -275,29 +76,10 @@ async function refreshRoomData() {
|
||||
|
||||
const startGame = async () => {
|
||||
const result = await startRoomAPI(room.value.number);
|
||||
step.value = 2;
|
||||
};
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||
if (refreshRoomTimer.value) clearInterval(refreshRoomTimer.value);
|
||||
// 这里会掉多次;
|
||||
battleId.value = msg.id;
|
||||
step.value = 2;
|
||||
if (battleType.value === 1) {
|
||||
redTeam.value = msg.groupUserStatus.redTeam;
|
||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||
} else if (battleType.value === 2) {
|
||||
players.value = [
|
||||
...msg.groupUserStatus.redTeam,
|
||||
...msg.groupUserStatus.blueTeam,
|
||||
];
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
if (msg.roomNumber === roomNumber.value) {
|
||||
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
||||
if (battleType.value === 1) {
|
||||
@@ -331,7 +113,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||
if (msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||
if (battleType.value === 1) {
|
||||
if (msg.userId === room.value.creator) {
|
||||
owner.value = {
|
||||
@@ -347,7 +129,7 @@ async function onReceiveMessage(messages = []) {
|
||||
players.value = players.value.filter((p) => p.id !== msg.userId);
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.RoomDestroy && !battleId.value) {
|
||||
if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
||||
uni.showToast({
|
||||
title: "房间已解散",
|
||||
icon: "none",
|
||||
@@ -358,138 +140,25 @@ async function onReceiveMessage(messages = []) {
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
if (msg.id === battleId.value) {
|
||||
if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||
start.value = true;
|
||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||
step.value = 3;
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
total.value = 15;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
start.value = true;
|
||||
startCount.value = true;
|
||||
step.value = 3;
|
||||
seq.value += 1;
|
||||
tips.value = scores.value.length
|
||||
? "下半场:请再射6箭"
|
||||
: "上半场:请先射6箭";
|
||||
total.value = 90;
|
||||
halfTimeTip.value = false;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||
if (battleType.value === 1) {
|
||||
if (currentShooterId.value !== msg.userId) {
|
||||
seq.value += 1;
|
||||
currentShooterId.value = msg.userId;
|
||||
tips.value =
|
||||
redTeam.value[0].id === currentShooterId.value
|
||||
? "请红队射箭 - "
|
||||
: "请蓝队射箭 - ";
|
||||
tips.value += isFinalShoot.value
|
||||
? "决金箭"
|
||||
: `第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
if (battleType.value === 1) {
|
||||
// 会有在蓝队射箭时间,红队射箭也有结果返回的情况
|
||||
if (currentShooterId.value !== msg.userId) return;
|
||||
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||
if (isRed) scores.value.push({ ...msg.target });
|
||||
else blueScores.value.push({ ...msg.target });
|
||||
if (!roundResults.value[currentRound.value - 1]) {
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
}
|
||||
roundResults.value[currentRound.value - 1][
|
||||
isRed ? "redArrows" : "blueArrows"
|
||||
].push({ ...msg.target });
|
||||
}
|
||||
if (battleType.value === 2 && msg.userId === user.value.id) {
|
||||
scores.value.push({ ...msg.target });
|
||||
power.value = msg.target.battery;
|
||||
}
|
||||
if (playersScores.value[msg.userId])
|
||||
playersScores.value[msg.userId].push({ ...msg.target });
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
if (battleType.value === 1) {
|
||||
const result = msg.preRoundResult;
|
||||
scores.value = [];
|
||||
blueScores.value = [];
|
||||
currentShooterId.value = 0;
|
||||
currentBluePoint.value = result.blueScore;
|
||||
currentRedPoint.value = result.redScore;
|
||||
bluePoints.value += result.blueScore;
|
||||
redPoints.value += result.redScore;
|
||||
uni.$emit("update-ramain", 0);
|
||||
if (result.currentRound < 5) {
|
||||
currentRound.value += 1;
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
showRoundTip.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||
currentShooterId.value = 0;
|
||||
currentRound.value += 1;
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
if (!isFinalShoot.value) {
|
||||
isFinalShoot.value = true;
|
||||
showRoundTip.value = true;
|
||||
tips.value = "准备开始决金箭";
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||
uni.$emit("update-ramain", 0);
|
||||
[
|
||||
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||
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,
|
||||
].forEach((player) => {
|
||||
playersScores.value[player.id] = [...player.arrows];
|
||||
if (player.id === user.value.id) scores.value = [...player.arrows];
|
||||
});
|
||||
startCount.value = false;
|
||||
halfTimeTip.value = true;
|
||||
tips.value = "准备下半场";
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
if (msg.endStatus.noSaved) {
|
||||
// 正常每回合结束通知,回合会加上1
|
||||
currentRound.value += 1;
|
||||
currentBluePoint.value = 0;
|
||||
currentRedPoint.value = 0;
|
||||
showRoundTip.value = true;
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 3000);
|
||||
} else {
|
||||
isEnded.value = true;
|
||||
uni.setStorageSync("last-battle", msg.endStatus);
|
||||
setTimeout(() => {
|
||||
]);
|
||||
uni.removeStorageSync("current-battle");
|
||||
if (msg.groupUserStatus.config.mode == 1) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/battle-result",
|
||||
url: `/pages/team-match?battleId=${msg.id}&gameMode=1`,
|
||||
});
|
||||
} else if (msg.groupUserStatus.config.mode == 2) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/melee-match?battleId=${msg.id}&gameMode=1`,
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||
uni.$emit("update-header-loading", false);
|
||||
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -512,23 +181,11 @@ const setClipboardData = () => {
|
||||
};
|
||||
|
||||
const onBack = () => {
|
||||
if (battleId.value) {
|
||||
uni.$showHint(2);
|
||||
} else {
|
||||
showModal.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.battleId) {
|
||||
const battleInfo = uni.getStorageSync("current-battle");
|
||||
if (battleInfo) {
|
||||
await nextTick(() => {
|
||||
recoverData(battleInfo);
|
||||
});
|
||||
setTimeout(getCurrentGameAPI, 2000);
|
||||
}
|
||||
} else if (options.roomNumber) {
|
||||
if (options.roomNumber) {
|
||||
roomNumber.value = options.roomNumber;
|
||||
refreshRoomData();
|
||||
refreshRoomTimer.value = setInterval(refreshRoomData, 2000);
|
||||
@@ -544,43 +201,24 @@ onMounted(() => {
|
||||
|
||||
onUnmounted(() => {
|
||||
if (refreshRoomTimer.value) clearInterval(refreshRoomTimer.value);
|
||||
if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (roomNumber.value && owner.value.id !== user.value.id && !battleId.value) {
|
||||
if (roomNumber.value && owner.value.id !== user.value.id) {
|
||||
exitRoomAPI(roomNumber.value);
|
||||
}
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
if (battleId.value) {
|
||||
if (!isEnded.value && (await isGameEnded(battleId.value))) return;
|
||||
getCurrentGameAPI();
|
||||
const refreshData = () => {
|
||||
const lastAwakeTime = uni.getStorageSync("last-awake-time");
|
||||
if (lastAwakeTime) getCurrentGameAPI();
|
||||
else clearInterval(refreshTimer.value);
|
||||
};
|
||||
refreshTimer.value = setInterval(refreshData, 2000);
|
||||
} else {
|
||||
refreshRoomData();
|
||||
}
|
||||
});
|
||||
onHide(() => {
|
||||
if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||
uni.setStorageSync("last-awake-time", Date.now());
|
||||
});
|
||||
onHide(() => {});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container
|
||||
:title="`好友约战 ${battleId ? '' : '- ' + roomNumber}`"
|
||||
:onBack="onBack"
|
||||
:bgType="battleId ? 1 : 0"
|
||||
>
|
||||
<view class="standby-phase" v-if="step === 1">
|
||||
<Container :title="`好友约战 - ${roomNumber}`" :onBack="onBack">
|
||||
<view class="standby-phase">
|
||||
<Guide>
|
||||
<view class="battle-guide">
|
||||
<view :style="{ display: 'flex', flexDirection: 'column' }">
|
||||
@@ -640,91 +278,8 @@ onHide(() => {
|
||||
<text class="tips">创建者点击下一步,所有人即可进入游戏。</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="step === 2" :style="{ width: '100%' }">
|
||||
<BattleHeader
|
||||
:blueTeam="blueTeam"
|
||||
:redTeam="redTeam"
|
||||
:players="players"
|
||||
/>
|
||||
<TestDistance :guide="false" />
|
||||
<Timer />
|
||||
</view>
|
||||
<view v-if="step === 3" :style="{ width: '100%' }">
|
||||
<ShootProgress
|
||||
:tips="tips"
|
||||
:seq="seq"
|
||||
:start="players.length > 0 && start && startCount"
|
||||
:total="total"
|
||||
:currentRound="currentRound"
|
||||
:battleId="battleId"
|
||||
:melee="players.length > 0"
|
||||
/>
|
||||
<PlayersRow
|
||||
v-if="blueTeam.length && redTeam.length"
|
||||
:blueTeam="blueTeam"
|
||||
:redTeam="redTeam"
|
||||
:currentShooterId="currentShooterId"
|
||||
/>
|
||||
<view v-if="battleType === 2" class="user-row">
|
||||
<Avatar :src="user.avatar" :size="35" />
|
||||
<BowPower :power="power" />
|
||||
</view>
|
||||
<BowTarget
|
||||
:mode="battleType === 1 ? 'team' : 'solo'"
|
||||
:power="battleType === 1 ? power : 0"
|
||||
:currentRound="scores.length"
|
||||
:totalRound="battleType === 1 ? 3 : totalRounds"
|
||||
:scores="scores"
|
||||
:blueScores="blueScores"
|
||||
:stop="!startCount"
|
||||
/>
|
||||
<BattleFooter
|
||||
v-if="roundResults.length"
|
||||
:roundResults="roundResults"
|
||||
:redPoints="redPoints"
|
||||
:bluePoints="bluePoints"
|
||||
/>
|
||||
<PlayerScore
|
||||
v-if="playersSorted.length"
|
||||
v-for="(player, index) in playersSorted"
|
||||
:key="index"
|
||||
:name="player.name"
|
||||
:avatar="player.avatar"
|
||||
:scores="playersScores[player.id] || []"
|
||||
/>
|
||||
</view>
|
||||
<ScreenHint
|
||||
:show="showRoundTip"
|
||||
:onClose="() => (showRoundTip = false)"
|
||||
:mode="isFinalShoot ? 'tall' : 'normal'"
|
||||
>
|
||||
<RoundEndTip
|
||||
v-if="showRoundTip"
|
||||
:isFinal="isFinalShoot"
|
||||
:round="currentRound - 1"
|
||||
:bluePoint="currentBluePoint"
|
||||
:redPoint="currentRedPoint"
|
||||
:roundData="
|
||||
roundResults[roundResults.length - 2]
|
||||
? roundResults[roundResults.length - 2]
|
||||
: []
|
||||
"
|
||||
:onAutoClose="() => (showRoundTip = false)"
|
||||
/>
|
||||
</ScreenHint>
|
||||
<ScreenHint
|
||||
:show="halfTimeTip"
|
||||
mode="small"
|
||||
:onClose="() => (halfTimeTip = false)"
|
||||
>
|
||||
<view class="half-time-tip">
|
||||
<text>上半场结束,休息一下吧:)</text>
|
||||
<text>20秒后开始下半场</text>
|
||||
</view>
|
||||
</ScreenHint>
|
||||
<SModal :show="showModal" :onClose="() => (showModal = false)">
|
||||
<view class="btns">
|
||||
<block v-if="!battleId">
|
||||
<SButton :onClick="exitRoom" width="200px" :rounded="20">
|
||||
暂时离开
|
||||
</SButton>
|
||||
@@ -734,12 +289,6 @@ onHide(() => {
|
||||
解散房间
|
||||
</SButton>
|
||||
</block>
|
||||
</block>
|
||||
<block v-else>
|
||||
<SButton :onClick="exitRoom" width="200px" :rounded="20">
|
||||
退出比赛
|
||||
</SButton>
|
||||
</block>
|
||||
</view>
|
||||
</SModal>
|
||||
</Container>
|
||||
|
||||
98
src/pages/match-page.vue
Normal file
98
src/pages/match-page.vue
Normal file
@@ -0,0 +1,98 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
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";
|
||||
|
||||
const gameType = ref(0);
|
||||
const teamSize = ref(0);
|
||||
const onComplete = ref(null);
|
||||
|
||||
async function stopMatch() {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||
if (!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,
|
||||
]);
|
||||
}
|
||||
uni.removeStorageSync("current-battle");
|
||||
if (gameType.value == 1) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/team-match?battleId=${msg.id}&gameMode=2`,
|
||||
});
|
||||
} else if (gameType.value == 2) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/melee-match?battleId=${msg.id}&gameMode=2`,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.gameType && options.teamSize) {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (gameType.value && teamSize.value) {
|
||||
matchGameAPI(false, gameType.value, teamSize.value);
|
||||
}
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
if (gameType.value && teamSize.value) {
|
||||
matchGameAPI(true, gameType.value, teamSize.value);
|
||||
}
|
||||
});
|
||||
|
||||
onHide(() => {
|
||||
if (gameType.value && teamSize.value) {
|
||||
matchGameAPI(false, gameType.value, teamSize.value);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="搜索对手..." :bgType="1" :onBack="stopMatch">
|
||||
<view class="container">
|
||||
<Matching :stopMatch="stopMatch" :onComplete="onComplete" />
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -4,24 +4,21 @@ import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
import Guide from "@/components/Guide.vue";
|
||||
import BattleHeader from "@/components/BattleHeader.vue";
|
||||
import Timer from "@/components/Timer.vue";
|
||||
import PlayerScore from "@/components/PlayerScore.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import Matching from "@/components/Matching.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import { getCurrentGameAPI, matchGameAPI } from "@/apis";
|
||||
import { getCurrentGameAPI } from "@/apis";
|
||||
import { isGameEnded } from "@/util";
|
||||
import { MESSAGETYPES, getMessageTypeName } from "@/constants";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const gameType = ref(0);
|
||||
const teamSize = ref(0);
|
||||
const title = ref("大乱斗");
|
||||
const start = ref(false);
|
||||
const startCount = ref(true);
|
||||
const battleId = ref("");
|
||||
@@ -29,12 +26,10 @@ const currentRound = ref(1);
|
||||
const power = ref(0);
|
||||
const scores = ref([]);
|
||||
const tips = ref("即将开始...");
|
||||
const seq = ref(0);
|
||||
const players = ref([]);
|
||||
const playersSorted = ref([]);
|
||||
const playersScores = ref({});
|
||||
const halfTimeTip = ref(false);
|
||||
const onComplete = ref(null);
|
||||
const isEnded = ref(false);
|
||||
|
||||
watch(
|
||||
@@ -92,44 +87,31 @@ function recoverData(battleInfo) {
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.gameMode == 1) title.value = "好友约战 - 大乱斗";
|
||||
if (options.gameMode == 2) title.value = "排位赛 - 大乱斗";
|
||||
if (options.battleId) {
|
||||
const battleInfo = uni.getStorageSync("current-battle");
|
||||
if (battleInfo) recoverData(battleInfo);
|
||||
setTimeout(getCurrentGameAPI, 2000);
|
||||
} else {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
if (gameType.value && teamSize.value) {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function stopMatch() {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||
onComplete.value = () => {
|
||||
// 这里会掉多次;
|
||||
battleId.value = msg.id;
|
||||
players.value = [
|
||||
...msg.groupUserStatus.redTeam,
|
||||
...msg.groupUserStatus.blueTeam,
|
||||
];
|
||||
battleId.value = options.battleId;
|
||||
const players = uni.getStorageSync("melee-players");
|
||||
if (players) {
|
||||
players.value = players;
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = [];
|
||||
});
|
||||
uni.$hideHint();
|
||||
};
|
||||
}
|
||||
const battleInfo = uni.getStorageSync("current-battle");
|
||||
if (battleInfo) {
|
||||
recoverData(battleInfo);
|
||||
setTimeout(getCurrentGameAPI, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.id !== battleId.value) return;
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
start.value = true;
|
||||
startCount.value = true;
|
||||
seq.value += 1;
|
||||
tips.value = scores.value.length
|
||||
? "下半场:请再射6箭"
|
||||
: "上半场:请先射6箭";
|
||||
@@ -171,11 +153,7 @@ async function onReceiveMessage(messages = []) {
|
||||
});
|
||||
}
|
||||
const onBack = () => {
|
||||
if (battleId.value) {
|
||||
uni.$showHint(2);
|
||||
} else {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
};
|
||||
onMounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
@@ -188,9 +166,6 @@ onUnmounted(() => {
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (gameType.value && teamSize.value && !battleId.value) {
|
||||
matchGameAPI(false, gameType.value, teamSize.value);
|
||||
}
|
||||
});
|
||||
const refreshTimer = ref(null);
|
||||
onShow(async () => {
|
||||
@@ -215,18 +190,12 @@ onHide(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container
|
||||
:title="battleId ? '大乱斗排位赛' : '搜索对手...'"
|
||||
:bgType="1"
|
||||
:onBack="onBack"
|
||||
>
|
||||
<Container :title="title" :bgType="1" :onBack="onBack">
|
||||
<view class="container">
|
||||
<block v-if="battleId">
|
||||
<BattleHeader v-if="!start" :players="players" />
|
||||
<TestDistance v-if="!start" :guide="false" />
|
||||
<ShootProgress
|
||||
:show="start"
|
||||
:seq="seq"
|
||||
:start="start && startCount"
|
||||
:tips="tips"
|
||||
:total="90"
|
||||
@@ -265,14 +234,6 @@ onHide(() => {
|
||||
<text>20秒后开始下半场</text>
|
||||
</view>
|
||||
</ScreenHint>
|
||||
</block>
|
||||
<block v-else>
|
||||
<Matching
|
||||
v-if="!battleId"
|
||||
:stopMatch="stopMatch"
|
||||
:onComplete="onComplete"
|
||||
/>
|
||||
</block>
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
@@ -36,24 +36,7 @@ const handleSelect = (index) => {
|
||||
}
|
||||
};
|
||||
|
||||
const toTeamMatchPage = async (gameType, teamSize) => {
|
||||
if (!device.value.deviceId) {
|
||||
return uni.showToast({
|
||||
title: "请先绑定设备",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
const isGaming = await isGamingAPI();
|
||||
if (isGaming) {
|
||||
uni.$showHint(1);
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-match?gameType=${gameType}&teamSize=${teamSize}`,
|
||||
});
|
||||
};
|
||||
|
||||
const toMeleeMatchPage = async (gameType, teamSize) => {
|
||||
const toMatchPage = async (gameType, teamSize) => {
|
||||
if (!device.value.deviceId) {
|
||||
return uni.showToast({
|
||||
title: "请先绑定设备",
|
||||
@@ -72,7 +55,7 @@ const toMeleeMatchPage = async (gameType, teamSize) => {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-match?gameType=${gameType}&teamSize=${teamSize}`,
|
||||
url: `/pages/match-page?gameType=${gameType}&teamSize=${teamSize}`,
|
||||
});
|
||||
};
|
||||
const toMyGrowthPage = () => {
|
||||
@@ -205,17 +188,17 @@ onShow(async () => {
|
||||
<image
|
||||
src="../static/battle1v1.png"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toTeamMatchPage(1, 2)"
|
||||
@click.stop="() => toMatchPage(1, 2)"
|
||||
/>
|
||||
<image
|
||||
src="../static/battle5.png"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMeleeMatchPage(2, 5)"
|
||||
@click.stop="() => toMatchPage(2, 5)"
|
||||
/>
|
||||
<image
|
||||
src="../static/battle10.png"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMeleeMatchPage(2, 10)"
|
||||
@click.stop="() => toMatchPage(2, 10)"
|
||||
/>
|
||||
</view>
|
||||
<view class="data-progress">
|
||||
|
||||
@@ -3,7 +3,6 @@ import { ref, onMounted, onUnmounted, nextTick } from "vue";
|
||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import BattleHeader from "@/components/BattleHeader.vue";
|
||||
import Guide from "@/components/Guide.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
import PlayersRow from "@/components/PlayersRow.vue";
|
||||
@@ -11,18 +10,16 @@ import Timer from "@/components/Timer.vue";
|
||||
import BattleFooter from "@/components/BattleFooter.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import Matching from "@/components/Matching.vue";
|
||||
import RoundEndTip from "@/components/RoundEndTip.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import { getCurrentGameAPI, matchGameAPI } from "@/apis";
|
||||
import { getCurrentGameAPI } from "@/apis";
|
||||
import { isGameEnded } from "@/util";
|
||||
import { MESSAGETYPES, roundsName } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const gameType = ref(0);
|
||||
const teamSize = ref(0);
|
||||
const title = ref("1V1");
|
||||
const start = ref(false);
|
||||
const battleId = ref("");
|
||||
const currentRound = ref(1);
|
||||
@@ -36,12 +33,10 @@ const redTeam = ref([]);
|
||||
const blueTeam = ref([]);
|
||||
const currentShooterId = ref(0);
|
||||
const tips = ref("即将开始...");
|
||||
const seq = ref(0);
|
||||
const roundResults = ref([]);
|
||||
const redPoints = ref(0);
|
||||
const bluePoints = ref(0);
|
||||
const showRoundTip = ref(false);
|
||||
const onComplete = ref(null);
|
||||
const isFinalShoot = ref(false);
|
||||
const isEnded = ref(false);
|
||||
|
||||
@@ -127,7 +122,6 @@ function recoverData(battleInfo) {
|
||||
const blueArrows = roundResults.value[lastIndex].blueArrows;
|
||||
blueScores.value = [...blueArrows].filter((item) => !!item.playerId);
|
||||
}
|
||||
}
|
||||
// if (battleInfo.status !== 11) return;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
@@ -151,23 +145,10 @@ function recoverData(battleInfo) {
|
||||
}
|
||||
}
|
||||
}
|
||||
async function stopMatch() {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||
// 这里会掉多次;
|
||||
if (!onComplete.value) {
|
||||
onComplete.value = () => {
|
||||
battleId.value = msg.id;
|
||||
redTeam.value = msg.groupUserStatus.redTeam;
|
||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||
uni.$hideHint();
|
||||
};
|
||||
}
|
||||
}
|
||||
if (msg.id !== battleId.value) return;
|
||||
if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||
start.value = true;
|
||||
@@ -181,7 +162,6 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||
if (currentShooterId.value !== msg.userId) {
|
||||
seq.value += 1;
|
||||
currentShooterId.value = msg.userId;
|
||||
const teamPrefix =
|
||||
redTeam.value[0].id === currentShooterId.value
|
||||
@@ -265,15 +245,16 @@ async function onReceiveMessage(messages = []) {
|
||||
});
|
||||
}
|
||||
const onBack = () => {
|
||||
if (battleId.value) {
|
||||
uni.$showHint(2);
|
||||
} else {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.gameMode == 1) title.value = "好友约战 - 1V1";
|
||||
if (options.gameMode == 2) title.value = "排位赛 - 1V1";
|
||||
if (options.battleId) {
|
||||
battleId.value = options.battleId;
|
||||
redTeam.value = uni.getStorageSync("red-team");
|
||||
blueTeam.value = uni.getStorageSync("blue-team");
|
||||
const battleInfo = uni.getStorageSync("current-battle");
|
||||
if (battleInfo) {
|
||||
await nextTick(() => {
|
||||
@@ -281,12 +262,6 @@ onLoad(async (options) => {
|
||||
});
|
||||
setTimeout(getCurrentGameAPI, 2000);
|
||||
}
|
||||
} else {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
if (gameType.value && teamSize.value) {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
onMounted(() => {
|
||||
@@ -300,9 +275,6 @@ onUnmounted(() => {
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (gameType.value && teamSize.value && !battleId.value) {
|
||||
matchGameAPI(false, gameType.value, teamSize.value);
|
||||
}
|
||||
});
|
||||
const refreshTimer = ref(null);
|
||||
onShow(async () => {
|
||||
@@ -327,19 +299,13 @@ onHide(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container
|
||||
:title="battleId ? '1V1排位赛' : '搜索对手...'"
|
||||
:bgType="1"
|
||||
:onBack="onBack"
|
||||
>
|
||||
<Container :title="title" :bgType="1" :onBack="onBack">
|
||||
<view class="container">
|
||||
<block v-if="battleId">
|
||||
<BattleHeader v-if="!start" :redTeam="redTeam" :blueTeam="blueTeam" />
|
||||
<TestDistance v-if="!start" :guide="false" />
|
||||
<ShootProgress
|
||||
:show="start"
|
||||
:tips="tips"
|
||||
:seq="seq"
|
||||
:total="15"
|
||||
:currentRound="currentRound"
|
||||
:battleId="battleId"
|
||||
@@ -385,14 +351,6 @@ onHide(() => {
|
||||
:onAutoClose="() => (showRoundTip = false)"
|
||||
/>
|
||||
</ScreenHint>
|
||||
</block>
|
||||
<block v-else>
|
||||
<Matching
|
||||
v-if="!battleId"
|
||||
:stopMatch="stopMatch"
|
||||
:onComplete="onComplete"
|
||||
/>
|
||||
</block>
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
@@ -38,35 +38,18 @@ function createWebSocket(token, onMessage) {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// const lastRoute = uni.getStorageSync("last-route");
|
||||
// if (
|
||||
// lastRoute === "pages/battle-room" ||
|
||||
// lastRoute === "pages/team-match" ||
|
||||
// lastRoute === "pages/melee-match"
|
||||
// ) {
|
||||
// return;
|
||||
// }
|
||||
const { battleInfo } = msg;
|
||||
uni.setStorageSync("current-battle", battleInfo);
|
||||
console.log("----battleInfo", battleInfo);
|
||||
// 约战
|
||||
if (battleInfo.config.battleMode === 1) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/battle-room?battleId=${battleInfo.id}`,
|
||||
});
|
||||
}
|
||||
// 排位
|
||||
if (battleInfo.config.battleMode === 2) {
|
||||
if (battleInfo.config.mode === 1) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-match?battleId=${battleInfo.id}`,
|
||||
url: `/pages/team-match?battleId=${battleInfo.id}&gameMode=${battleInfo.config.battleMode}`,
|
||||
});
|
||||
} else if (battleInfo.config.mode === 2) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-match?battleId=${battleInfo.id}`,
|
||||
url: `/pages/melee-match?battleId=${battleInfo.id}&gameMode=${battleInfo.config.battleMode}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
uni.$emit("game-over");
|
||||
} else if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
||||
|
||||
Reference in New Issue
Block a user