From 51753c3a13633e51e707547cbcc4e5935abddff6 Mon Sep 17 00:00:00 2001 From: Ted Date: Sun, 5 Nov 2023 11:25:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=93=9A=E7=AC=AC=E4=B8=80=E6=AC=A1co?= =?UTF-8?q?de=20review=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt | 4 ++-- .../gaas/spring/it/controllers/RoomControllerTest.kt | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt b/domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt index 95514e3c..69aa1b4c 100644 --- a/domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt +++ b/domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt @@ -51,7 +51,7 @@ class Room( throw PlatformException(GAME_NOT_STARTED, "Game has not started yet") } status = WAITING - playersCancelReady() + cancelReadyForNonHostPlayers() } fun hasPlayer(playerId: Player.Id): Boolean = @@ -94,7 +94,7 @@ class Room( private fun findPlayer(playerId: Player.Id): Player? = players.find { it.id == playerId } - private fun playersCancelReady() { + private fun cancelReadyForNonHostPlayers() { players.forEach { player -> if (!isHost(player.id)) { player.cancelReady() diff --git a/spring/src/test/kotlin/tw/waterballsa/gaas/spring/it/controllers/RoomControllerTest.kt b/spring/src/test/kotlin/tw/waterballsa/gaas/spring/it/controllers/RoomControllerTest.kt index cd6e1d7d..14f5d314 100644 --- a/spring/src/test/kotlin/tw/waterballsa/gaas/spring/it/controllers/RoomControllerTest.kt +++ b/spring/src/test/kotlin/tw/waterballsa/gaas/spring/it/controllers/RoomControllerTest.kt @@ -518,11 +518,9 @@ class RoomControllerTest @Autowired constructor( } private fun givenPlayersArePlayingInRoom(host: Player, vararg players: Player): Room { - val combinedPlayers = (listOf(host) + players).toMutableList() - players.forEach { player -> - player.ready() - } - testRoom = createRoom(host = host, players = combinedPlayers, status = PLAYING) + players.forEach { it.ready() } + val allPlayers = mutableListOf(host, *players) + testRoom = createRoom(host = host, players = allPlayers, status = PLAYING) return testRoom }