From bacb59602a9a22796606624e4d5124a652786e63 Mon Sep 17 00:00:00 2001 From: zc_meng <161465879+zc-meng@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:55:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A5=9E=E7=A7=98=E4=BA=BA=E8=AF=95=E6=8E=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20(#282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 神秘人试探优化 * 优化代码 --------- Co-authored-by: 奇葩の灵梦 --- src/main/kotlin/card/ShiTan.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/kotlin/card/ShiTan.kt b/src/main/kotlin/card/ShiTan.kt index 561bb5ed..1ddd0651 100644 --- a/src/main/kotlin/card/ShiTan.kt +++ b/src/main/kotlin/card/ShiTan.kt @@ -253,6 +253,24 @@ class ShiTan : Card { } } + player.identity == Black -> { + // 按照和自己身份相同的情报数降序排列,然后按照手牌数升序排列 + val c1: Comparator = Comparator { p1, p2 -> + val p1MsgCount = p1!!.messageCards.count(p1.identity) + val p2MsgCount = p2!!.messageCards.count(p2.identity) + if (p1MsgCount != p2MsgCount) + return@Comparator p2MsgCount.compareTo(p1MsgCount) + p1.cards.size.compareTo(p2.cards.size) + } + val colors = listOf(Red, Blue).filter { it !in (card as ShiTan).whoDrawCard } + if (colors.isEmpty()) return false + else { + listOf(player.game!!.players.filter { + it!!.alive && it.identity in colors && it.cards.isNotEmpty() + }.minWithOrNull(c1)) + } + } + jianXianSheng != null && player.isPartner(jianXianSheng) -> listOf(jianXianSheng)