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