寻宝:优化创建队伍时生成组队信息的逻辑
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { FriendRelationModel } from './../db/FriendRelation';
|
||||
import { RoleModel, RoleType } from './../db/Role';
|
||||
import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop';
|
||||
import { FriendPointModel } from './../db/FriendPoint';
|
||||
import { STATUS } from './../consts/statusCode';
|
||||
import { COM_TEAM_STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, FRIEND_DROP_TYPE, COM_BTL_CONST, FRIEND_DROP_MAX } from './../consts';
|
||||
import { RoleStatus, ComBattleTeamModel } from './../db/ComBattleTeam';
|
||||
import { getBluePrtByQuality, getComBtlSetByQuality, getRewardByBlueprtId, getWarById, getWarIdByBlueprtId, comBtlRangeInfo } from "../pubUtils/gamedata";
|
||||
import { getRandEelm, getRandValue, resResult, ratioReward, getRandValueByMinMax, getRandomWithWeight, decodeStr, getRobotInfo } from "../pubUtils/util";
|
||||
import { getRandEelm, getRandValue, resResult, ratioReward, getRandValueByMinMax, getRandomWithWeight, decodeStr, getRobotInfo, reduceCe } from "../pubUtils/util";
|
||||
import { getRandRobot } from "./battleService";
|
||||
import { difference, omit } from 'underscore';
|
||||
import { Channel } from 'pinus';
|
||||
@@ -448,4 +450,51 @@ export async function getComBattleFriendAdd(roleStatus: RoleStatus[]) {
|
||||
hasAdd.push(roleIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 检查玩家是否符合加入队伍的条件
|
||||
* @param {Partial<RoleType>} roleInfo 要加入玩家的信息
|
||||
* @param {string} roleId 要加入玩家的 id
|
||||
* @param {Array<string>} roleIds 队伍中当前玩家列表
|
||||
* @param {number} ceLimit
|
||||
* @returns
|
||||
*/
|
||||
async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleIds: Array<string>, ceLimit: number) {
|
||||
if (!roleInfo || roleIds.indexOf(roleId) !== -1) 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;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 将用户信息转换成寻宝组队所需的 RoleStatus
|
||||
* @export
|
||||
* @param {string} roleId 要加入玩家的信息
|
||||
* @param {Array<string>} roleIds 队伍中当前玩家列表
|
||||
* @param {number} ceLimit
|
||||
* @param {number} quality
|
||||
* @returns
|
||||
*/
|
||||
export async function getValidTeammateRoleSt(roleId: string, roleIds: Array<string>, ceLimit: number, quality: number) {
|
||||
let roleInfo = await RoleModel.findByRoleId(roleId);
|
||||
let { roleName, headHid = 19, sHid = 19, topFiveCe, lv } = roleInfo;
|
||||
const valid = await teammateValid(roleInfo, roleId, roleIds, ceLimit);
|
||||
if (!valid) return null;
|
||||
|
||||
let isFrd = await getFrd(roleId, quality);
|
||||
const result = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user