Skip to content

Commit

Permalink
赛季切换相关(close #245)
Browse files Browse the repository at this point in the history
* 赛季切换时自动计算勋章

* 赛季切换时清空场次相关数据
  • Loading branch information
CuteReimu committed Sep 21, 2024
1 parent e8b11bb commit 0763c46
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
28 changes: 17 additions & 11 deletions src/main/kotlin/ScoreFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ import kotlin.math.round
object ScoreFactory : Logging {
private val rankString = listOf("I", "II", "III", "IV", "V")

fun getRankNameByScore(score: Int): String {
return when {
score < 60 -> "\uD83E\uDD49" + rankString[2 - score / 20]
score < 240 -> "\uD83E\uDD48" + rankString[2 - (score - 60) / 60]
score < 360 -> "\uD83E\uDD47" + rankString[4 - (score - 240) / 60]
score < 600 -> "\uD83E\uDD47" + rankString[2 - (score - 360) / 80]
score < 1000 -> "\uD83D\uDC8D" + rankString[4 - (score - 600) / 80]
score < 1500 -> "\uD83D\uDCA0" + rankString[4 - (score - 1000) / 100]
score < 2000 -> "\uD83D\uDC51" + rankString[4 - (score - 1500) / 100]
else -> "\uD83D\uDC51" + rankString[0]
}
fun getRankNameByScore(score: Int): String = when {
score < 60 -> "\uD83E\uDD49" + rankString[2 - score / 20]
score < 240 -> "\uD83E\uDD48" + rankString[2 - (score - 60) / 60]
score < 360 -> "\uD83E\uDD47" + rankString[4 - (score - 240) / 60]
score < 600 -> "\uD83E\uDD47" + rankString[2 - (score - 360) / 80]
score < 1000 -> "\uD83D\uDC8D" + rankString[4 - (score - 600) / 80]
score < 1500 -> "\uD83D\uDCA0" + rankString[4 - (score - 1000) / 100]
score < 2000 -> "\uD83D\uDC51" + rankString[4 - (score - 1500) / 100]
else -> "\uD83D\uDC51" + rankString[0]
}

fun getSeasonTitleByScore(score: Int): String = when {
score >= 1900 -> "\uD83D\uDC51"
score >= 1400 -> "\uD83D\uDCA0"
score >= 920 -> "\uD83D\uDC8D"
score >= 520 -> "\uD83E\uDD47"
else -> ""
}

fun getRankStringNameByScore(score: Int): String {
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/Statistics.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fengsheng

import com.fengsheng.ScoreFactory.addScore
import com.fengsheng.ScoreFactory.getSeasonTitleByScore
import com.fengsheng.protos.Common.*
import com.fengsheng.protos.Common.color.*
import com.fengsheng.protos.Common.secret_task.*
Expand Down Expand Up @@ -316,10 +317,16 @@ object Statistics {
v.copy(
winCount = 0,
gameCount = 0,
title = "",
title = v.title + getSeasonTitleByScore(v.score),
score = v.score / 2,
energy = v.energy.coerceAtLeast(10),
maxScore = v.score / 2
maxScore = v.score / 2,
rbWinCount = 0,
rbGameCount = 0,
blackWinCount = 0,
blackGameCount = 0,
blacksWinCount = emptyMap(),
blacksGameCount = emptyMap(),
)
}
}
Expand Down

0 comments on commit 0763c46

Please sign in to comment.