bug修复

This commit is contained in:
kron
2025-06-26 01:27:23 +08:00
parent 0ea2d65e67
commit 159207a99d
6 changed files with 86 additions and 31 deletions

View File

@@ -121,11 +121,19 @@ async function onReceiveMessage(messages = []) {
if (msg.roomNumber === roomNumber.value) {
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
if (room.value.battleType === 1) {
opponent.value = {
id: msg.userId,
name: msg.name,
avatar: msg.avatar,
};
if (msg.userId === room.value.creator) {
owner.value = {
id: msg.userId,
name: msg.name,
avatar: msg.avatar,
};
} else {
opponent.value = {
id: msg.userId,
name: msg.name,
avatar: msg.avatar,
};
}
}
if (room.value.battleType === 2) {
players.value.push({
@@ -137,9 +145,15 @@ async function onReceiveMessage(messages = []) {
}
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
if (room.value.battleType === 1) {
opponent.value = {
id: "",
};
if (msg.userId === room.value.creator) {
owner.value = {
id: "",
};
} else {
opponent.value = {
id: "",
};
}
}
if (room.value.battleType === 2) {
players.value = players.value.filter((p) => p.id !== msg.userId);