From: TheSaminator Date: Sun, 20 Feb 2022 14:23:54 +0000 (-0500) Subject: Prevent lower-ranking admirals from joining larger battles X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=409306960dd606626af81927b3cb625e790f91f6;p=starship-fights Prevent lower-ranking admirals from joining larger battles --- diff --git a/src/jvmMain/kotlin/starshipfights/game/server_matchmaking.kt b/src/jvmMain/kotlin/starshipfights/game/server_matchmaking.kt index c3ecff8..a88aacb 100644 --- a/src/jvmMain/kotlin/starshipfights/game/server_matchmaking.kt +++ b/src/jvmMain/kotlin/starshipfights/game/server_matchmaking.kt @@ -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)