寻宝:抽象藏宝图数量判断方法

This commit is contained in:
liangtongchuan
2021-02-19 15:34:09 +08:00
parent a057da5c13
commit 9913bca97d
2 changed files with 16 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ import { ItemModel } from '../../../db/Item';
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
import { transBossHpArr } from '../../../services/battleService';
import { getRandBlueprtId, getRandComBtlRobots, clearComBtlTimer, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd, getValidTeammateRoleSt, teammateInBlackList, blueprtIdValid, createComTeamData } from '../../../services/comBattleService';
import { getRandBlueprtId, getRandComBtlRobots, clearComBtlTimer, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd, getValidTeammateRoleSt, teammateInBlackList, blueprtIdValid, createComTeamData, hasEnoughBlueprt } from '../../../services/comBattleService';
import { setAp } from '../../../services/actionPointService';
import { roleLevelup } from '../../../services/normalBattleService';
@@ -49,22 +49,16 @@ export class ComBattleHandler {
// 检查藏宝图Id是否合法
let goodData = getGoodById(blueprtId);
if (!blueprtIdValid(blueprtId)) return resResult(STATUS.COM_BATTLE_BLUEPRT_INVALID);
const enoughBlueprt = await hasEnoughBlueprt(roleId, blueprtId);
if (!enoughBlueprt) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
// 检查藏宝图是否足够
let { lv, headHid = 19, topFiveCe = 100, sHid = 19 } = await RoleModel.findByRoleId(roleId);
topFiveCe = reduceCe(topFiveCe);
if (lv < COM_BTL_CONST.ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
if (!blueprt) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_FOUND);
// 检查是否有已创建未结束的寻宝,预先占用一张藏宝图
let teams = await ComBattleTeamModel.getTeamByCapAndStatus(roleId, COM_TEAM_STATUS.FIGHTING);
if (teams && blueprt.count <= teams.length) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
let roleStatus = [];
let roleIds = [];
roleIds.push(roleId);
topFiveCe = reduceCe(topFiveCe);
let capStatus = new RoleStatus(roleId, roleName, true, false, headHid, sHid, topFiveCe, lv);
roleStatus.push(capStatus);