寻宝:清理匹配成功的玩家信息;修复机器人和匹配条件等bug

This commit is contained in:
liangtongchuan
2020-12-01 21:12:09 +08:00
parent b55bfcbcbd
commit 15cf434d73
6 changed files with 42 additions and 17 deletions

View File

@@ -251,13 +251,15 @@ export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
if (cnt > source.length) return [];
if (cnt === source.length) return source;
let idxs = new Set();
for (let i = 0; i < cnt; ++i) {
while(1) {
let rand = Math.floor(Math.random() * source.length);
idxs.add(rand);
if (idxs.size == cnt) {
break;
}
}
return source.filter((_item, idx) => idxs.has(idx));
}