细节完善

This commit is contained in:
kron
2025-08-15 11:23:23 +08:00
parent 2a9a373743
commit b46bc7aaa5
9 changed files with 121 additions and 80 deletions

View File

@@ -259,12 +259,14 @@ export const getGameAPI = async (battleId) => {
battleId, battleId,
mode: battleStats.mode, // 1.几V几 2.大乱斗 mode: battleStats.mode, // 1.几V几 2.大乱斗
gameMode: battleStats.gameMode, // 1.约战 2.排位 gameMode: battleStats.gameMode, // 1.约战 2.排位
teamSize: battleStats.teamSize,
}; };
if (battleStats && battleStats.mode === 1) { if (battleStats && battleStats.mode === 1) {
data.winner = battleStats.winner; data.winner = battleStats.winner;
data.roundsData = {}; data.roundsData = {};
data.redPlayers = {}; data.redPlayers = {};
data.bluePlayers = {}; data.bluePlayers = {};
data.mvps = [];
data.goldenRound = data.goldenRound =
goldenRoundRecords && goldenRoundRecords.length goldenRoundRecords && goldenRoundRecords.length
? goldenRoundRecords[0] ? goldenRoundRecords[0]
@@ -277,6 +279,9 @@ export const getGameAPI = async (battleId) => {
if (playerBattleStats.team === 1) { if (playerBattleStats.team === 1) {
data.bluePlayers[playerBattleStats.playerId] = playerBattleStats; data.bluePlayers[playerBattleStats.playerId] = playerBattleStats;
} }
if (playerBattleStats.mvp) {
data.mvps.push(playerBattleStats);
}
roundRecords.forEach((round) => { roundRecords.forEach((round) => {
data.roundsData[round.roundNumber] = { data.roundsData[round.roundNumber] = {
...data.roundsData[round.roundNumber], ...data.roundsData[round.roundNumber],
@@ -284,6 +289,7 @@ export const getGameAPI = async (battleId) => {
}; };
}); });
}); });
data.mvps.sort((a, b) => b.totalRings - a.totalRings);
} }
if (battleStats && battleStats.mode === 2) { if (battleStats && battleStats.mode === 2) {
data.players = []; data.players = [];

View File

@@ -1,3 +1,4 @@
=
<script setup> <script setup>
import BowPower from "@/components/BowPower.vue"; import BowPower from "@/components/BowPower.vue";
import { RoundImages } from "@/constants"; import { RoundImages } from "@/constants";
@@ -14,6 +15,10 @@ defineProps({
type: Number, type: Number,
default: 0, default: 0,
}, },
power: {
type: Number,
default: 0,
},
}); });
</script> </script>
@@ -21,8 +26,13 @@ defineProps({
<view class="container"> <view class="container">
<view class="guide-row"> <view class="guide-row">
<image src="../static/shooter.png" mode="widthFix" /> <image src="../static/shooter.png" mode="widthFix" />
<view :style="{ marginBottom: '10px', transform: 'scale(0.8) translateX(10px)' }"> <view
<BowPower :power="20" /> :style="{
marginBottom: '10px',
transform: 'scale(0.8) translateX(10px)',
}"
>
<BowPower :power="power" />
</view> </view>
</view> </view>
<view> <view>
@@ -47,9 +57,12 @@ defineProps({
</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 v-for="i in 3 - roundResults.length" :key="i">
<image :src="RoundImages[`round${i}`]" mode="widthFix" /> <image
:src="RoundImages[`round${i + roundResults.length}`]"
mode="widthFix"
/>
<view> <view>
<text>{{ i }}</text> <text></text>
<text></text> <text></text>
</view> </view>
</view> </view>
@@ -71,7 +84,10 @@ defineProps({
</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 v-for="i in 3 - roundResults.length" :key="i">
<image :src="RoundImages[`round${i}`]" mode="widthFix" /> <image
:src="RoundImages[`round${i + roundResults.length}`]"
mode="widthFix"
/>
<view> <view>
<text></text> <text></text>
<text></text> <text></text>

View File

@@ -295,7 +295,7 @@ onMounted(() => {
} }
.simul { .simul {
position: absolute; position: absolute;
bottom: 20px; bottom: 40px;
right: 20px; right: 20px;
margin-left: 20px; margin-left: 20px;
} }

View File

@@ -27,7 +27,6 @@ watch(
if (newVal.includes("蓝队")) key = "请蓝方射击"; if (newVal.includes("蓝队")) key = "请蓝方射击";
if (key && sound.value) { if (key && sound.value) {
if (currentRoundEnded.value) { if (currentRoundEnded.value) {
currentRound.value += 1;
currentRoundEnded.value = false; currentRoundEnded.value = false;
if (currentRound.value === 1) audioManager.play("第一轮"); if (currentRound.value === 1) audioManager.play("第一轮");
if (currentRound.value === 2) audioManager.play("第二轮"); if (currentRound.value === 2) audioManager.play("第二轮");
@@ -63,14 +62,17 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.WaitForAllReady) { } else if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
battleId.value = msg.id; battleId.value = msg.id;
} else if (msg.constructor === MESSAGETYPES.AllReady) { } else if (msg.constructor === MESSAGETYPES.AllReady) {
currentRoundEnded.value = true;
audioManager.play("比赛开始"); audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) { } else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
melee.value = true; melee.value = true;
halfTime.value = false; halfTime.value = false;
audioManager.play("比赛开始"); audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { } else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentRound.value += 1; if (msg.preRoundResult && msg.preRoundResult.currentRound) {
currentRoundEnded.value = true; currentRound.value = msg.preRoundResult.currentRound + 1;
currentRoundEnded.value = true;
}
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) { } else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
halfTime.value = true; halfTime.value = true;
audioManager.play("中场休息"); audioManager.play("中场休息");
@@ -113,7 +115,7 @@ onUnmounted(() => {
<view class="container"> <view class="container">
<text>{{ tips }}</text> <text>{{ tips }}</text>
<!-- <text> ({{ currentRound }}/{{ totalRound }}) </text> --> <!-- <text> ({{ currentRound }}/{{ totalRound }}) </text> -->
<button hover-class="none" @click="updateSound"> <button v-if="!!tips" hover-class="none" @click="updateSound">
<image <image
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`" :src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
mode="widthFix" mode="widthFix"

View File

@@ -16,7 +16,7 @@ const props = defineProps({
}, },
}); });
const barColor = ref("linear-gradient( 180deg, #FFA0A0 0%, #FF6060 100%)"); const barColor = ref("");
const remain = ref(15); const remain = ref(15);
const timer = ref(null); const timer = ref(null);

View File

@@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, watch } from "vue"; import { ref, watch, onMounted } from "vue";
const props = defineProps({ const props = defineProps({
isRed: { isRed: {
type: Boolean, type: Boolean,
@@ -18,13 +18,33 @@ const props = defineProps({
default: false, default: false,
}, },
}); });
const players = ref(props.team); const players = ref({});
const youTurn = ref(false); const youTurn = ref(false);
const firstName = ref("");
onMounted(() => {
props.team.forEach((p, index) => {
players.value[p.id] = { sort: index, ...p };
});
});
watch( watch(
() => props.currentShooterId, () => props.currentShooterId,
(newVal) => { (newVal) => {
const exit = props.team.some((p) => p.id === newVal); if (!newVal) return;
youTurn.value = !!exit; const index = props.team.findIndex((p) => p.id === newVal);
youTurn.value = index >= 0;
if (index >= 0) {
const newPlayers = [...props.team];
const target = newPlayers.splice(index, 1)[0];
if (target) {
newPlayers.unshift(target);
firstName.value = target.name;
newPlayers.forEach((p, index) => {
players.value[p.id] = { sort: index, ...p };
});
}
}
}, },
{ immediate: true } { immediate: true }
); );
@@ -37,17 +57,22 @@ watch(
:key="index" :key="index"
class="player" class="player"
:style="{ :style="{
width: (youTurn ? 40 - index * 5 : 30) + 'px', width:
height: (youTurn ? 40 - index * 5 : 30) + 'px', (youTurn ? 40 - ((players[item.id] || {}).sort || 0) * 5 : 35) + 'px',
height:
(youTurn ? 40 - ((players[item.id] || {}).sort || 0) * 5 : 35) + 'px',
borderColor: isRed ? '#ff6060' : '#5fadff', borderColor: isRed ? '#ff6060' : '#5fadff',
zIndex: players.length - index, zIndex: team.length - ((players[item.id] || {}).sort || 0),
top: youTurn ? index * 2 + 'px' : '6px', top: youTurn ? ((players[item.id] || {}).sort || 0) * 2 + 'px' : '6px',
left: (isRed ? index * 20 : 35 - index * 15) + 'px', left:
(isRed
? ((players[item.id] || {}).sort || 0) * 20
: 35 - ((players[item.id] || {}).sort || 0) * 15) + 'px',
}" }"
> >
<image :src="item.avatar || '../static/user-icon.png'" mode="widthFix" /> <image :src="item.avatar || '../static/user-icon.png'" mode="widthFix" />
<text <text
v-if="youTurn && index === 0" v-if="youTurn && ((players[item.id] || {}).sort || 0) === 0"
:style="{ backgroundColor: isRed ? '#ff6060' : '#5fadff' }" :style="{ backgroundColor: isRed ? '#ff6060' : '#5fadff' }"
>{{ isRed ? "红队" : "蓝队" }}</text >{{ isRed ? "红队" : "蓝队" }}</text
> >
@@ -59,7 +84,7 @@ watch(
color: isRed ? '#ff6060' : '#5fadff', color: isRed ? '#ff6060' : '#5fadff',
[isRed ? 'left' : 'right']: 0, [isRed ? 'left' : 'right']: 0,
}" }"
>{{ team[0].name }}</text >{{ firstName }}</text
> >
</view> </view>
</template> </template>

View File

@@ -21,12 +21,10 @@ function exit() {
} }
onLoad(async (options) => { onLoad(async (options) => {
// const myId = user.value.id; const myId = user.value.id;
const myId = 39;
if (options.battleId) { if (options.battleId) {
const result = await getGameAPI( const result = await getGameAPI(
options.battleId || "BATTLE-1754302650041171466-546" options.battleId || "BATTLE-1755156795334880000-865"
// options.battleId || "BATTLE-1754017978280570919-571"
); );
data.value = { data.value = {
...result, ...result,
@@ -58,12 +56,17 @@ onLoad(async (options) => {
} else { } else {
const battleInfo = uni.getStorageSync("last-battle"); const battleInfo = uni.getStorageSync("last-battle");
if (!battleInfo) return; if (!battleInfo) return;
data.value = battleInfo; data.value = {
mvps: [],
...battleInfo,
};
if (battleInfo.mode === 1) { if (battleInfo.mode === 1) {
battleInfo.playerStats.forEach((p) => { battleInfo.playerStats.forEach((p) => {
if (p.team === 1) data.value.bluePlayers = [p]; if (p.team === 1) data.value.bluePlayers = [p];
if (p.team === 0) data.value.redPlayers = [p]; if (p.team === 0) data.value.redPlayers = [p];
if (p.mvp) data.value.mvps.push(p);
}); });
data.value.mvps.sort((a, b) => b.totalRings - a.totalRings);
} }
rank.value = 0; rank.value = 0;
const mine = battleInfo.playerStats.find((p, index) => { const mine = battleInfo.playerStats.find((p, index) => {
@@ -90,7 +93,7 @@ const checkBowData = () => {
<block v-if="data.mode === 1"> <block v-if="data.mode === 1">
<view class="header-team" :style="{ marginTop: '25%' }"> <view class="header-team" :style="{ marginTop: '25%' }">
<image src="../static/battle-result.png" mode="widthFix" /> <image src="../static/battle-result.png" mode="widthFix" />
<!-- <view class="header-solo"> <view class="header-solo" v-if="data.teamSize === 2">
<text <text
:style="{ :style="{
background: background:
@@ -110,47 +113,38 @@ const checkBowData = () => {
:borderColor="data.winner === 1 ? '#5FADFF' : '#FF5656'" :borderColor="data.winner === 1 ? '#5FADFF' : '#FF5656'"
mode="widthFix" mode="widthFix"
/> />
</view> --> </view>
</view> </view>
<view class="header-mvp"> <view class="header-mvp" v-if="data.teamSize !== 2">
<image src="../static/red-team-win.png" mode="widthFix" /> <image
:src="`../static/${data.winner === 1 ? 'blue' : 'red'}-team-win.png`"
mode="widthFix"
/>
<view> <view>
<view> <view v-if="data.mvps && data.mvps[0].totalRings">
<image src="../static/title-mvp.png" mode="widthFix" /> <image src="../static/title-mvp.png" mode="widthFix" />
<text <text
>斩获<text >斩获<text
:style="{ color: '#fed847', fontSize: '18px', margin: '0 2px' }" :style="{ color: '#fed847', fontSize: '18px', margin: '0 2px' }"
>60</text >{{ data.mvps[0].totalRings }}</text
></text ></text
> >
</view> </view>
<view> <view v-if="data.mvps && data.mvps.length">
<view> <view v-for="(player, index) in data.mvps" :key="index">
<view class="team-avatar"> <view class="team-avatar">
<Avatar <Avatar
:src="user.avatar" :src="player.avatar"
:size="40" :size="40"
:borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'" :borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'"
/> />
<text :style="{ backgroundColor: '#ff6060' }">自己</text> <text
v-if="player.id === user.id"
:style="{ backgroundColor: '#ff6060' }"
>自己</text
>
</view> </view>
<text>某某某</text> <text>{{ player.name }}</text>
</view>
<view>
<Avatar
:src="user.avatar"
:size="40"
:borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'"
/>
<text>某某某</text>
</view>
<view>
<Avatar
:src="user.avatar"
:size="40"
:borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'"
/>
<text>某某某</text>
</view> </view>
</view> </view>
</view> </view>
@@ -513,7 +507,7 @@ const checkBowData = () => {
.header-mvp > view > view:first-child > text { .header-mvp > view > view:first-child > text {
color: #fff; color: #fff;
font-size: 14px; font-size: 14px;
transform: translateY(-4px) skewY(-6deg); transform: translateY(-4px) skewY(-6deg);
} }
.header-mvp > view > view:last-child { .header-mvp > view > view:last-child {
display: flex; display: flex;
@@ -522,6 +516,7 @@ const checkBowData = () => {
font-size: 8px; font-size: 8px;
text-align: center; text-align: center;
transform: translateY(-16px) skewY(-6deg); transform: translateY(-16px) skewY(-6deg);
min-width: 40%;
} }
.header-mvp > view > view:last-child > view { .header-mvp > view > view:last-child > view {
margin-right: 4vw; margin-right: 4vw;

View File

@@ -13,6 +13,8 @@ const { getLvlName } = store;
const defaultSeasonData = { const defaultSeasonData = {
"1v1": { totalGames: 0, winCount: 0, winRate: 0 }, "1v1": { totalGames: 0, winCount: 0, winRate: 0 },
"2v2": { totalGames: 0, winCount: 0, winRate: 0 },
"3v3": { totalGames: 0, winCount: 0, winRate: 0 },
"5m": { totalGames: 0, winCount: 0, winRate: 0 }, "5m": { totalGames: 0, winCount: 0, winRate: 0 },
"10m": { totalGames: 0, winCount: 0, winRate: 0 }, "10m": { totalGames: 0, winCount: 0, winRate: 0 },
}; };
@@ -98,6 +100,8 @@ const updateData = () => {
} }
let keyName = ""; let keyName = "";
if (item.gameType === 1 && item.teamSize === 2) keyName = "1v1"; if (item.gameType === 1 && item.teamSize === 2) keyName = "1v1";
if (item.gameType === 1 && item.teamSize === 3) keyName = "2v2";
if (item.gameType === 1 && item.teamSize === 5) keyName = "3v3";
if (item.gameType === 2 && item.teamSize === 5) keyName = "5m"; if (item.gameType === 2 && item.teamSize === 5) keyName = "5m";
if (item.gameType === 2 && item.teamSize === 10) keyName = "10m"; if (item.gameType === 2 && item.teamSize === 10) keyName = "10m";
if (keyName) { if (keyName) {
@@ -234,13 +238,13 @@ onShow(async () => {
<view class="data-progress"> <view class="data-progress">
<text> <text>
{{ {{
`【2 V 2】${currentSeasonData["1v1"].totalGames}场 胜率 ${currentSeasonData["1v1"].winRate}%` `【2 V 2】${currentSeasonData["2v2"].totalGames}场 胜率 ${currentSeasonData["2v2"].winRate}%`
}} }}
</text> </text>
<view> <view>
<view <view
:style="{ :style="{
width: `${currentSeasonData['1v1'].winRate}%`, width: `${currentSeasonData['2v2'].winRate}%`,
backgroundColor: '#69B5FF', backgroundColor: '#69B5FF',
}" }"
/> />
@@ -249,7 +253,7 @@ onShow(async () => {
<view class="data-progress"> <view class="data-progress">
<text> <text>
{{ {{
`【3 V 3】${currentSeasonData["1v1"].totalGames}场 胜率 ${currentSeasonData["1v1"].winRate}%` `【3 V 3】${currentSeasonData["3v3"].totalGames}场 胜率 ${currentSeasonData["3v3"].winRate}%`
}} }}
</text> </text>
<view> <view>

View File

@@ -130,17 +130,10 @@ function recoverData(battleInfo) {
// if (battleInfo.status !== 11) return; // if (battleInfo.status !== 11) return;
if (battleInfo.firePlayerIndex) { if (battleInfo.firePlayerIndex) {
currentShooterId.value = battleInfo.firePlayerIndex; currentShooterId.value = battleInfo.firePlayerIndex;
// const teamPrefix = const redPlayer = redTeam.value.find(
// redTeam.value[0].id === currentShooterId.value (item) => item.id === currentShooterId.value
// ? "请红队射箭 - " );
// : "请蓝队射箭 - "; tips.value = redPlayer ? "请红队射箭" : "请蓝队射箭";
// const roundSuffix = isFinalShoot.value
// ? "决金箭"
// : `第${roundsName[currentRound.value]}轮`;
tips.value =
redTeam.value[0].id === currentShooterId.value
? "请红队射箭"
: "请蓝队射箭";
uni.$emit("update-tips", tips.value); uni.$emit("update-tips", tips.value);
} }
if (battleInfo.fireTime > 0) { if (battleInfo.fireTime > 0) {
@@ -171,17 +164,16 @@ async function onReceiveMessage(messages = []) {
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) { if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
if (currentShooterId.value !== msg.userId) { if (currentShooterId.value !== msg.userId) {
currentShooterId.value = msg.userId; currentShooterId.value = msg.userId;
// const teamPrefix = const redPlayer = redTeam.value.find(
// redTeam.value[0].id === currentShooterId.value (item) => item.id === currentShooterId.value
// ? "请红队射箭 - " );
// : "请蓝队射箭 - "; tips.value = redPlayer ? "请红队射箭" : "请蓝队射箭";
// const roundSuffix = isFinalShoot.value uni.$emit("update-tips", tips.value);
// ? "决金箭" // if (redPlayer) tips.value = "红队" + redPlayer.id;
// : `第${roundsName[currentRound.value]}轮`; // const bluePlayer = blueTeam.value.find(
tips.value = // (item) => item.id === currentShooterId.value
redTeam.value[0].id === currentShooterId.value // );
? "请红队射箭" // if (bluePlayer) tips.value = "蓝队" + bluePlayer.id;
: "请蓝队射箭";
uni.$emit("update-tips", tips.value); uni.$emit("update-tips", tips.value);
} }
} }
@@ -331,6 +323,7 @@ onHide(() => {
:roundResults="roundResults" :roundResults="roundResults"
:redPoints="redPoints" :redPoints="redPoints"
:bluePoints="bluePoints" :bluePoints="bluePoints"
:power="power"
/> />
<Timer v-if="!start" /> <Timer v-if="!start" />
<ScreenHint <ScreenHint