fix:修复合并错误

This commit is contained in:
tsui110 2026-01-03 16:51:45 +08:00
parent 9309277047
commit a304e66e75

View File

@ -232,24 +232,15 @@
</view> </view>
<!-- 结算弹窗 --> <!-- 结算弹窗 -->
<<<<<<< HEAD
<view v-if="shouldShowResultModal" class="modal-overlay"> <view v-if="shouldShowResultModal" class="modal-overlay">
<view class="modal-content glass-card"> <view class="modal-content glass-card">
<text class="modal-emoji">{{ gameState.winnerId === myUserId ? '🏆' : '💀' }}</text> <text class="modal-emoji">{{ getGameResultEmoji() }}</text>
<text class="modal-title">{{ gameState.winnerId === myUserId ? '胜利!' : '很遗憾失败了' }}</text> <text class="modal-title">{{ getGameResultTitle() }}</text>
<view class="result-details" v-if="gameState.players"> <view class="result-details" v-if="gameState.players">
<text class="detail-text">{{ getResultMessage() }}</text> <text class="detail-text">{{ getResultMessage() }}</text>
</view> </view>
<view <view
class="btn-primary" class="btn-primary"
=======
<view v-if="gameState && !gameState.gameStarted && gameState.winnerId" class="modal-overlay">
<view class="modal-content glass-card">
<text class="modal-emoji">{{ gameState.winnerId === 'draw' ? '🤝' : (gameState.winnerId === myUserId ? '🏆' : '💀') }}</text>
<text class="modal-title">{{ gameState.winnerId === 'draw' ? '平局' : (gameState.winnerId === myUserId ? '胜利!' : '很遗憾失败了') }}</text>
<view
class="btn-primary"
>>>>>>> c028a29943b7b201a73114cb14a1109deb3af339
:class="{ disabled: isRefreshing }" :class="{ disabled: isRefreshing }"
@tap="refreshAndPlayAgain" @tap="refreshAndPlayAgain"
> >
@ -662,21 +653,25 @@ export default {
console.log('[游戏结束] gameStarted:', this.gameState.gameStarted); console.log('[游戏结束] gameStarted:', this.gameState.gameStarted);
console.log('[游戏结束] 是否显示弹窗:', !this.gameState.gameStarted && !!this.gameState.winnerId); console.log('[游戏结束] 是否显示弹窗:', !this.gameState.gameStarted && !!this.gameState.winnerId);
this.addLog('system', `战局结束:${this.gameState.winnerId === this.myUserId ? '🎉 您获得了胜利!' : '💀 很遗憾失败了'}`); //
let endMsg = '';
if (this.gameState.winnerId === 'draw') {
endMsg = '平局:无人幸存';
} else if (this.gameState.winnerId === this.myUserId) {
endMsg = '🎉 您获得了胜利!';
} else {
endMsg = '💀 很遗憾失败了';
}
this.addLog('system', `战局结束:${endMsg}`);
// //
if (this.gameState.winnerId === this.myUserId) { if (this.gameState.winnerId === this.myUserId) {
uni.vibrateShort({ type: 'success' }); uni.vibrateShort({ type: 'success' });
} else if (this.gameState.winnerId === 'draw') {
uni.vibrateShort({ type: 'warning' });
} else { } else {
uni.vibrateShort({ type: 'fail' }); uni.vibrateShort({ type: 'fail' });
} }
<<<<<<< HEAD
=======
let endMsg = '';
if (data.winnerId === 'draw') endMsg = '平局:无人幸存';
else endMsg = `战局结束:${data.winnerId === this.myUserId ? '您获得了胜利!' : '很遗憾失败了'}`;
this.addLog('system', endMsg);
>>>>>>> c028a29943b7b201a73114cb14a1109deb3af339
} }
}, },
handleEvent(event) { handleEvent(event) {
@ -812,6 +807,12 @@ export default {
if (!this.gameState || !this.gameState.players) return ''; if (!this.gameState || !this.gameState.players) return '';
const winnerId = this.gameState.winnerId; const winnerId = this.gameState.winnerId;
//
if (winnerId === 'draw') {
return '所有玩家都倒下了,本局为平局!';
}
const winner = this.gameState.players[winnerId]; const winner = this.gameState.players[winnerId];
const winnerName = winner ? (winner.username || '对手') : '未知'; const winnerName = winner ? (winner.username || '对手') : '未知';
@ -820,6 +821,30 @@ export default {
} else { } else {
return `${winnerName.substring(0, 10)} 获得了胜利,下次好运!`; return `${winnerName.substring(0, 10)} 获得了胜利,下次好运!`;
} }
},
//
getGameResultEmoji() {
if (!this.gameState || !this.gameState.winnerId) return '💀';
if (this.gameState.winnerId === 'draw') {
return '🤝';
} else if (this.gameState.winnerId === this.myUserId) {
return '🏆';
} else {
return '💀';
}
},
//
getGameResultTitle() {
if (!this.gameState || !this.gameState.winnerId) return '很遗憾失败了';
if (this.gameState.winnerId === 'draw') {
return '平局';
} else if (this.gameState.winnerId === this.myUserId) {
return '胜利!';
} else {
return '很遗憾失败了';
}
} }
} }
} }