Merge branch 'second' of http://git.kingsome.cn/node/card_svr into second

This commit is contained in:
yuexin 2021-01-19 13:40:42 +08:00
commit 02a74035e3

View File

@ -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
@ -272,7 +282,8 @@ export class RankedLobbyRoom extends Room {
* Match long-waiting clients with bots
* FIXME: peers of this group may be entered short ago
*/
(stat.waitingTime >= this.maxWaitingTime && this.allowUnmatchedGroups)
(stat.waitingTime >= this.maxWaitingTime && this.allowUnmatchedGroups) ||
stat.priority
) {
currentGroup.ready = true;
currentGroup = this.createGroup();
@ -319,7 +330,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) {