From 0fc4c6ed713e390d58e1352e919a60967dd7d1e2 Mon Sep 17 00:00:00 2001 From: HoYeon Lee Date: Wed, 14 Aug 2024 23:02:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?DRAW-220=20fix:=20Draw=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=B9=84=EC=A0=95=EC=83=81=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=82=98=EC=98=A4=EB=8A=94=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xorker/draw/mafia/MafiaPhase.kt | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/domain/src/main/kotlin/com/xorker/draw/mafia/MafiaPhase.kt b/domain/src/main/kotlin/com/xorker/draw/mafia/MafiaPhase.kt index e307b2dd..5ab20eba 100644 --- a/domain/src/main/kotlin/com/xorker/draw/mafia/MafiaPhase.kt +++ b/domain/src/main/kotlin/com/xorker/draw/mafia/MafiaPhase.kt @@ -59,19 +59,32 @@ sealed class MafiaPhase { } fun getDraw(): List> { - return if (drawData.isEmpty()) { - emptyList() - } else { - drawData.take(drawData.size - 1).map { it.second } + if (drawData.isEmpty()) { + return emptyList() } + + val currentUser = turnList[turnInfo.turn] + + if (drawData.last().first == currentUser.userId) { + return drawData.take(drawData.size - 1).map { it.second } + } + + return drawData.map { it.second } } fun getCurrentDraw(): Map { - return if (drawData.isEmpty()) { - emptyMap() - } else { - drawData.last().second + if (drawData.isEmpty()) { + return emptyMap() } + + val currentUser = turnList[turnInfo.turn] + + val last = drawData.last() + if (last.first == currentUser.userId) { + return last.second + } + + return emptyMap() } } From 81fe0d6ee3ac429e3a869d0950e1b9bee654cfea Mon Sep 17 00:00:00 2001 From: HoYeon Lee Date: Wed, 14 Aug 2024 23:06:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?DRAW-220=20fix:=20=EB=B0=A9=EC=9E=A5=20?= =?UTF-8?q?=EC=83=89=20=EA=B3=A0=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/xorker/draw/mafia/MafiaGameRoomService.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/src/main/kotlin/com/xorker/draw/mafia/MafiaGameRoomService.kt b/core/src/main/kotlin/com/xorker/draw/mafia/MafiaGameRoomService.kt index a0040056..22d41446 100644 --- a/core/src/main/kotlin/com/xorker/draw/mafia/MafiaGameRoomService.kt +++ b/core/src/main/kotlin/com/xorker/draw/mafia/MafiaGameRoomService.kt @@ -83,10 +83,7 @@ internal class MafiaGameRoomService( } private fun generateColor(gameInfo: MafiaGameInfo?): String { - if (gameInfo == null) return COLOR_LIST.first() - - val alreadyUsedColors = - gameInfo.room.players.map { it.color }.toList() + val alreadyUsedColors = gameInfo?.room?.players?.map { it.color }?.toList() ?: emptyList() return COLOR_LIST .filterNot { alreadyUsedColors.contains(it) }