feat: 积分榜详情增加对手名和各自得分
This commit is contained in:
parent
800238df40
commit
145a432f7d
@ -66,7 +66,8 @@ data class ScoreEntry(
|
||||
val playerCount: Int,
|
||||
val turnNumber: Int,
|
||||
val date: Long,
|
||||
val scoreDetail: String? = ""
|
||||
val scoreDetail: String? = "",
|
||||
val opponentDetail: String? = ""
|
||||
)
|
||||
|
||||
object Scoreboard {
|
||||
@ -95,7 +96,8 @@ object Scoreboard {
|
||||
duration: Int,
|
||||
playerCount: Int,
|
||||
turnNumber: Int,
|
||||
scoreDetail: String = ""
|
||||
scoreDetail: String = "",
|
||||
opponentDetail: String = ""
|
||||
) {
|
||||
val scores = loadScores(context).toMutableList()
|
||||
scores.add(
|
||||
@ -108,7 +110,8 @@ object Scoreboard {
|
||||
playerCount = playerCount,
|
||||
turnNumber = turnNumber,
|
||||
date = System.currentTimeMillis(),
|
||||
scoreDetail = scoreDetail
|
||||
scoreDetail = scoreDetail,
|
||||
opponentDetail = opponentDetail
|
||||
)
|
||||
)
|
||||
saveScores(context, scores.sortedByDescending { it.points }.take(50))
|
||||
@ -201,6 +204,14 @@ fun LocalGameScreen(
|
||||
}
|
||||
}
|
||||
val detailStr = scoreDetails.joinToString(", ")
|
||||
// 对手名和各自总分
|
||||
val opponentDetails = state.players.filter { it.id != myPlayerId }.joinToString(";") { p ->
|
||||
val pScore = p.cards.sumOf { card ->
|
||||
val active = if (state.flipped && card.flipSide != null) card.flipSide else card
|
||||
active.score
|
||||
}
|
||||
"${p.name}:${pScore}分"
|
||||
}
|
||||
Scoreboard.addEntry(
|
||||
context = context,
|
||||
name = humanPlayerName,
|
||||
@ -210,7 +221,8 @@ fun LocalGameScreen(
|
||||
duration = gameDuration,
|
||||
playerCount = totalPlayers,
|
||||
turnNumber = gameTurnNumber,
|
||||
scoreDetail = detailStr
|
||||
scoreDetail = detailStr,
|
||||
opponentDetail = opponentDetails
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,6 +307,17 @@ fun ScoreboardScreen(onBack: () -> Unit) {
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text("难度: ${entry.difficulty} | ${entry.playerCount}人 | ${entry.turnNumber}轮",
|
||||
color = Color.White.copy(alpha = 0.5f), fontSize = 12.sp)
|
||||
// 对手得分
|
||||
val opps = (entry.opponentDetail ?: "").split(";").filter { it.isNotEmpty() }
|
||||
if (opps.isNotEmpty()) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text("对手得分", color = GoldAccent, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
opps.forEach { opp ->
|
||||
Text(opp, color = Color.White.copy(alpha = 0.7f), fontSize = 13.sp,
|
||||
modifier = Modifier.padding(vertical = 1.dp))
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
Text("分数明细", color = GoldAccent, fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user