fix: 选中上浮改为1/3牌高、非回合可点击查看手牌、清除选中防错位误上浮
This commit is contained in:
parent
536fbb4918
commit
347e01b5ee
@ -65,7 +65,7 @@ private fun ClassicCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 8.dp else 2.dp, RoundedCornerShape(10.dp))
|
||||
.clip(RoundedCornerShape(10.dp))
|
||||
.background(
|
||||
@ -89,7 +89,7 @@ private fun ElegantCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 8.dp else 3.dp, RoundedCornerShape(14.dp))
|
||||
.clip(RoundedCornerShape(14.dp))
|
||||
.background(Color.White)
|
||||
@ -129,7 +129,7 @@ private fun MidnightCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 12.dp else 4.dp, RoundedCornerShape(12.dp), ambientColor = glow, spotColor = glow)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(DarkCard)
|
||||
@ -160,7 +160,7 @@ private fun NeonCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 10.dp else 4.dp, RoundedCornerShape(8.dp), ambientColor = neonColor, spotColor = neonColor)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(Color(0xFF0A0A0A))
|
||||
@ -188,7 +188,7 @@ private fun PastelCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 6.dp else 2.dp, RoundedCornerShape(16.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(
|
||||
@ -224,7 +224,7 @@ private fun ForestCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 6.dp else 2.dp, RoundedCornerShape(6.dp))
|
||||
.clip(RoundedCornerShape(6.dp))
|
||||
.background(
|
||||
@ -249,7 +249,7 @@ private fun OceanCard(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.width(60.dp).height(90.dp)
|
||||
.then(if (selected) Modifier.offset(y = (-10).dp) else Modifier)
|
||||
.then(if (selected) Modifier.offset(y = (-30).dp) else Modifier)
|
||||
.shadow(if (selected) 6.dp else 3.dp, RoundedCornerShape(10.dp))
|
||||
.clip(RoundedCornerShape(10.dp))
|
||||
.background(
|
||||
|
||||
@ -49,6 +49,11 @@ fun GameScreen(
|
||||
val currentPlayer = gameState.currentPlayer
|
||||
val sortedCards = myCards.sortedWith(compareBy({ it.color.ordinal }, { it.number }, { it.type.ordinal }))
|
||||
|
||||
// 手牌变化后清除选中状态,避免位置错位导致的误上浮
|
||||
LaunchedEffect(myCards.size, gameState.turnNumber) {
|
||||
selectedCardIndex = -1
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@ -299,16 +304,21 @@ fun GameScreen(
|
||||
topCard = topCard,
|
||||
currentWildColor = gameState.currentWildColor,
|
||||
onCardClick = { index ->
|
||||
if (!isMyTurn) return@PlayerHand
|
||||
val realCard = sortedCards[index]
|
||||
if (realCard.type.isWild) {
|
||||
selectedAutoCard = sortedCards.indexOf(realCard)
|
||||
showColorPicker = true
|
||||
} else if (isSevenZeroMode && realCard.type == CardType.NUMBER && realCard.number == 7 && gameState.players.size > 2) {
|
||||
onPlaySeven(myCards.indexOf(realCard))
|
||||
if (isMyTurn) {
|
||||
// 我的回合:打出牌
|
||||
if (realCard.type.isWild) {
|
||||
selectedAutoCard = sortedCards.indexOf(realCard)
|
||||
showColorPicker = true
|
||||
} else if (isSevenZeroMode && realCard.type == CardType.NUMBER && realCard.number == 7 && gameState.players.size > 2) {
|
||||
onPlaySeven(myCards.indexOf(realCard))
|
||||
} else {
|
||||
selectedCardIndex = index
|
||||
onPlayCard(myCards.indexOf(realCard))
|
||||
}
|
||||
} else {
|
||||
selectedCardIndex = index
|
||||
onPlayCard(myCards.indexOf(realCard))
|
||||
// 非我的回合:仅上浮查看,再次点击取消
|
||||
selectedCardIndex = if (selectedCardIndex == index) -1 else index
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user