Commit b5d7f8ab authored by 's avatar

Added Timed gate.

parent 560db373
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
"timeInterval": 10000, "timeInterval": 10000,
"athleticTrueSkillGate": 0.4, "athleticTrueSkillGate": 0.4,
"entertainExpGate": 100, "entertainExpGate": 100,
"atheleticPtGate": 50 "atheleticPtGate": [350, 50, 500]
} }
} }
...@@ -42,6 +42,7 @@ let getUserConfig = function (user, callback) { ...@@ -42,6 +42,7 @@ let getUserConfig = function (user, callback) {
else { else {
try { try {
let value = JSON.parse(body); let value = JSON.parse(body);
setUserLimit(value);
callback(value); callback(value);
} }
catch (e) { catch (e) {
...@@ -58,6 +59,15 @@ let getUserConfig = function (user, callback) { ...@@ -58,6 +59,15 @@ let getUserConfig = function (user, callback) {
*/ */
}; };
let setUserLimit = function(data) {
if (Array.isArray(config.match.atheleticPtGate))
data.limit = config.match.atheleticPtGate[1];
else if (Number.isInteger(config.match.atheleticPtGate))
data.limit = config.match.atheleticPtGatmatche;
else
data.limit = 500;
};
// TrueSkill // TrueSkill
// 参考于 https://zh.wikipedia.org/zh-hans/TrueSkill评分系统 // 参考于 https://zh.wikipedia.org/zh-hans/TrueSkill评分系统
...@@ -127,7 +137,8 @@ updateAthleticMatch = function () { ...@@ -127,7 +137,8 @@ updateAthleticMatch = function () {
break; break;
} }
// 若 pt 之差小于门限,则匹配房间 // 若 pt 之差小于门限,则匹配房间
if (userA.data.pt - userB.data.pt < config.match.atheleticPtGate) { let delta = userA.data.pt - userB.data.pt;
if (delta < userA.data.limit && delta < userB.data.limit) {
pair(userA.client, userB.client, 'athletic'); pair(userA.client, userB.client, 'athletic');
i += 1; i += 1;
} }
...@@ -135,6 +146,9 @@ updateAthleticMatch = function () { ...@@ -135,6 +146,9 @@ updateAthleticMatch = function () {
else else
newPool.push(userA); newPool.push(userA);
} }
if (Array.isArray(config.match.atheleticPtGate))
for (let user of newPool)
user.data.limit = Math.min(user.data.limit + config.match.atheleticPtGate[1], config.match.atheleticPtGate[2])
athleticUserPool = newPool; athleticUserPool = newPool;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment