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