寻宝:优化创建队伍时生成组队信息的逻辑
This commit is contained in:
@@ -5,19 +5,19 @@ import { difference } from 'underscore';
|
|||||||
* @Last Modified by: 梁桐川
|
* @Last Modified by: 梁桐川
|
||||||
* @Last Modified time: 2020-12-03 21:36:00
|
* @Last Modified time: 2020-12-03 21:36:00
|
||||||
*/
|
*/
|
||||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, QUALITY_TYPE } from './../../../consts';
|
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY } from './../../../consts';
|
||||||
import { getGoodById, getBossHpByBlueprtId, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId, comBtlRangeInfo, comBtlRangeByLv } from '../../../pubUtils/gamedata';
|
import { getGoodById, getBossHpByBlueprtId, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId, comBtlRangeByLv } from '../../../pubUtils/gamedata';
|
||||||
import { ComBattleTeamModel, BossHp, ComBattleTeamType } from '../../../db/ComBattleTeam';
|
import { ComBattleTeamModel, BossHp, ComBattleTeamType } from '../../../db/ComBattleTeam';
|
||||||
import Role, { RoleModel } from '../../../db/Role';
|
import Role, { RoleModel } from '../../../db/Role';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession } from 'pinus';
|
||||||
import { resResult, getRandomByLen, calculateNum, getRandValue, ratioReward, reduceCe, getRandValueByMinMax } from '../../../pubUtils/util';
|
import { resResult, getRandomByLen, reduceCe, getRandValueByMinMax } from '../../../pubUtils/util';
|
||||||
import { RoleStatus } from '../../../db/ComBattleTeam';
|
import { RoleStatus } from '../../../db/ComBattleTeam';
|
||||||
import { ItemModel } from '../../../db/Item';
|
import { ItemModel } from '../../../db/Item';
|
||||||
import { handleFixedReward, addItems, handleCost, decreaseItems } from '../../../services/rewardService';
|
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
|
||||||
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||||
import { transBossHpArr } from '../../../services/battleService';
|
import { transBossHpArr } from '../../../services/battleService';
|
||||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd } from '../../../services/comBattleService';
|
import { getRandBlueprtId, getRandComBtlRobots, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd, getValidTeammateRoleSt } from '../../../services/comBattleService';
|
||||||
import { setAp } from '../../../services/actionPointService';
|
import { setAp } from '../../../services/actionPointService';
|
||||||
import { roleLevelup } from '../../../services/normalBattleService';
|
import { roleLevelup } from '../../../services/normalBattleService';
|
||||||
import { FriendRelationModel } from '../../../db/FriendRelation';
|
import { FriendRelationModel } from '../../../db/FriendRelation';
|
||||||
@@ -125,28 +125,12 @@ export class ComBattleHandler {
|
|||||||
let teammates = await getTeamSearchByQuality(goodData.quality, comBtlRangeByLv(goodData.lvLimited));
|
let teammates = await getTeamSearchByQuality(goodData.quality, comBtlRangeByLv(goodData.lvLimited));
|
||||||
if (teammates) {
|
if (teammates) {
|
||||||
for (let teammate of teammates) {
|
for (let teammate of teammates) {
|
||||||
let roleInfo = await RoleModel.findByRoleId(teammate.roleId);
|
const { roleId: teammateRoleId } = teammate;
|
||||||
if (!roleInfo || roleIds.indexOf(teammate.roleId) !== -1) continue;
|
const st = getValidTeammateRoleSt(teammateRoleId, roleIds, ceLimit, goodData.quality);
|
||||||
let {roleId, roleName, headHid = 19, sHid = 19, topFiveCe, lv} = roleInfo;
|
if (!st) continue;
|
||||||
|
rmRoleFromQueue(teammateRoleId, sid, COM_BTL_QUALITY, null); // 匹配成功后删除redis中该用户的匹配记录
|
||||||
// 黑名单屏蔽
|
|
||||||
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;
|
|
||||||
|
|
||||||
rmRoleFromQueue(roleId, sid, COM_BTL_QUALITY, null); // 匹配成功后删除redis中该用户的匹配记录
|
|
||||||
|
|
||||||
let isFrd = await getFrd(roleId, goodData.quality);
|
|
||||||
const st = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
|
|
||||||
|
|
||||||
roleStatus.push(st);
|
roleStatus.push(st);
|
||||||
roleIds.push(roleInfo.roleId);
|
roleIds.push(teammateRoleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let { bossHpSum, bossHpArr } = getBossHpByBlueprtId(blueprtId);
|
let { bossHpSum, bossHpArr } = getBossHpByBlueprtId(blueprtId);
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { FriendRelationModel } from './../db/FriendRelation';
|
||||||
|
import { RoleModel, RoleType } from './../db/Role';
|
||||||
import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop';
|
import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop';
|
||||||
import { FriendPointModel } from './../db/FriendPoint';
|
import { FriendPointModel } from './../db/FriendPoint';
|
||||||
import { STATUS } from './../consts/statusCode';
|
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 { 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 { RoleStatus, ComBattleTeamModel } from './../db/ComBattleTeam';
|
||||||
import { getBluePrtByQuality, getComBtlSetByQuality, getRewardByBlueprtId, getWarById, getWarIdByBlueprtId, comBtlRangeInfo } from "../pubUtils/gamedata";
|
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 { getRandRobot } from "./battleService";
|
||||||
import { difference, omit } from 'underscore';
|
import { difference, omit } from 'underscore';
|
||||||
import { Channel } from 'pinus';
|
import { Channel } from 'pinus';
|
||||||
@@ -448,4 +450,51 @@ export async function getComBattleFriendAdd(roleStatus: RoleStatus[]) {
|
|||||||
hasAdd.push(roleIds);
|
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