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

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

View File

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