diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-09-07 23:36:44 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-09-08 00:39:01 +0200 |
commit | 9cb098df0ad5978b0e9aac78b4c68c9d16759f0f (patch) | |
tree | b7c4829c163a004a012a3da13183753fe4ee32e6 /sw-server/src/main/kotlin/org/luxons | |
parent | Use port 80 in docker image (diff) | |
download | seven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.tar.gz seven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.tar.bz2 seven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.zip |
Format with trailing comma
Diffstat (limited to 'sw-server/src/main/kotlin/org/luxons')
12 files changed, 21 insertions, 25 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt index 3958260c..aef121ee 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt @@ -6,8 +6,11 @@ import org.springframework.validation.ObjectError fun ObjectError.toDTO() = (this as? FieldError)?.fieldError() ?: objectError() -fun FieldError.fieldError(): ValidationErrorDTO = - ValidationErrorDTO("$objectName.$field", "Invalid value for field '$field': $defaultMessage", rejectedValue?.toString()) +fun FieldError.fieldError(): ValidationErrorDTO = ValidationErrorDTO( + path = "$objectName.$field", + message = "Invalid value for field '$field': $defaultMessage", + rejectedValue = rejectedValue?.toString(), +) fun ObjectError.objectError(): ValidationErrorDTO = ValidationErrorDTO(objectName, "Invalid value for object '$objectName': $defaultMessage") diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt index 61bcad89..12f346a2 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt @@ -14,8 +14,7 @@ fun Lobby.toDTO(): LobbyDTO = LobbyDTO( allWonders = allWonders, state = state, hasEnoughPlayers = hasEnoughPlayers(), - maxPlayersReached = maxPlayersReached() + maxPlayersReached = maxPlayersReached(), ) -private fun Player.toDTO(wonder: AssignedWonder) = - PlayerDTO(username, displayName, icon, wonder, isGameOwner, isReady) +private fun Player.toDTO(wonder: AssignedWonder) = PlayerDTO(username, displayName, icon, wonder, isGameOwner, isReady) diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt index 56b3400f..06b46d17 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt @@ -16,7 +16,7 @@ internal class AnonymousUsersHandshakeHandler : DefaultHandshakeHandler() { override fun determineUser( request: ServerHttpRequest, wsHandler: WebSocketHandler, - attributes: Map<String, Any> + attributes: Map<String, Any>, ): Principal? { var p = super.determineUser(request, wsHandler, attributes) if (p == null) { diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt index d8181f8a..d32fa0a6 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component @Component class TopicSubscriptionInterceptor( - private val destinationAccessValidator: DestinationAccessValidator + private val destinationAccessValidator: DestinationAccessValidator, ) : ChannelInterceptor { override fun preSend(message: Message<*>, channel: MessageChannel): Message<*>? { diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt index 1911f5b9..aad1c2ce 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt @@ -14,7 +14,7 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler @Configuration @EnableWebSocketMessageBroker class WebSocketConfig( - private val topicSubscriptionInterceptor: TopicSubscriptionInterceptor + private val topicSubscriptionInterceptor: TopicSubscriptionInterceptor, ) : WebSocketMessageBrokerConfigurer { override fun configureMessageBroker(config: MessageBrokerRegistry) { diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt index c3dcf87c..3236a6c9 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt @@ -27,7 +27,7 @@ class GameBrowserController( private val lobbyController: LobbyController, private val lobbyRepository: LobbyRepository, private val playerRepository: PlayerRepository, - private val template: SimpMessagingTemplate + private val template: SimpMessagingTemplate, ) { /** * Gets the created or updated games. The list of existing games is received on this topic at once upon diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt index c15f7a68..f3d8aaef 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt @@ -20,7 +20,7 @@ import java.security.Principal @Controller class GameController( private val template: SimpMessagingTemplate, - private val playerRepository: PlayerRepository + private val playerRepository: PlayerRepository, ) { private val Principal.player get() = playerRepository.find(name) diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt index 4a9fe0a2..c34756a8 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt @@ -18,7 +18,7 @@ import java.security.Principal @Api(name = "Home") @Controller class HomeController( - private val playerRepository: PlayerRepository + private val playerRepository: PlayerRepository, ) { /** diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt index 1c8cf17e..64e75a8f 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt @@ -31,8 +31,7 @@ class LobbyController( private val lobbyRepository: LobbyRepository, private val playerRepository: PlayerRepository, private val template: SimpMessagingTemplate, - @Value("\${server.port}") - private val serverPort: String + @Value("\${server.port}") private val serverPort: String, ) { private val Principal.player: Player get() = playerRepository.find(name) diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt index ed8add56..6ebe39c1 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt @@ -12,7 +12,7 @@ class Lobby( val id: Long, val name: String, var owner: Player, - private val gameDefinition: GameDefinition + private val gameDefinition: GameDefinition, ) { private val players: MutableList<Player> = ArrayList(gameDefinition.maxPlayers) @@ -49,8 +49,7 @@ class Lobby( assignedWonders.add(pickRandomWonder()) } - private fun pickRandomWonder(): AssignedWonder = - allWonders.filter { !it.isAssigned() }.random().withRandomSide() + private fun pickRandomWonder(): AssignedWonder = allWonders.filter { !it.isAssigned() }.random().withRandomSide() private fun PreGameWonder.isAssigned() = name in assignedWonders.map { it.name } @@ -122,11 +121,9 @@ class Lobby( state = State.FINISHED } - internal class GameAlreadyStartedException(name: String) : - IllegalStateException("Game '$name' has already started") + internal class GameAlreadyStartedException(name: String) : IllegalStateException("Game '$name' has already started") - internal class PlayerOverflowException(max: Int) : - IllegalStateException("Maximum $max players allowed") + internal class PlayerOverflowException(max: Int) : IllegalStateException("Maximum $max players allowed") internal class PlayerUnderflowException(min: Int) : IllegalStateException("Minimum $min players required to start a game") @@ -134,8 +131,7 @@ class Lobby( internal class PlayerNameAlreadyUsedException(displayName: String, gameName: String) : IllegalArgumentException("Name '$displayName' is already used by a player in game '$gameName'") - internal class UnknownPlayerException(username: String) : - IllegalArgumentException("Unknown player '$username'") + internal class UnknownPlayerException(username: String) : IllegalArgumentException("Unknown player '$username'") internal class PlayerListMismatchException(usernames: List<String>) : IllegalArgumentException("Newly ordered usernames $usernames don't match the current player list") diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt index 95b37643..94ae9742 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt @@ -7,7 +7,7 @@ import org.luxons.sevenwonders.server.ApiMisuseException class Player( val username: String, var displayName: String, - var icon: Icon? = null + var icon: Icon? = null, ) { var index: Int = -1 diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt index e76bdaea..c5dd6215 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt @@ -25,5 +25,4 @@ class PlayerRepository { fun remove(username: String): Player = players.remove(username) ?: throw PlayerNotFoundException(username) } -internal class PlayerNotFoundException(username: String) : - ApiMisuseException("Player '$username' doesn't exist") +internal class PlayerNotFoundException(username: String) : ApiMisuseException("Player '$username' doesn't exist") |