Skip to content

Commit

Permalink
Give isFull into room domain
Browse files Browse the repository at this point in the history
  • Loading branch information
sudaidai committed May 28, 2023
1 parent acf1fea commit 8c2b642
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class JoinRoomUsecase(
if(!room.password.isNullOrEmpty() && !room.password.equals(request.password)){
throw WrongRoomPasswordException(room.password!!)
}
if (room.players.size >= room.maxPlayers) {
if (room.isFull()) {
throw JointRoomFullException("The room (${room.id}) is full. Please select another room or try again later.")
}
}
Expand Down
4 changes: 4 additions & 0 deletions domain/src/main/kotlin/tw/waterballsa/gaas/domain/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Room (
}
}

fun isFull(): Boolean {
return players.size >= maxPlayers
}

@JvmInline
value class Id(val value: String)

Expand Down

0 comments on commit 8c2b642

Please sign in to comment.