寻宝:调整黑名单检查代码

This commit is contained in:
liangtongchuan
2021-02-18 20:32:36 +08:00
parent e04c02bd2a
commit c1c8ed49e1
2 changed files with 23 additions and 26 deletions
+18 -9
View File
@@ -463,16 +463,10 @@ export async function getComBattleFriendAdd(roleStatus: RoleStatus[]) {
async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleIds: Array<string>, ceLimit: number) {
if (!roleInfo || roleIds.indexOf(roleId) !== -1) return false;
const isBlack = await teammateInBlackList(roleId, roleIds);
if(isBlack) return false;
let { topFiveCe } = roleInfo;
// 黑名单屏蔽
let hasBlackList = false;
for(let hisRoleId of roleIds) {
let isInBlackList = await FriendRelationModel.isInBlackList(roleId, hisRoleId);
if(isInBlackList) { hasBlackList = true; break; }
}
if(hasBlackList) return false;
topFiveCe = reduceCe(topFiveCe);
if (topFiveCe < ceLimit) return false;
@@ -497,4 +491,19 @@ export async function getValidTeammateRoleSt(roleId: string, roleIds: Array<stri
let isFrd = await getFrd(roleId, quality);
const result = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
return result;
}
/**
* @description 检查队伍中是否有人互为黑名单
* @export
* @param {string} roleId 要加入队伍的玩家 id
* @param {Array<string>} roleIds 队伍中已有的玩家 id
* @returns
*/
export async function teammateInBlackList(roleId: string, roleIds: Array<string>) {
for(let teammateRoleId of roleIds) {
const isBlack = await FriendRelationModel.isInBlackList(roleId, teammateRoleId);
if (isBlack === true) return true;
}
return false;
}