Merge branch 'second' of http://git.kingsome.cn/node/card_svr into second
This commit is contained in:
commit
02a74035e3
@ -3,7 +3,7 @@ import {BaseConst} from "../constants/BaseConst";
|
|||||||
|
|
||||||
interface MatchmakingGroup {
|
interface MatchmakingGroup {
|
||||||
averageRank: number;
|
averageRank: number;
|
||||||
clients: ClientStat[],
|
clients: ClientStat[];
|
||||||
priority?: boolean;
|
priority?: boolean;
|
||||||
|
|
||||||
ready?: boolean;
|
ready?: boolean;
|
||||||
@ -20,6 +20,7 @@ interface ClientStat {
|
|||||||
group?: MatchmakingGroup;
|
group?: MatchmakingGroup;
|
||||||
rank: number;
|
rank: number;
|
||||||
confirmed?: boolean;
|
confirmed?: boolean;
|
||||||
|
priority?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RankedLobbyRoom extends Room {
|
export class RankedLobbyRoom extends Room {
|
||||||
@ -96,6 +97,10 @@ export class RankedLobbyRoom extends Room {
|
|||||||
client.leave();
|
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
|
* Redistribute clients into groups at every interval
|
||||||
@ -231,6 +236,12 @@ export class RankedLobbyRoom extends Room {
|
|||||||
if (stat.group && stat.group.ready) {
|
if (stat.group && stat.group.ready) {
|
||||||
continue;
|
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
|
* Force this client to join a group, even if rank is incompatible
|
||||||
@ -241,7 +252,6 @@ export class RankedLobbyRoom extends Room {
|
|||||||
// ) {
|
// ) {
|
||||||
// currentGroup.priority = true;
|
// currentGroup.priority = true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (
|
if (
|
||||||
currentGroup.averageRank > 0 &&
|
currentGroup.averageRank > 0 &&
|
||||||
!currentGroup.priority
|
!currentGroup.priority
|
||||||
@ -272,7 +282,8 @@ export class RankedLobbyRoom extends Room {
|
|||||||
* Match long-waiting clients with bots
|
* Match long-waiting clients with bots
|
||||||
* FIXME: peers of this group may be entered short ago
|
* 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.ready = true;
|
||||||
currentGroup = this.createGroup();
|
currentGroup = this.createGroup();
|
||||||
@ -319,7 +330,7 @@ export class RankedLobbyRoom extends Room {
|
|||||||
score: avaScore,
|
score: avaScore,
|
||||||
count: this.numClientsToMatch - group.count
|
count: this.numClientsToMatch - group.count
|
||||||
});
|
});
|
||||||
// TODO: 预处理数据, 确定座次
|
// 预处理数据, 确定座次
|
||||||
let hasGroup = false;
|
let hasGroup = false;
|
||||||
for (let client of group.clients) {
|
for (let client of group.clients) {
|
||||||
if (client.clients.size > 1) {
|
if (client.clients.size > 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user