27 lines
730 B
Kotlin
27 lines
730 B
Kotlin
package me.zobrist.tichucounter.domain
|
|
|
|
class Tichu {
|
|
|
|
fun calculateOtherScore(score: Int?): Int? {
|
|
if (score == null) {
|
|
return null
|
|
}
|
|
if (!score.isMultipleOf5()) {
|
|
return null
|
|
}
|
|
if (score.isMultipleOf100() && score != 0) {
|
|
return 0
|
|
}
|
|
if (score in 101..125) {
|
|
return 0 - (score % 100)
|
|
}
|
|
return 100 - (score % 100)
|
|
}
|
|
|
|
fun isValidRound(round: Round): Boolean {
|
|
if (round.scoreA == null || round.scoreB == null) {
|
|
return false
|
|
}
|
|
return (round.scoreA!!.isMultipleOf5()) && round.scoreB!!.isMultipleOf5() && (round.scoreA!! + round.scoreB!!).isMultipleOf100()
|
|
}
|
|
} |