From 60af138211b971f1157c8e0624384a04f9a6c9e8 Mon Sep 17 00:00:00 2001 From: ssttkkl Date: Mon, 19 Feb 2024 23:36:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9A=97=E6=9D=A0=E4=B9=9D?= =?UTF-8?q?=E8=8E=B2=E7=9A=84=E9=97=AE=E9=A2=98=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复暗杠九莲的问题 * 升级版本号 --- gradle.properties | 2 +- .../mahjongutils/yaku/CheckerFactory.kt | 2 +- .../kotlin/mahjongutils/yaku/TestYakuman.kt | 47 +++++++++++++++++-- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index d48079e..985769f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ kotlin.code.style=official group=io.github.ssttkkl -version=0.6.2 +version=0.6.3 org.gradle.jvmargs=-Xmx8g -Xms1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 diff --git a/mahjong-utils/src/commonMain/kotlin/mahjongutils/yaku/CheckerFactory.kt b/mahjong-utils/src/commonMain/kotlin/mahjongutils/yaku/CheckerFactory.kt index 1cc0617..9bb69e0 100644 --- a/mahjong-utils/src/commonMain/kotlin/mahjongutils/yaku/CheckerFactory.kt +++ b/mahjong-utils/src/commonMain/kotlin/mahjongutils/yaku/CheckerFactory.kt @@ -225,7 +225,7 @@ internal fun sushiSeriesCheckerFactory(windKotsuCount: Int, windJyantou: Boolean */ internal fun churenSeriesCheckerFactory(nineWaiting: Boolean): YakuChecker { return YakuChecker { pattern -> - if (pattern !is RegularHoraHandPattern) { + if (pattern !is RegularHoraHandPattern || pattern.furo.isNotEmpty()) { return@YakuChecker false } diff --git a/mahjong-utils/src/commonTest/kotlin/mahjongutils/yaku/TestYakuman.kt b/mahjong-utils/src/commonTest/kotlin/mahjongutils/yaku/TestYakuman.kt index 742f2de..21fe450 100644 --- a/mahjong-utils/src/commonTest/kotlin/mahjongutils/yaku/TestYakuman.kt +++ b/mahjong-utils/src/commonTest/kotlin/mahjongutils/yaku/TestYakuman.kt @@ -1,14 +1,11 @@ package mahjongutils.yaku -import mahjongutils.models.Furo -import mahjongutils.models.Mentsu -import mahjongutils.models.Tatsu -import mahjongutils.models.Tile import mahjongutils.hora.KokushiHoraHandPattern import mahjongutils.models.hand.RegularHandPattern import mahjongutils.hora.RegularHoraHandPattern -import mahjongutils.yaku.Yakus +import mahjongutils.models.* import kotlin.test.Test +import kotlin.test.assertFails internal class TestYakuman { @Test @@ -128,6 +125,46 @@ internal class TestYakuman { tester(pattern, setOf(Yakus.ChurenNineWaiting)) } + @Test + fun testChurenShouldFails() { + val pattern = RegularHoraHandPattern( + RegularHandPattern( + k = 4, + jyantou = Tile.get("8s"), + menzenMentsu = listOf(Mentsu("111s"), Mentsu("234s"), Mentsu("567s")), + furo = listOf(Furo("0990s")), + tatsu = emptyList(), + remaining = emptyList() + ), + agari = Tile.get("8s"), + agariTatsu = null, + tsumo = false + ) + val pattern2 = RegularHoraHandPattern( + RegularHandPattern( + k = 4, + jyantou = Tile.get("8s"), + menzenMentsu = listOf(Mentsu("111s"), Mentsu("234s"), Mentsu("567s")), + furo = listOf(Furo("0990s")), + tatsu = emptyList(), + remaining = emptyList() + ), + agari = Tile.get("7s"), + agariTatsu = Tatsu("56s"), + tsumo = false + ) + + assertFails { + tester(pattern, setOf(Yakus.Churen)) + tester(pattern, setOf(Yakus.ChurenNineWaiting)) + } + + assertFails { + tester(pattern2, setOf(Yakus.Churen)) + tester(pattern2, setOf(Yakus.ChurenNineWaiting)) + } + } + @Test fun testDaisushi_Tsuiso() { val pattern = RegularHoraHandPattern(