Skip to content

Commit

Permalink
根據第一次code review修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted committed Nov 5, 2023
1 parent d6c6b5b commit 51753c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 51753c3

Please sign in to comment.