修改了对对碰的前端操作逻辑,需要手动摸牌

This commit is contained in:
tsui110 2025-12-30 19:29:29 +08:00
parent a4dbfd14b7
commit ef4e4599f4
2 changed files with 142 additions and 15 deletions

View File

@ -14,7 +14,7 @@
<!-- 中奖标题 -->
<view class="title-area">
<view class="crown-icon">🎉</view>
<text class="main-title">恭喜中奖</text>
<text class="main-title">恭喜获得</text>
</view>
<!-- 奖品展示区 -->
@ -58,7 +58,7 @@
<view class="btn-glow"></view>
<view class="btn-inner">
<text class="btn-icon"></text>
<text class="btn-text">收下奖励</text>
<text class="btn-text">知道了</text>
</view>
</view>
</view>

View File

@ -94,13 +94,18 @@
<!-- 游戏信息 -->
<view class="game-stats glass-card">
<button class="game-btn-draw" @tap="manualDraw" :disabled="gameLoading || !canManualDraw">
<text>摸牌</text>
</button>
<view class="stat-item">
<text class="stat-label">总对数</text>
<text class="stat-value">{{ totalPairs }}</text>
</view>
<view class="stat-item">
<text class="stat-label">摸牌机会</text>
<text class="stat-value">{{ chance }}</text>
<text class="stat-label">{{ countdownSeconds > 0 ? '倒计时' : '摸牌机会' }}</text>
<text class="stat-value" :class="{ 'countdown': countdownSeconds > 0 }">
{{ countdownSeconds > 0 ? `${countdownSeconds}s` : chance }}
</text>
</view>
<view class="stat-item">
<text class="stat-label">牌组剩余</text>
@ -137,9 +142,6 @@
<!-- 底部操作栏 -->
<view class="game-actions">
<button class="game-btn btn-secondary" @tap="manualDraw" :disabled="gameLoading || !canManualDraw">
<text>摸牌</text>
</button>
<button class="game-btn btn-primary" @tap="advanceOne" :disabled="gameLoading">
<text>下一步</text>
</button>
@ -240,6 +242,8 @@ const chance = ref(0)
const totalPairs = ref(0)
const gameFinished = ref(false)
const pickedHandIndex = ref(-1)
const countdownTimer = ref(null)
const countdownSeconds = ref(0)
const gameIdText = computed(() => String((gameEntry.value && gameEntry.value.game_id) || ''))
const deckRemaining = computed(() => {
const entry = gameEntry.value || null
@ -738,7 +742,14 @@ async function openGame(latest) {
gameError.value = ''
await applyResumeEntry(gameEntry.value)
restoreOrInitLocalGame()
await autoDrawIfStuck()
// 0
if (Number(chance.value || 0) <= 0 && !canEliminateNow()) {
// 使 setTimeout ,
setTimeout(() => {
startCountdown()
}, 500)
}
}
function closeGame() {
@ -748,6 +759,44 @@ function closeGame() {
gameEntry.value = null
gameIssueId.value = ''
pickedHandIndex.value = -1
//
clearCountdown()
}
function startCountdown() {
//
clearCountdown()
countdownSeconds.value = 3
uni.showToast({
title: `摸牌次数已用完,${countdownSeconds.value}秒后结束游戏`,
icon: 'none',
duration: 1000
})
countdownTimer.value = setInterval(() => {
countdownSeconds.value -= 1
if (countdownSeconds.value > 0) {
uni.showToast({
title: `${countdownSeconds.value}秒后结束游戏`,
icon: 'none',
duration: 900
})
} else {
//
clearCountdown()
finishAndReport()
}
}, 1000)
}
function clearCountdown() {
if (countdownTimer.value) {
clearInterval(countdownTimer.value)
countdownTimer.value = null
}
countdownSeconds.value = 0
}
function getSelectedCodeFromEntry(entry) {
@ -918,6 +967,11 @@ function manualDraw() {
chance.value = Math.max(0, Number(chance.value || 0) - 1)
pickedHandIndex.value = -1
persistLocalGame()
// 0
if (Number(chance.value || 0) <= 0 && !canEliminateNow()) {
startCountdown()
}
}
async function autoDrawIfStuck() {
@ -977,7 +1031,13 @@ async function onCellTap(cell) {
chance.value = Number(chance.value || 0) + 1
pickedHandIndex.value = -1
persistLocalGame()
await autoDrawIfStuck()
// 0
if (!canEliminateNow() && Number(chance.value || 0) <= 0) {
startCountdown()
}
//
return
}
@ -1099,8 +1159,17 @@ async function advanceOne() {
return
}
//
//
if (!canEliminateNow()) {
await autoDrawIfStuck()
if (Number(chance.value || 0) > 0 && canDrawOne()) {
uni.showToast({ title: '请摸牌后再试', icon: 'none' })
} else if (Number(chance.value || 0) <= 0 && !canDrawOne()) {
// 0
if (!canEliminateNow()) {
await finishAndReport()
}
}
return
}
@ -2149,11 +2218,40 @@ onLoad((opts) => {
.game-stats {
display: flex;
justify-content: center;
gap: 48rpx;
align-items: center;
gap: 32rpx;
padding: 24rpx 32rpx;
margin: 0 32rpx;
}
.game-btn-draw {
flex-shrink: 0;
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.15);
border: 3rpx solid rgba(255, 255, 255, 0.3);
color: #FF6B6B;
font-size: 28rpx;
font-weight: 800;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(10rpx);
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.3);
transition: all 0.3s;
&:active {
transform: scale(0.9);
background: rgba(255, 255, 255, 0.25);
}
&[disabled] {
opacity: 0.3;
transform: none;
}
}
.stat-item {
display: flex;
flex-direction: column;
@ -2171,6 +2269,22 @@ onLoad((opts) => {
font-weight: 900;
color: $accent-gold;
font-family: 'DIN Alternate', sans-serif;
&.countdown {
color: #FF6B6B;
animation: pulse 1s ease-in-out infinite;
}
}
@keyframes pulse {
0%, 100% {
opacity: 1;
transform: scale(1);
}
50% {
opacity: 0.7;
transform: scale(1.1);
}
}
.game-content {
@ -2266,13 +2380,13 @@ onLoad((opts) => {
.game-actions {
display: flex;
gap: 24rpx;
justify-content: center;
padding: 32rpx;
padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
}
.game-btn {
flex: 1;
width: 400rpx;
height: 96rpx;
border-radius: 48rpx;
font-size: 32rpx;
@ -2282,11 +2396,24 @@ onLoad((opts) => {
justify-content: center;
border: none;
transition: all 0.3s;
color: #fff;
&.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.4);
}
&.btn-secondary {
background: rgba(255, 255, 255, 0.15);
border: 2rpx solid rgba(255, 255, 255, 0.3);
color: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10rpx);
}
&:active {
transform: scale(0.95);
}
&[disabled] {
opacity: 0.4;
}