好友:寻宝关系加成及黑名单屏蔽
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);
|
||||
|
||||
@@ -10,6 +10,7 @@ import { difference, omit } from 'underscore';
|
||||
import { Channel } from 'pinus';
|
||||
import { TREASURE } from '../pubUtils/dicParam';
|
||||
import { decreaseItems } from './rewardService';
|
||||
import { getFriendLvAdd } from './friendService';
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
@@ -421,4 +422,22 @@ export function randEquipPrintId(warInfo) {
|
||||
return null;
|
||||
}
|
||||
return result.dic.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照好友关系,新增加成
|
||||
*
|
||||
* @param {RoleStatus} myRoleStatus 新增的队友
|
||||
* @param {RoleStatus[]} roleStatus 队伍内的所有队友
|
||||
*/
|
||||
export async function getComBattleFriendAdd(myRoleStatus: RoleStatus, roleStatus: RoleStatus[]) {
|
||||
let myAdd = 0; // 多好友,加成直接叠加
|
||||
for(let rs of roleStatus) {
|
||||
if(myRoleStatus.roleId == rs.roleId) continue;
|
||||
if(myRoleStatus.isRobot || rs.isRobot) continue;
|
||||
let add = await getFriendLvAdd(myRoleStatus.roleId, rs.roleId);
|
||||
rs.addFrdRatio(add);
|
||||
myAdd += add;
|
||||
}
|
||||
myRoleStatus.addFrdRatio(myAdd);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { RoleType, RoleModel } from "../db/Role";
|
||||
import { FriendRelationType, Relation } from "../db/FriendRelation";
|
||||
import { getResStr } from "../pubUtils/util";
|
||||
import { STATUS, FRIEND_RELATION_TYPE } from "../consts";
|
||||
import { FriendShipType } from "../db/FriendShip";
|
||||
import { FriendShipType, FriendShipModel } from "../db/FriendShip";
|
||||
import { outputCnt } from '../pubUtils/friendUtil';
|
||||
|
||||
/**
|
||||
@@ -87,4 +87,16 @@ function getSentHeart(roleId: string, relation: Relation) {
|
||||
beSentHeart: json.beSentHeart,
|
||||
beSentHeartTime: json.beSentHeartTime
|
||||
}
|
||||
}
|
||||
|
||||
export async function getFriendLvAdd(roleId: string, hisRoleId: string) {
|
||||
let friendShip = await FriendShipModel.getFriendLv(roleId, hisRoleId);
|
||||
if(!friendShip) {
|
||||
return 0
|
||||
}
|
||||
let dic = gameData.roleFriendLv.get(friendShip.friendLv);
|
||||
if(!dic) {
|
||||
return 0
|
||||
}
|
||||
return dic.comBattleAdd
|
||||
}
|
||||
Reference in New Issue
Block a user