调试多v多房间功能
This commit is contained in:
@@ -48,83 +48,7 @@ const updateSound = () => {
|
||||
|
||||
async function onReceiveMessage(message) {
|
||||
if (ended.value) return;
|
||||
if (Array.isArray(message)) {
|
||||
message.forEach((msg) => {
|
||||
// if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
// if (melee.value && msg.userId !== user.value.id) return;
|
||||
// if (msg.userId === user.value.id) currentShot.value++;
|
||||
// if (msg.battleInfo && msg.userId === user.value.id) {
|
||||
// const players = [
|
||||
// ...(msg.battleInfo.blueTeam || []),
|
||||
// ...(msg.battleInfo.redTeam || []),
|
||||
// ];
|
||||
// const currentPlayer = players.find((p) => p.id === msg.userId);
|
||||
// currentShot.value = 0;
|
||||
// try {
|
||||
// if (
|
||||
// currentPlayer &&
|
||||
// currentPlayer.shotHistory &&
|
||||
// currentPlayer.shotHistory[msg.battleInfo.currentRound]
|
||||
// ) {
|
||||
// currentShot.value =
|
||||
// currentPlayer.shotHistory[msg.battleInfo.currentRound].length;
|
||||
// }
|
||||
// } catch (_) {}
|
||||
// }
|
||||
// if (!halfTime.value && msg.target) {
|
||||
// let key = [];
|
||||
// key.push(msg.target.ring ? `${msg.target.ring}环` : "未上靶");
|
||||
// if (!msg.target.ring)
|
||||
// key.push(`向${getDirectionText(msg.target.angle)}调整`);
|
||||
// audioManager.play(key);
|
||||
// }
|
||||
// } else
|
||||
// if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
||||
// if (msg.userId === user.value.id) {
|
||||
// uni.showToast({
|
||||
// title: "距离不足,无效",
|
||||
// icon: "none",
|
||||
// });
|
||||
// audioManager.play("射击无效");
|
||||
// }
|
||||
// }
|
||||
// else if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||
// const { config } = msg.groupUserStatus;
|
||||
// if (config && config.mode === 1) {
|
||||
// totalShot.value = config.teamSize === 2 ? 3 : 2;
|
||||
// }
|
||||
// currentRoundEnded.value = true;
|
||||
// audioManager.play("比赛开始");
|
||||
// } else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
// melee.value = true;
|
||||
// halfTime.value = false;
|
||||
// audioManager.play("比赛开始");
|
||||
// } else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
// currentShot.value = 0;
|
||||
// if (msg.preRoundResult && msg.preRoundResult.currentRound) {
|
||||
// currentRound.value = msg.preRoundResult.currentRound;
|
||||
// currentRoundEnded.value = true;
|
||||
// }
|
||||
// } else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||
// halfTime.value = true;
|
||||
// audioManager.play("中场休息");
|
||||
// } else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
// audioManager.play("比赛结束");
|
||||
// } else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||
// totalShot.value = 0;
|
||||
// audioManager.play("决金箭轮");
|
||||
// tips.value = "即将开始...";
|
||||
// currentRoundEnded.value = false;
|
||||
// } else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
// ended.value = true;
|
||||
// } else if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||
// if (msg.battleInfo) {
|
||||
// melee.value = msg.battleInfo.config.mode === 2;
|
||||
// }
|
||||
// }
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(message)) return;
|
||||
if (message.type === MESSAGETYPESV2.BattleStart) {
|
||||
melee.value = Boolean(message.mode);
|
||||
totalShot.value = message.mode === 1 ? 3 : 2;
|
||||
|
||||
@@ -79,7 +79,7 @@ const seats = new Array(props.total).fill(1);
|
||||
}
|
||||
.avatar > text {
|
||||
background-color: #2c261fb3;
|
||||
border-color: #a3793f66;
|
||||
border: 1rpx solid #a3793f66;
|
||||
color: #fed847;
|
||||
font-size: 16rpx;
|
||||
border-radius: 20rpx;
|
||||
|
||||
@@ -36,10 +36,12 @@ const updateTimer = (value) => {
|
||||
};
|
||||
onMounted(() => {
|
||||
audioManager.play("请射箭测试距离");
|
||||
timer.value = setInterval(() => {
|
||||
if (count.value > 0) count.value -= 1;
|
||||
else clearInterval(timer.value);
|
||||
}, 1000);
|
||||
if (props.isBattle) {
|
||||
timer.value = setInterval(() => {
|
||||
count.value -= 1;
|
||||
if (count.value < 0) clearInterval(timer.value);
|
||||
}, 1000);
|
||||
}
|
||||
uni.$on("update-timer", updateTimer);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
@@ -117,11 +119,12 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
<view v-if="isBattle" class="ready-timer">
|
||||
<image src="../static/test-tip.png" mode="widthFix" />
|
||||
<view>
|
||||
<view v-if="count >= 0">
|
||||
<text>具体正式比赛还有</text>
|
||||
<text>{{ count }}</text>
|
||||
<text>秒</text>
|
||||
</view>
|
||||
<view v-else> 进入中... </view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -114,7 +114,7 @@ export const getBattleResultTips = (
|
||||
) => {
|
||||
const getRandomIndex = (len) => Math.floor(Math.random() * len);
|
||||
if (gameMode === 1) {
|
||||
if (mode === 1) {
|
||||
if (mode <= 3) {
|
||||
if (win) {
|
||||
const tests = [
|
||||
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fglywucyoh9zn.png",
|
||||
@@ -136,7 +136,7 @@ export const getBattleResultTips = (
|
||||
];
|
||||
return tests[getRandomIndex(3)];
|
||||
}
|
||||
} else if (mode === 2) {
|
||||
} else {
|
||||
if (rank <= 3) {
|
||||
const tests = [
|
||||
"好成绩!全国排位赛等着你!",
|
||||
@@ -148,7 +148,7 @@ export const getBattleResultTips = (
|
||||
}
|
||||
}
|
||||
} else if (gameMode === 2) {
|
||||
if (mode === 1) {
|
||||
if (mode <= 3) {
|
||||
if (win) {
|
||||
const tests = [
|
||||
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtb29jbdus4g.png",
|
||||
@@ -170,7 +170,7 @@ export const getBattleResultTips = (
|
||||
];
|
||||
return tests[getRandomIndex(3)];
|
||||
}
|
||||
} else if (mode === 2) {
|
||||
} else {
|
||||
if (score > 0) {
|
||||
const tests = [
|
||||
"王者一定属于你!",
|
||||
|
||||
@@ -114,8 +114,8 @@ const refreshMembers = (members = []) => {
|
||||
players.value[index] = { ...m.userInfo, groupType: m.groupType };
|
||||
if (m.groupType === 1) {
|
||||
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
|
||||
} else if (m.groupType === 0) {
|
||||
redTeam.value.push({ ...m.userInfo, groupType: 0 });
|
||||
} else if (m.groupType === 2) {
|
||||
redTeam.value.push({ ...m.userInfo, groupType: 2 });
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < room.value.count / 2; i++) {
|
||||
@@ -165,12 +165,6 @@ async function onReceiveMessage(message) {
|
||||
}
|
||||
|
||||
const chooseTeam = async (team) => {
|
||||
if (team !== 2) {
|
||||
const notInTeam = room.value.members.some(
|
||||
(m) => m.userInfo.id === user.value.id && m.groupType === 2
|
||||
);
|
||||
if (!notInTeam) return;
|
||||
}
|
||||
const result = await chooseTeamAPI(roomNumber.value, team);
|
||||
refreshMembers(result.members);
|
||||
};
|
||||
@@ -302,45 +296,45 @@ onBeforeUnmount(() => {
|
||||
<view class="choose-side">
|
||||
<view>
|
||||
<view
|
||||
v-for="(item, index) in blueTeam"
|
||||
v-for="(item, index) in redTeam"
|
||||
:key="index"
|
||||
class="choose-side-left-item"
|
||||
>
|
||||
<button
|
||||
hover-class="none"
|
||||
v-if="item.id === user.id"
|
||||
@click="chooseTeam(2)"
|
||||
@click="chooseTeam(0)"
|
||||
>
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<view v-if="item.id">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text v-if="!!item.state">已准备</text>
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||
<button v-else hover-class="none" @click="chooseTeam(2)">
|
||||
<image src="../static/add-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view
|
||||
v-for="(item, index) in redTeam"
|
||||
v-for="(item, index) in blueTeam"
|
||||
:key="index"
|
||||
class="choose-side-right-item"
|
||||
>
|
||||
<view v-if="item.id">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text v-if="!!item.state">已准备</text>
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
<button v-else hover-class="none" @click="chooseTeam(0)">
|
||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||
<image src="../static/add-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<button
|
||||
hover-class="none"
|
||||
v-if="item.id === user.id"
|
||||
@click="chooseTeam(2)"
|
||||
@click="chooseTeam(0)"
|
||||
>
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
@@ -479,7 +473,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.player .ready {
|
||||
background-color: #2c261fb3 !important;
|
||||
border-color: #a3793f66 !important;
|
||||
border: 1rpx solid #a3793f66 !important;
|
||||
color: #fed847 !important;
|
||||
}
|
||||
.team-mode > view > image:nth-child(2) {
|
||||
@@ -657,6 +651,7 @@ onBeforeUnmount(() => {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
.choose-side-left-item > button:last-child > image,
|
||||
.choose-side-right-item > button:first-child > image {
|
||||
@@ -677,7 +672,7 @@ onBeforeUnmount(() => {
|
||||
margin-top: -16rpx;
|
||||
position: relative;
|
||||
background-color: #2c261fb3;
|
||||
border-color: #a3793f66;
|
||||
border: 1rpx solid #a3793f66;
|
||||
color: #fed847;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -109,7 +109,11 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container :bgType="1" title="个人单组练习" :showBottom="!start && !scores.length">
|
||||
<Container
|
||||
:bgType="1"
|
||||
title="个人单组练习"
|
||||
:showBottom="!start && !scores.length"
|
||||
>
|
||||
<view>
|
||||
<TestDistance v-if="!practiseId" />
|
||||
<block v-if="practiseId">
|
||||
|
||||
@@ -162,23 +162,8 @@ onShow(async () => {
|
||||
} else {
|
||||
recoverData(result, { force: true });
|
||||
}
|
||||
// if (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);
|
||||
}
|
||||
});
|
||||
// onHide(() => {
|
||||
// if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||
// uni.setStorageSync("last-awake-time", Date.now());
|
||||
// });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user