bug修复
This commit is contained in:
@@ -55,6 +55,7 @@ const showModal = ref(false);
|
||||
const halfTimeTip = ref(false);
|
||||
const isFinalShoot = ref(false);
|
||||
const total = ref(15);
|
||||
const battleType = ref(0);
|
||||
|
||||
watch(
|
||||
() => [players.value, playersScores.value],
|
||||
@@ -77,6 +78,7 @@ onLoad(async (options) => {
|
||||
console.log("----battleInfo", battleInfo);
|
||||
if (battleInfo) {
|
||||
battleId.value = battleInfo.id;
|
||||
battleType.value = battleInfo.config.mode;
|
||||
start.value = true;
|
||||
step.value = 3;
|
||||
if (battleInfo.config.mode === 1) {
|
||||
@@ -88,6 +90,18 @@ onLoad(async (options) => {
|
||||
totalRounds.value = battleInfo.maxRound;
|
||||
roundResults.value = battleInfo.roundResults;
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
setTimeout(() => {
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows;
|
||||
blueScores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows;
|
||||
}
|
||||
}, 300);
|
||||
if (
|
||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
@@ -151,6 +165,7 @@ onLoad(async (options) => {
|
||||
roomNumber.value = options.roomNumber;
|
||||
const result = await getRoomAPI(options.roomNumber);
|
||||
room.value = result;
|
||||
battleType.value = result.battleType;
|
||||
result.members.some((m) => {
|
||||
if (m.userInfo.id === result.creator) {
|
||||
owner.value = {
|
||||
@@ -218,10 +233,10 @@ async function onReceiveMessage(messages = []) {
|
||||
timerSeq.value += 1;
|
||||
battleId.value = msg.id;
|
||||
step.value = 2;
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
redTeam.value = msg.groupUserStatus.redTeam;
|
||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||
} else if (room.value.battleType === 2) {
|
||||
} else if (battleType.value === 2) {
|
||||
players.value = [
|
||||
...msg.groupUserStatus.redTeam,
|
||||
...msg.groupUserStatus.blueTeam,
|
||||
@@ -233,7 +248,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.roomNumber === roomNumber.value) {
|
||||
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
if (msg.userId === room.value.creator) {
|
||||
owner.value = {
|
||||
id: msg.userId,
|
||||
@@ -248,7 +263,7 @@ async function onReceiveMessage(messages = []) {
|
||||
};
|
||||
}
|
||||
}
|
||||
if (room.value.battleType === 2) {
|
||||
if (battleType.value === 2) {
|
||||
if (room.value.creator === msg.userId) {
|
||||
players.value[0] = {
|
||||
id: msg.userId,
|
||||
@@ -265,7 +280,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
if (msg.userId === room.value.creator) {
|
||||
owner.value = {
|
||||
id: "",
|
||||
@@ -276,7 +291,7 @@ async function onReceiveMessage(messages = []) {
|
||||
};
|
||||
}
|
||||
}
|
||||
if (room.value.battleType === 2) {
|
||||
if (battleType.value === 2) {
|
||||
players.value = players.value.filter((p) => p.id !== msg.userId);
|
||||
}
|
||||
}
|
||||
@@ -298,7 +313,7 @@ async function onReceiveMessage(messages = []) {
|
||||
scores.value = [];
|
||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||
step.value = 3;
|
||||
if (room.value.battleType === 2) {
|
||||
if (battleType.value === 2) {
|
||||
tips.value = "请在90秒内射完12支箭";
|
||||
seq.value += 1;
|
||||
}
|
||||
@@ -319,7 +334,7 @@ async function onReceiveMessage(messages = []) {
|
||||
total.value = 90;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
if (currentShooterId.value !== msg.userId) {
|
||||
seq.value += 1;
|
||||
currentShooterId.value = msg.userId;
|
||||
@@ -337,7 +352,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||
if (isRed) scores.value.push(msg.target);
|
||||
else blueScores.value.push(msg.target);
|
||||
@@ -362,7 +377,7 @@ async function onReceiveMessage(messages = []) {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (room.value.battleType === 2) {
|
||||
if (battleType.value === 2) {
|
||||
scores.value.push(msg.target);
|
||||
power.value = msg.target.battery;
|
||||
}
|
||||
@@ -370,7 +385,7 @@ async function onReceiveMessage(messages = []) {
|
||||
playersScores.value[msg.userId].push(msg.target);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
if (room.value.battleType === 1) {
|
||||
if (battleType.value === 1) {
|
||||
const result = msg.preRoundResult;
|
||||
scores.value = [];
|
||||
blueScores.value = [];
|
||||
@@ -381,6 +396,7 @@ async function onReceiveMessage(messages = []) {
|
||||
redPoints.value += result.redScore;
|
||||
// roundResults.value = result.roundResults;
|
||||
currentRound.value = result.currentRound + 1;
|
||||
uni.$emit("update-ramain", 0);
|
||||
if (result.currentRound < 5) {
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
@@ -468,13 +484,13 @@ onUnmounted(() => {
|
||||
<view class="battle-guide">
|
||||
<view :style="{ display: 'flex', flexDirection: 'column' }">
|
||||
<text :style="{ color: '#fed847' }">弓箭手们,人都到齐了吗?</text>
|
||||
<text v-if="room.battleType === 1">1v1比赛即将开始! </text>
|
||||
<text v-if="room.battleType === 2">大乱斗即将开始! </text>
|
||||
<text v-if="battleType === 1">1v1比赛即将开始! </text>
|
||||
<text v-if="battleType === 2">大乱斗即将开始! </text>
|
||||
</view>
|
||||
<view @click="setClipboardData">邀请好友</view>
|
||||
</view>
|
||||
</Guide>
|
||||
<view v-if="room.battleType === 1" class="team-mode">
|
||||
<view v-if="battleType === 1" class="team-mode">
|
||||
<image src="../static/1v1-bg.png" mode="widthFix" />
|
||||
<view>
|
||||
<view class="player" :style="{ transform: 'translateY(-60px)' }">
|
||||
@@ -502,19 +518,19 @@ onUnmounted(() => {
|
||||
</view>
|
||||
</view>
|
||||
<PlayerSeats
|
||||
v-if="room.battleType === 2"
|
||||
v-if="battleType === 2"
|
||||
:total="room.count || 10"
|
||||
:players="players"
|
||||
/>
|
||||
<view>
|
||||
<SButton
|
||||
v-if="user.id === owner.id && room.battleType === 1"
|
||||
v-if="user.id === owner.id && battleType === 1"
|
||||
:disabled="!opponent.id"
|
||||
:onClick="startGame"
|
||||
>进入对战</SButton
|
||||
>
|
||||
<SButton
|
||||
v-if="user.id === owner.id && room.battleType === 2"
|
||||
v-if="user.id === owner.id && battleType === 2"
|
||||
:disabled="players.length < 3"
|
||||
:onClick="startGame"
|
||||
>进入大乱斗</SButton
|
||||
@@ -548,7 +564,7 @@ onUnmounted(() => {
|
||||
:currentShooterId="currentShooterId"
|
||||
/>
|
||||
<BowTarget
|
||||
:mode="room.battleType ? 'team' : 'solo'"
|
||||
:mode="battleType ? 'team' : 'solo'"
|
||||
:power="start ? power : 0"
|
||||
:currentRound="currentRound"
|
||||
:totalRound="totalRounds"
|
||||
|
||||
Reference in New Issue
Block a user