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

@@ -152,8 +152,6 @@ export const getGameAPI = async (battleId) => {
}; };
if (battleStats.mode === 1) { if (battleStats.mode === 1) {
data.winner = battleStats.winner; data.winner = battleStats.winner;
data.redTotal = battleStats.redTotal;
data.blueTotal = battleStats.blueTotal;
data.roundsData = {}; data.roundsData = {};
data.redPlayers = {}; data.redPlayers = {};
data.bluePlayers = {}; data.bluePlayers = {};

View File

@@ -53,6 +53,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
mode: {
type: String,
default: "solo", // solo 单排team 双排
},
}); });
const showRoundTips = ref(false); const showRoundTips = ref(false);
@@ -89,6 +93,23 @@ watch(
} }
); );
watch(
() => props.blueScores,
(newVal) => {
if (newVal.length - prevLength.value === 1) {
if (timer.value) clearTimeout(timer.value);
showRoundTips.value = true;
timer.value = setTimeout(() => {
showRoundTips.value = false;
}, 1000);
}
prevLength.value = newVal.length;
},
{
deep: true,
}
);
function calcRealX(num) { function calcRealX(num) {
const len = 20 + num; const len = 20 + num;
return `calc(${(len / 40) * 100}% - 10px)`; return `calc(${(len / 40) * 100}% - 10px)`;
@@ -124,16 +145,24 @@ const simulShoot = async () => {
class="round-tip fade-in" class="round-tip fade-in"
>{{ scores[scores.length - 1].ring }}<text></text></view >{{ scores[scores.length - 1].ring }}<text></text></view
> >
<view
v-if="blueScores.length && showRoundTips && showLatestArrow"
class="round-tip fade-in"
>{{ blueScores[blueScores.length - 1].ring }}<text></text></view
>
<block v-for="(bow, index) in scores" :key="index"> <block v-for="(bow, index) in scores" :key="index">
<image <image
v-if="bow.ring > 0" v-if="bow.ring > 0"
:src=" :src="
index === scores.length - 1 && !blueScores.length && showLatestArrow index === scores.length - 1 &&
!blueScores.length &&
showLatestArrow &&
mode !== 'team'
? '../static/hit-icon-green.png' ? '../static/hit-icon-green.png'
: '../static/hit-icon.png' : '../static/hit-icon.png'
" "
:class="`hit ${ :class="`hit ${
index + 1 === scores.length && !blueScores.length && showLatestArrow index === scores.length - 1 && !blueScores.length && showLatestArrow
? 'pump-in' ? 'pump-in'
: '' : ''
}`" }`"
@@ -148,6 +177,7 @@ const simulShoot = async () => {
v-if="bow.ring > 0" v-if="bow.ring > 0"
src="../static/hit-icon-blue.png" src="../static/hit-icon-blue.png"
class="hit" class="hit"
:class="`hit ${blueScores.length === 1 ? 'pump-in' : ''}`"
:style="{ :style="{
left: calcRealX(bow.x), left: calcRealX(bow.x),
top: calcRealY(bow.y), top: calcRealY(bow.y),

View File

@@ -75,7 +75,7 @@ watch(
clearInterval(timer.value); clearInterval(timer.value);
setTimeout(() => { setTimeout(() => {
newVal(); newVal();
}, 1000); }, 2000);
} else { } else {
totalTop.value += 0.5; totalTop.value += 0.5;
} }
@@ -117,7 +117,7 @@ onUnmounted(() => {
v-for="(name, index) in playerNames" v-for="(name, index) in playerNames"
:key="index" :key="index"
:style="{ :style="{
lineHeight: `${98 / 7}vw`, lineHeight: `${95 / 7}vw`,
...(textStyles[index] || {}), ...(textStyles[index] || {}),
}" }"
> >
@@ -129,7 +129,7 @@ onUnmounted(() => {
v-for="(name, index) in playerNames" v-for="(name, index) in playerNames"
:key="index" :key="index"
:style="{ :style="{
lineHeight: `${98 / 7}vw`, lineHeight: `${95 / 7}vw`,
...(textStyles[index + 7] || {}), ...(textStyles[index + 7] || {}),
}" }"
> >
@@ -153,20 +153,19 @@ onUnmounted(() => {
} }
.matching > view { .matching > view {
width: 70vw; width: 70vw;
height: 98vw; height: 95vw;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
transform: translateY(3vw);
} }
.matching-bg { .matching-bg {
position: absolute; position: absolute;
width: 70vw; width: 70vw;
height: 102vw; height: 102vw;
top: 30vw; top: 27vw;
} }
.matching > button { .matching > button {
width: 55%; width: 55%;
margin-top: 20vw; margin-top: 15vw;
padding: 18px; padding: 18px;
color: #000; color: #000;
background-color: #fed847; background-color: #fed847;
@@ -175,12 +174,11 @@ onUnmounted(() => {
} }
.player-names { .player-names {
width: 100%; width: 100%;
height: 98vw; height: 95vw;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 0; top: 0;
transform: translateY(3vw);
} }
.player-names > text { .player-names > text {
width: 100%; width: 100%;

View File

@@ -18,16 +18,16 @@ const totalPoints = ref(0);
onLoad(async (options) => { onLoad(async (options) => {
battleId.value = options.battleId; battleId.value = options.battleId;
const result = await getGameAPI( const result = await getGameAPI(
// options.battleId || "BATTLE-1750688685843436271-553" options.battleId || "BATTLE-1750867490990424058-718"
options.battleId || "BATTLE-1750688536849458226-518" // options.battleId || "BATTLE-1750688536849458226-518"
); );
data.value = result; data.value = result;
if (result.mode === 1 && result.redPlayers[user.value.id]) { if (result.mode === 1 && result.redPlayers[user.value.id]) {
totalPoints.value = result.redTotal; totalPoints.value = result.redPlayers[user.value.id].totalScore;
ifWin.value = result.winner === 0; ifWin.value = result.winner === 0;
} }
if (result.mode === 1 && result.bluePlayers[user.value.id]) { if (result.mode === 1 && result.bluePlayers[user.value.id]) {
totalPoints.value = result.redTotal; totalPoints.value = result.bluePlayers[user.value.id].totalScore;
ifWin.value = result.winner === 1; ifWin.value = result.winner === 1;
} }
if (result.mode === 2) { if (result.mode === 2) {
@@ -72,7 +72,7 @@ const topThreeColors = ["#FFD947 ", "#D2D2D2", "#FFA515"];
<view class="battle-winner"> <view class="battle-winner">
<image src="../static/shining-bg.png" mode="widthFix" /> <image src="../static/shining-bg.png" mode="widthFix" />
<image src="../static/throphy.png" mode="widthFix" /> <image src="../static/throphy.png" mode="widthFix" />
<text>{{ ifWin && data.winner === 1 ? "蓝队" : "红队" }}获胜</text> <text>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text>
<text>强势登顶荣耀加冕</text> <text>强势登顶荣耀加冕</text>
</view> </view>
</block> </block>
@@ -145,8 +145,12 @@ const topThreeColors = ["#FFD947 ", "#D2D2D2", "#FFA515"];
</block> </block>
<view class="battle-e"> <view class="battle-e">
<image src="../static/row-yellow-bg.png" mode="widthFix" /> <image src="../static/row-yellow-bg.png" mode="widthFix" />
<text v-if="data.gameMode === 1">经验 +{{ totalPoints }}</text> <text v-if="data.gameMode === 1"
<text v-if="data.gameMode === 2">积分 +{{ totalPoints }}</text> >经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
>
<text v-if="data.gameMode === 2"
>积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
>
</view> </view>
<text v-if="data.mode === 1" class="description">你是朋友中的佼佼者哦</text> <text v-if="data.mode === 1" class="description">你是朋友中的佼佼者哦</text>
<text v-if="data.mode === 2" class="description" <text v-if="data.mode === 2" class="description"

View File

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

View File

@@ -28,6 +28,7 @@ const currentBluePoint = ref(0);
const totalRounds = ref(0); const totalRounds = ref(0);
const power = ref(0); const power = ref(0);
const scores = ref([]); const scores = ref([]);
const blueScores = ref([]);
const redTeam = ref([]); const redTeam = ref([]);
const blueTeam = ref([]); const blueTeam = ref([]);
const currentShooterId = ref(0); const currentShooterId = ref(0);
@@ -89,6 +90,7 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) { if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
scores.value = []; scores.value = [];
blueScores.value = [];
seq.value += 1; seq.value += 1;
currentShooterId.value = msg.userId; currentShooterId.value = msg.userId;
if (redTeam.value[0].id === currentShooterId.value) { if (redTeam.value[0].id === currentShooterId.value) {
@@ -98,11 +100,16 @@ async function onReceiveMessage(messages = []) {
} }
} }
if (msg.constructor === MESSAGETYPES.ShootResult) { if (msg.constructor === MESSAGETYPES.ShootResult) {
const isRed = redTeam.value.find((item) => item.id === msg.userId);
if (isRed) {
scores.value = [msg.target]; scores.value = [msg.target];
} else {
blueScores.value = [msg.target];
}
} }
if (msg.constructor === MESSAGETYPES.RoundPoint) { if (msg.constructor === MESSAGETYPES.RoundPoint) {
bluePoints.value += msg.blueScore; // bluePoints.value += msg.blueScore;
redPoints.value += msg.redScore; // redPoints.value += msg.redScore;
} }
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
const result = msg.preRoundResult; const result = msg.preRoundResult;
@@ -110,6 +117,8 @@ async function onReceiveMessage(messages = []) {
currentShooterId.value = 0; currentShooterId.value = 0;
currentBluePoint.value = result.blueScore; currentBluePoint.value = result.blueScore;
currentRedPoint.value = result.redScore; currentRedPoint.value = result.redScore;
bluePoints.value += result.blueScore;
redPoints.value += result.redScore;
showRoundTip.value = true; showRoundTip.value = true;
// 开始下一轮; // 开始下一轮;
roundResults.value = result.roundResults; roundResults.value = result.roundResults;
@@ -159,11 +168,13 @@ onUnmounted(() => {
:redTeam="redTeam" :redTeam="redTeam"
/> />
<BowTarget <BowTarget
mode="team"
:showE="start && user.id === currentShooterId" :showE="start && user.id === currentShooterId"
:power="start ? power : 0" :power="start ? power : 0"
:currentRound="currentRound" :currentRound="currentRound"
:totalRound="totalRounds" :totalRound="totalRounds"
:scores="scores" :scores="scores"
:blueScores="blueScores"
:tips=" :tips="
!start && scores.length > 0 !start && scores.length > 0
? `本次射程${scores[scores.length - 1].dst / 100}米,${ ? `本次射程${scores[scores.length - 1].dst / 100}米,${