寻宝助战匹配简单机器人
This commit is contained in:
18
game-server/app/services/comBattleService.ts
Normal file
18
game-server/app/services/comBattleService.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getBluePrtByQuality } from "../pubUtils/gamedata";
|
||||
import { getRandEelm } from "../pubUtils/util";
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
* @param qualityArr 品质数组,在所有给定品质的藏宝图中筛选1
|
||||
* @param cnt 返回藏宝图数量
|
||||
*/
|
||||
export async function getRandBlueprtId(qualityArr: Array<number>, cnt = 1) {
|
||||
if (!qualityArr || !qualityArr.length) return null;
|
||||
let blueprtIdArr = [];
|
||||
for (let q of qualityArr) {
|
||||
blueprtIdArr = blueprtIdArr.concat(getBluePrtByQuality(q));
|
||||
}
|
||||
if (blueprtIdArr.length === 0) return null;
|
||||
const res = getRandEelm(blueprtIdArr, cnt);
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user