From aee478488aeb36b999c0c3dceed7420a9de77744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=91=A9=E3=81=AE=E7=81=B5=E6=A2=A6?= Date: Wed, 25 Sep 2024 23:45:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=97=E5=88=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF(fix=20#300)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/CountColors.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/CountColors.kt b/src/main/kotlin/CountColors.kt index e0c71104..04028557 100644 --- a/src/main/kotlin/CountColors.kt +++ b/src/main/kotlin/CountColors.kt @@ -26,13 +26,15 @@ class CountColors(cards: Iterable) { operator fun plusAssign(cards: Iterable) = cards.forEach { plusAssign(it.colors) } operator fun plusAssign(card: Card) = plusAssign(card.colors) - operator fun plusAssign(colors: List) = colors.forEach { + operator fun plusAssign(colors: List) { if (colors.any { c -> c != Black }) trueCard++ - when (it) { - Black -> black++ - Red -> red++ - Blue -> blue++ - else -> {} + colors.forEach { + when (it) { + Black -> black++ + Red -> red++ + Blue -> blue++ + else -> {} + } } }