细节完善
This commit is contained in:
@@ -41,7 +41,13 @@ defineProps({
|
||||
</view>
|
||||
</view>
|
||||
<block v-if="roundResults.length < 3">
|
||||
<view v-for="i in 3 - roundResults.length" :key="i"> </view>
|
||||
<view v-for="i in 3 - roundResults.length" :key="i">
|
||||
<text>Round</text>
|
||||
<view>
|
||||
<text></text>
|
||||
<text>环</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view>
|
||||
@@ -62,7 +68,13 @@ defineProps({
|
||||
</view>
|
||||
</view>
|
||||
<block v-if="roundResults.length < 3">
|
||||
<view v-for="i in 3 - roundResults.length" :key="i"> </view>
|
||||
<view v-for="i in 3 - roundResults.length" :key="i">
|
||||
<text>Round</text>
|
||||
<view>
|
||||
<text></text>
|
||||
<text>环</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -56,7 +56,7 @@ onUnmounted(() => {
|
||||
<view class="round-end-tip">
|
||||
<text>第{{ round }}轮射击结束</text>
|
||||
<block v-if="!isFinal">
|
||||
<view class="point-view1">
|
||||
<view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
|
||||
<text>本轮蓝队</text>
|
||||
<text>{{
|
||||
(roundData.blueArrows || []).reduce(
|
||||
@@ -73,10 +73,13 @@ onUnmounted(() => {
|
||||
}}</text>
|
||||
<text>环</text>
|
||||
</view>
|
||||
<text v-if="bluePoint === 0 && redPoint === 0">
|
||||
本场比赛无人射箭,已取消
|
||||
<text
|
||||
v-if="bluePoint === 0 && redPoint === 0"
|
||||
:style="{ marginTop: '20px' }"
|
||||
>
|
||||
连续3个来回无人射箭,比赛被取消
|
||||
</text>
|
||||
<text v-if="bluePoint === redPoint">
|
||||
<text v-if="bluePoint !== 0 && bluePoint === redPoint">
|
||||
红队、蓝队各得<text :style="{ color: '#fed847', margin: '0 5px' }">{{
|
||||
redPoint
|
||||
}}</text
|
||||
|
||||
@@ -124,16 +124,14 @@ function recoverData(battleInfo) {
|
||||
redPoints.value += 2;
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
}, 300);
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
if (
|
||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
@@ -152,16 +150,36 @@ function recoverData(battleInfo) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 这个状态不准
|
||||
// if (battleInfo.status !== 11) return;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
if (redTeam.value[0].id === currentShooterId.value) {
|
||||
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
} else {
|
||||
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
if (redTeam.value[0].id === currentShooterId.value)
|
||||
tips.value = "请红队射箭";
|
||||
else tips.value = "请蓝队射箭";
|
||||
tips.value += isFinalShoot.value
|
||||
? "决金箭"
|
||||
: `第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
if (battleInfo.fireTime > 0) {
|
||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||
@@ -396,26 +414,15 @@ async function onReceiveMessage(messages = []) {
|
||||
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]) {
|
||||
if (isRed && roundResults.value[currentRound.value - 1].redArrows) {
|
||||
roundResults.value[currentRound.value - 1].redArrows.push(
|
||||
msg.target
|
||||
);
|
||||
}
|
||||
if (
|
||||
!isRed &&
|
||||
roundResults.value[currentRound.value - 1].blueArrows
|
||||
) {
|
||||
roundResults.value[currentRound.value - 1].blueArrows.push(
|
||||
msg.target
|
||||
);
|
||||
}
|
||||
} else {
|
||||
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 });
|
||||
@@ -434,9 +441,9 @@ async function onReceiveMessage(messages = []) {
|
||||
currentRedPoint.value = result.redScore;
|
||||
bluePoints.value += result.blueScore;
|
||||
redPoints.value += result.redScore;
|
||||
currentRound.value = result.currentRound + 1;
|
||||
uni.$emit("update-ramain", 0);
|
||||
if (result.currentRound < 5) {
|
||||
currentRound.value += 1;
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
@@ -446,6 +453,12 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
@@ -467,15 +480,14 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
if (msg.endStatus.noSaved) {
|
||||
// uni.showToast({
|
||||
// title: "本场比赛无人射箭,已取消",
|
||||
// icon: "none",
|
||||
// });
|
||||
// 正常每回合结束通知,回合会加上1
|
||||
currentRound.value += 1;
|
||||
currentBluePoint.value = 0;
|
||||
currentRedPoint.value = 0;
|
||||
showRoundTip.value = true;
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
}, 3000);
|
||||
} else {
|
||||
isEnded.value = true;
|
||||
uni.setStorageSync("last-battle", msg.endStatus);
|
||||
@@ -559,7 +571,11 @@ onHide(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="对战" :onBack="onBack" :bgType="battleId ? 1 : 0">
|
||||
<Container
|
||||
:title="`好友约战 - ${roomNumber}`"
|
||||
:onBack="onBack"
|
||||
:bgType="battleId ? 1 : 0"
|
||||
>
|
||||
<view class="standby-phase" v-if="step === 1">
|
||||
<Guide>
|
||||
<view class="battle-guide">
|
||||
@@ -568,7 +584,7 @@ onHide(() => {
|
||||
<text v-if="battleType === 1">1v1比赛即将开始! </text>
|
||||
<text v-if="battleType === 2">大乱斗即将开始! </text>
|
||||
</view>
|
||||
<view @click="setClipboardData">邀请好友</view>
|
||||
<view @click="setClipboardData">复制房间号</view>
|
||||
</view>
|
||||
</Guide>
|
||||
<view v-if="battleType === 1" class="team-mode">
|
||||
|
||||
@@ -33,9 +33,11 @@ const enterRoom = debounce(async () => {
|
||||
);
|
||||
if (!alreadyIn) {
|
||||
const result = await joinRoomAPI(roomNumber.value);
|
||||
if (result.full) warnning.value = "房间已满员";
|
||||
showModal.value = true;
|
||||
return;
|
||||
if (result.full) {
|
||||
warnning.value = "房间已满员";
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
roomNumber.value = "";
|
||||
showModal.value = false;
|
||||
|
||||
@@ -168,7 +168,7 @@ async function onReceiveMessage(messages = []) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/battle-result",
|
||||
});
|
||||
}, 1500);
|
||||
}, 3000);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||
uni.$emit("update-header-loading", false);
|
||||
|
||||
@@ -121,7 +121,7 @@ const updateData = () => {
|
||||
currentSeasonData.value[keyName] = {
|
||||
totalGames: item.totalGames,
|
||||
winCount: item.winCount,
|
||||
winRate: Number(((item.winCount / item.totalGames) * 100).toFixed(2)),
|
||||
winRate: Number(((item.winCount / item.totalGames) * 100).toFixed(1)),
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -195,7 +195,7 @@ onShow(async () => {
|
||||
<view>
|
||||
<text>赛季胜率</text>
|
||||
<text :style="{ color: '#FF507E' }">{{
|
||||
rankData.user.avg_win ? rankData.user.avg_win + "%" : "-"
|
||||
rankData.user.avg_win ? rankData.user.avg_win * 100 + "%" : "-"
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -83,16 +83,14 @@ function recoverData(battleInfo) {
|
||||
redPoints.value += 2;
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
}, 300);
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
if (
|
||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
@@ -111,15 +109,35 @@ function recoverData(battleInfo) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (battleInfo.status !== 11) return;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
if (redTeam.value[0].id === currentShooterId.value) {
|
||||
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
} else {
|
||||
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
if (redTeam.value[0].id === currentShooterId.value)
|
||||
tips.value = "请红队射箭";
|
||||
else tips.value = "请蓝队射箭";
|
||||
tips.value += isFinalShoot.value
|
||||
? "决金箭"
|
||||
: `第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
if (battleInfo.fireTime > 0) {
|
||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||
@@ -198,21 +216,15 @@ async function onReceiveMessage(messages = []) {
|
||||
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]) {
|
||||
if (isRed && roundResults.value[currentRound.value - 1].redArrows) {
|
||||
roundResults.value[currentRound.value - 1].redArrows.push(msg.target);
|
||||
}
|
||||
if (!isRed && roundResults.value[currentRound.value - 1].blueArrows) {
|
||||
roundResults.value[currentRound.value - 1].blueArrows.push(
|
||||
msg.target
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!roundResults.value[currentRound.value - 1]) {
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
}
|
||||
roundResults.value[currentRound.value - 1][
|
||||
isRed ? "redArrows" : "blueArrows"
|
||||
].push(msg.target);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
const result = msg.preRoundResult;
|
||||
@@ -223,8 +235,8 @@ async function onReceiveMessage(messages = []) {
|
||||
currentRedPoint.value = result.redScore;
|
||||
bluePoints.value += result.blueScore;
|
||||
redPoints.value += result.redScore;
|
||||
currentRound.value = result.currentRound + 1;
|
||||
if (result.currentRound < 5) {
|
||||
currentRound.value = result.currentRound + 1;
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
@@ -234,6 +246,11 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
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;
|
||||
@@ -242,15 +259,13 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
if (msg.endStatus.noSaved) {
|
||||
// uni.showToast({
|
||||
// title: "本场比赛无人射箭,已取消",
|
||||
// icon: "none",
|
||||
// });
|
||||
currentRound.value += 1;
|
||||
currentBluePoint.value = 0;
|
||||
currentRedPoint.value = 0;
|
||||
showRoundTip.value = true;
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
}, 3000);
|
||||
} else {
|
||||
isEnded.value = true;
|
||||
uni.setStorageSync("last-battle", msg.endStatus);
|
||||
|
||||
Reference in New Issue
Block a user