commonMain.mahjongutils.hora.helpers.CalcHan.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mahjong-utils-jvm Show documentation
Show all versions of mahjong-utils-jvm Show documentation
Mahjong Utils (for Japanese Riichi Mahjong)
package mahjongutils.hora.helpers
import mahjongutils.hora.HoraHandPattern
import mahjongutils.hora.HoraOptions
import mahjongutils.yaku.Yaku
fun calcHan(
pattern: HoraHandPattern,
options: HoraOptions,
yaku: Set,
dora: Int
): Int {
val hasYakuman: Boolean = yaku.any { it.isYakuman }
var ans = 0
if (hasYakuman && !options.aotenjou && !options.hasComplexYakuman) {
ans = if (pattern.menzen) {
yaku.maxOf { it.han }
} else {
yaku.maxOf { it.han - it.furoLoss }
}
} else {
ans = if (pattern.menzen) {
yaku.sumOf { it.han }
} else {
yaku.sumOf { it.han - it.furoLoss }
}
if (options.aotenjou || !hasYakuman && ans > 0) {
ans += dora
}
}
return ans
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy