好友:寻宝关系加成及黑名单屏蔽
This commit is contained in:
@@ -7,7 +7,7 @@ import { difference } from 'underscore';
|
||||
*/
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, QUALITY_TYPE } from './../../../consts';
|
||||
import { getGoodById, getBossHpByBlueprtId, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId, comBtlRangeInfo, comBtlRangeByLv } from '../../../pubUtils/gamedata';
|
||||
import { ComBattleTeamModel, BossHp } from '../../../db/ComBattleTeam';
|
||||
import { ComBattleTeamModel, BossHp, ComBattleTeamType } from '../../../db/ComBattleTeam';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
@@ -17,9 +17,10 @@ import { ItemModel } from '../../../db/Item';
|
||||
import { handleFixedReward, addItems, handleCost, decreaseItems } from '../../../services/rewardService';
|
||||
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||
import { transBossHpArr } from '../../../services/battleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress } from '../../../services/comBattleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
import { roleLevelup } from '../../../services/normalBattleService';
|
||||
import { FriendRelationModel } from '../../../db/FriendRelation';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ComBattleHandler(app);
|
||||
@@ -127,11 +128,22 @@ export class ComBattleHandler {
|
||||
let roleInfo = await RoleModel.findByRoleId(teammate.roleId);
|
||||
if (!roleInfo || roleIds.indexOf(teammate.roleId) !== -1) continue;
|
||||
let {roleId, roleName, headHid = 19, sHid = 19, topFiveCe, lv} = roleInfo;
|
||||
|
||||
// 黑名单屏蔽
|
||||
let hasBlackList = false;
|
||||
for(let hisRoleId of roleIds) {
|
||||
let isInBlackList = await FriendRelationModel.isInBlackList(roleId, hisRoleId);
|
||||
if(isInBlackList) { hasBlackList = true; break; }
|
||||
}
|
||||
if(hasBlackList) continue;
|
||||
|
||||
topFiveCe = reduceCe(topFiveCe);
|
||||
if (topFiveCe < ceLimit) continue;
|
||||
|
||||
let isFrd = await getFrd(roleId, goodData.quality);
|
||||
const st = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
|
||||
await getComBattleFriendAdd(st, roleStatus);
|
||||
|
||||
roleStatus.push(st);
|
||||
roleIds.push(roleInfo.roleId);
|
||||
}
|
||||
@@ -215,7 +227,22 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
}
|
||||
|
||||
const team = await ComBattleTeamModel.getOtherTeamByQualityAndSt(roleId, qualityArr, COM_TEAM_STATUS.DEFAULT, lvRange, topFiveCe);
|
||||
const teams = await ComBattleTeamModel.getOtherTeamByQualityAndSt(roleId, qualityArr, COM_TEAM_STATUS.DEFAULT, lvRange, topFiveCe);
|
||||
let team: ComBattleTeamType;
|
||||
for(let curTeam of teams) {
|
||||
let { roleIds } = curTeam;
|
||||
|
||||
// 黑名单屏蔽
|
||||
let hasBlackList = false;
|
||||
for(let hisRoleId of roleIds) {
|
||||
let isInBlackList = await FriendRelationModel.isInBlackList(roleId, hisRoleId);
|
||||
if(isInBlackList) { hasBlackList = true; break; }
|
||||
}
|
||||
if(!hasBlackList) {
|
||||
team = curTeam; break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 有匹配的队伍还需要重新 joinTeam 加入,有失败可能,体验不好,需优化
|
||||
if (team && team.roleIds.length < 3 && team.status === COM_TEAM_STATUS.DEFAULT && team.roleIds.indexOf(roleId) === -1) {
|
||||
return resResult(STATUS.SUCCESS, {teamCode: team.teamCode});
|
||||
@@ -312,6 +339,13 @@ export class ComBattleHandler {
|
||||
if (!isFrd) {
|
||||
isFrd = await getFrd(roleId, quality);
|
||||
}
|
||||
|
||||
// 一般不会匹配到,手动邀请的可以加入
|
||||
// for(let hisRoleId of teamStatus.roleIds) {
|
||||
// let isInBlackList = await FriendRelationModel.isInBlackList(roleId, hisRoleId);
|
||||
// if(isInBlackList) return resResult(STATUS.COM_BATTLE_BLACKLIST);
|
||||
// }
|
||||
|
||||
// 加入队伍
|
||||
let roleStatus = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
|
||||
const team = await ComBattleTeamModel.addRole(teamCode, roleStatus);
|
||||
@@ -324,6 +358,10 @@ export class ComBattleHandler {
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
teamStatus.roleIds.push(roleId);
|
||||
teamStatus.roleStatus.push(roleStatus);
|
||||
|
||||
// 好友加成
|
||||
await getComBattleFriendAdd(roleStatus, teamStatus.roleStatus);
|
||||
|
||||
let users = channel.getMembers();
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
|
||||
Reference in New Issue
Block a user