细节完善

This commit is contained in:
kron
2025-07-25 15:18:46 +08:00
parent e5b1194882
commit 10af25c254
7 changed files with 129 additions and 81 deletions

View File

@@ -41,7 +41,13 @@ defineProps({
</view> </view>
</view> </view>
<block v-if="roundResults.length < 3"> <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> </block>
</view> </view>
<view> <view>
@@ -62,7 +68,13 @@ defineProps({
</view> </view>
</view> </view>
<block v-if="roundResults.length < 3"> <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> </block>
</view> </view>
</view> </view>

View File

@@ -56,7 +56,7 @@ onUnmounted(() => {
<view class="round-end-tip"> <view class="round-end-tip">
<text>{{ round }}轮射击结束</text> <text>{{ round }}轮射击结束</text>
<block v-if="!isFinal"> <block v-if="!isFinal">
<view class="point-view1"> <view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
<text>本轮蓝队</text> <text>本轮蓝队</text>
<text>{{ <text>{{
(roundData.blueArrows || []).reduce( (roundData.blueArrows || []).reduce(
@@ -73,10 +73,13 @@ onUnmounted(() => {
}}</text> }}</text>
<text></text> <text></text>
</view> </view>
<text v-if="bluePoint === 0 && redPoint === 0"> <text
本场比赛无人射箭已取消 v-if="bluePoint === 0 && redPoint === 0"
:style="{ marginTop: '20px' }"
>
连续3个来回无人射箭比赛被取消
</text> </text>
<text v-if="bluePoint === redPoint"> <text v-if="bluePoint !== 0 && bluePoint === redPoint">
红队蓝队各得<text :style="{ color: '#fed847', margin: '0 5px' }">{{ 红队蓝队各得<text :style="{ color: '#fed847', margin: '0 5px' }">{{
redPoint redPoint
}}</text }}</text

View File

@@ -124,7 +124,6 @@ function recoverData(battleInfo) {
redPoints.value += 2; redPoints.value += 2;
} }
}); });
setTimeout(() => {
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) { if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
scores.value = battleInfo.roundResults[ scores.value = battleInfo.roundResults[
battleInfo.roundResults.length - 1 battleInfo.roundResults.length - 1
@@ -133,7 +132,6 @@ function recoverData(battleInfo) {
battleInfo.roundResults.length - 1 battleInfo.roundResults.length - 1
].blueArrows.filter((item) => !!item.playerId); ].blueArrows.filter((item) => !!item.playerId);
} }
}, 300);
if ( if (
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] || battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound] battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
@@ -152,16 +150,36 @@ function recoverData(battleInfo) {
blueArrows: [], 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.status !== 11) return;
if (battleInfo.firePlayerIndex) { if (battleInfo.firePlayerIndex) {
currentShooterId.value = battleInfo.firePlayerIndex; currentShooterId.value = battleInfo.firePlayerIndex;
if (redTeam.value[0].id === currentShooterId.value) { if (redTeam.value[0].id === currentShooterId.value)
tips.value = `请红队射箭-第${roundsName[currentRound.value]}`; tips.value = "请红队射箭";
} else { else tips.value = "请蓝队射箭";
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}`; tips.value += isFinalShoot.value
} ? "决金箭"
: `${roundsName[currentRound.value]}`;
} }
if (battleInfo.fireTime > 0) { if (battleInfo.fireTime > 0) {
const remain = Date.now() / 1000 - battleInfo.fireTime; 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); const isRed = redTeam.value.find((item) => item.id === msg.userId);
if (isRed) scores.value.push(msg.target); if (isRed) scores.value.push(msg.target);
else blueScores.value.push(msg.target); else blueScores.value.push(msg.target);
if (roundResults.value[currentRound.value - 1]) { 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 {
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
blueArrows: [], blueArrows: [],
}); });
} }
roundResults.value[currentRound.value - 1][
isRed ? "redArrows" : "blueArrows"
].push(msg.target);
} }
if (battleType.value === 2 && msg.userId === user.value.id) { if (battleType.value === 2 && msg.userId === user.value.id) {
scores.value.push({ ...msg.target }); scores.value.push({ ...msg.target });
@@ -434,9 +441,9 @@ async function onReceiveMessage(messages = []) {
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore; bluePoints.value += result.blueScore;
redPoints.value += result.redScore; redPoints.value += result.redScore;
currentRound.value = result.currentRound + 1;
uni.$emit("update-ramain", 0); uni.$emit("update-ramain", 0);
if (result.currentRound < 5) { if (result.currentRound < 5) {
currentRound.value += 1;
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
blueArrows: [], blueArrows: [],
@@ -446,6 +453,12 @@ async function onReceiveMessage(messages = []) {
} }
} }
if (msg.constructor === MESSAGETYPES.FinalShoot) { if (msg.constructor === MESSAGETYPES.FinalShoot) {
currentShooterId.value = 0;
currentRound.value += 1;
roundResults.value.push({
redArrows: [],
blueArrows: [],
});
if (!isFinalShoot.value) { if (!isFinalShoot.value) {
isFinalShoot.value = true; isFinalShoot.value = true;
showRoundTip.value = true; showRoundTip.value = true;
@@ -467,15 +480,14 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
if (msg.endStatus.noSaved) { if (msg.endStatus.noSaved) {
// uni.showToast({ // 正常每回合结束通知回合会加上1
// title: "本场比赛无人射箭,已取消", currentRound.value += 1;
// icon: "none",
// });
currentBluePoint.value = 0; currentBluePoint.value = 0;
currentRedPoint.value = 0; currentRedPoint.value = 0;
showRoundTip.value = true;
setTimeout(() => { setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 1500); }, 3000);
} else { } else {
isEnded.value = true; isEnded.value = true;
uni.setStorageSync("last-battle", msg.endStatus); uni.setStorageSync("last-battle", msg.endStatus);
@@ -559,7 +571,11 @@ onHide(() => {
</script> </script>
<template> <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"> <view class="standby-phase" v-if="step === 1">
<Guide> <Guide>
<view class="battle-guide"> <view class="battle-guide">
@@ -568,7 +584,7 @@ onHide(() => {
<text v-if="battleType === 1">1v1比赛即将开始! </text> <text v-if="battleType === 1">1v1比赛即将开始! </text>
<text v-if="battleType === 2">大乱斗即将开始! </text> <text v-if="battleType === 2">大乱斗即将开始! </text>
</view> </view>
<view @click="setClipboardData">邀请好友</view> <view @click="setClipboardData">复制房间号</view>
</view> </view>
</Guide> </Guide>
<view v-if="battleType === 1" class="team-mode"> <view v-if="battleType === 1" class="team-mode">

View File

@@ -33,10 +33,12 @@ const enterRoom = debounce(async () => {
); );
if (!alreadyIn) { if (!alreadyIn) {
const result = await joinRoomAPI(roomNumber.value); const result = await joinRoomAPI(roomNumber.value);
if (result.full) warnning.value = "房间已满员"; if (result.full) {
warnning.value = "房间已满员";
showModal.value = true; showModal.value = true;
return; return;
} }
}
roomNumber.value = ""; roomNumber.value = "";
showModal.value = false; showModal.value = false;
uni.navigateTo({ uni.navigateTo({

View File

@@ -168,7 +168,7 @@ async function onReceiveMessage(messages = []) {
uni.redirectTo({ uni.redirectTo({
url: "/pages/battle-result", url: "/pages/battle-result",
}); });
}, 1500); }, 3000);
} }
if (msg.constructor === MESSAGETYPES.BackToGame) { if (msg.constructor === MESSAGETYPES.BackToGame) {
uni.$emit("update-header-loading", false); uni.$emit("update-header-loading", false);

View File

@@ -121,7 +121,7 @@ const updateData = () => {
currentSeasonData.value[keyName] = { currentSeasonData.value[keyName] = {
totalGames: item.totalGames, totalGames: item.totalGames,
winCount: item.winCount, 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> <view>
<text>赛季胜率</text> <text>赛季胜率</text>
<text :style="{ color: '#FF507E' }">{{ <text :style="{ color: '#FF507E' }">{{
rankData.user.avg_win ? rankData.user.avg_win + "%" : "-" rankData.user.avg_win ? rankData.user.avg_win * 100 + "%" : "-"
}}</text> }}</text>
</view> </view>
</view> </view>

View File

@@ -83,7 +83,6 @@ function recoverData(battleInfo) {
redPoints.value += 2; redPoints.value += 2;
} }
}); });
setTimeout(() => {
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) { if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
scores.value = battleInfo.roundResults[ scores.value = battleInfo.roundResults[
battleInfo.roundResults.length - 1 battleInfo.roundResults.length - 1
@@ -92,7 +91,6 @@ function recoverData(battleInfo) {
battleInfo.roundResults.length - 1 battleInfo.roundResults.length - 1
].blueArrows.filter((item) => !!item.playerId); ].blueArrows.filter((item) => !!item.playerId);
} }
}, 300);
if ( if (
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] || battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound] battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
@@ -111,15 +109,35 @@ function recoverData(battleInfo) {
blueArrows: [], 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.status !== 11) return;
if (battleInfo.firePlayerIndex) { if (battleInfo.firePlayerIndex) {
currentShooterId.value = battleInfo.firePlayerIndex; currentShooterId.value = battleInfo.firePlayerIndex;
if (redTeam.value[0].id === currentShooterId.value) { if (redTeam.value[0].id === currentShooterId.value)
tips.value = `请红队射箭-第${roundsName[currentRound.value]}`; tips.value = "请红队射箭";
} else { else tips.value = "请蓝队射箭";
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}`; tips.value += isFinalShoot.value
} ? "决金箭"
: `${roundsName[currentRound.value]}`;
} }
if (battleInfo.fireTime > 0) { if (battleInfo.fireTime > 0) {
const remain = Date.now() / 1000 - battleInfo.fireTime; 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); const isRed = redTeam.value.find((item) => item.id === msg.userId);
if (isRed) scores.value.push(msg.target); if (isRed) scores.value.push(msg.target);
else blueScores.value.push(msg.target); else blueScores.value.push(msg.target);
if (roundResults.value[currentRound.value - 1]) { 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 {
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
blueArrows: [], blueArrows: [],
}); });
} }
roundResults.value[currentRound.value - 1][
isRed ? "redArrows" : "blueArrows"
].push(msg.target);
} }
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
const result = msg.preRoundResult; const result = msg.preRoundResult;
@@ -223,8 +235,8 @@ async function onReceiveMessage(messages = []) {
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore; bluePoints.value += result.blueScore;
redPoints.value += result.redScore; redPoints.value += result.redScore;
currentRound.value = result.currentRound + 1;
if (result.currentRound < 5) { if (result.currentRound < 5) {
currentRound.value = result.currentRound + 1;
roundResults.value.push({ roundResults.value.push({
redArrows: [], redArrows: [],
blueArrows: [], blueArrows: [],
@@ -234,6 +246,11 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.FinalShoot) { if (msg.constructor === MESSAGETYPES.FinalShoot) {
currentShooterId.value = 0; currentShooterId.value = 0;
currentRound.value += 1;
roundResults.value.push({
redArrows: [],
blueArrows: [],
});
if (!isFinalShoot.value) { if (!isFinalShoot.value) {
isFinalShoot.value = true; isFinalShoot.value = true;
showRoundTip.value = true; showRoundTip.value = true;
@@ -242,15 +259,13 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
if (msg.endStatus.noSaved) { if (msg.endStatus.noSaved) {
// uni.showToast({ currentRound.value += 1;
// title: "本场比赛无人射箭,已取消",
// icon: "none",
// });
currentBluePoint.value = 0; currentBluePoint.value = 0;
currentRedPoint.value = 0; currentRedPoint.value = 0;
showRoundTip.value = true;
setTimeout(() => { setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 1500); }, 3000);
} else { } else {
isEnded.value = true; isEnded.value = true;
uni.setStorageSync("last-battle", msg.endStatus); uni.setStorageSync("last-battle", msg.endStatus);