From 9c49d2b2d38dcdfddd0f6640042c0b2e3955dab6 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 19 Jan 2021 11:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=92=E9=98=9F=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/RankedLobbyRoom.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rooms/RankedLobbyRoom.ts b/src/rooms/RankedLobbyRoom.ts index 8b856f7..d2db1de 100644 --- a/src/rooms/RankedLobbyRoom.ts +++ b/src/rooms/RankedLobbyRoom.ts @@ -3,7 +3,7 @@ import {BaseConst} from "../constants/BaseConst"; interface MatchmakingGroup { averageRank: number; - clients: ClientStat[], + clients: ClientStat[]; priority?: boolean; ready?: boolean; @@ -20,6 +20,7 @@ interface ClientStat { group?: MatchmakingGroup; rank: number; confirmed?: boolean; + priority?: boolean; } export class RankedLobbyRoom extends Room { @@ -96,6 +97,10 @@ export class RankedLobbyRoom extends Room { client.leave(); } }) + this.onMessage('gogogo', (client: Client, message: any) => { + const stat = this.stats.find(obj => obj.clients.has(client.sessionId)); + stat.priority = true; + }) /** * Redistribute clients into groups at every interval @@ -231,6 +236,12 @@ export class RankedLobbyRoom extends Room { if (stat.group && stat.group.ready) { continue; } + if (currentGroup.count + stat.clients.size > this.maxClients) { + continue; + } + if (stat.priority) { + currentGroup.priority = true; + } /** * Force this client to join a group, even if rank is incompatible @@ -241,7 +252,6 @@ export class RankedLobbyRoom extends Room { // ) { // currentGroup.priority = true; // } - if ( currentGroup.averageRank > 0 && !currentGroup.priority @@ -319,7 +329,7 @@ export class RankedLobbyRoom extends Room { score: avaScore, count: this.numClientsToMatch - group.count }); - // TODO: 预处理数据, 确定座次 + // 预处理数据, 确定座次 let hasGroup = false; for (let client of group.clients) { if (client.clients.size > 1) {