Prevent lower-ranking admirals from joining larger battles
authorTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 20 Feb 2022 14:23:54 +0000 (09:23 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 20 Feb 2022 14:23:54 +0000 (09:23 -0500)
src/jvmMain/kotlin/starshipfights/game/server_matchmaking.kt

index c3ecff87229a3bf8f3ac993926c7dbf6668c239a..a88aacbef0f4b7d78e60fce154e233bec72e0aa4 100644 (file)
@@ -84,7 +84,9 @@ suspend fun DefaultWebSocketServerSession.matchmakingEndpoint(user: User): Boole
                        while (true) {
                                val openGames = openSessions.use {
                                        var index = 0
-                                       it.associateBy { "${++index}" }
+                                       it.filter { sess ->
+                                               sess.joinable.battleInfo.size <= inGameAdmiral.rank.maxBattleSize
+                                       }.associateBy { "${++index}" }
                                }
                                val joinListing = JoinListing(openGames.mapValues { (_, invitation) -> invitation.joinable })
                                sendObject(JoinListing.serializer(), joinListing)