寻宝:抽象藏宝图数量判断方法
This commit is contained in:
@@ -17,7 +17,7 @@ import { ItemModel } from '../../../db/Item';
|
|||||||
import { handleFixedReward, addItems, handleCost } 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, 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 { setAp } from '../../../services/actionPointService';
|
||||||
import { roleLevelup } from '../../../services/normalBattleService';
|
import { roleLevelup } from '../../../services/normalBattleService';
|
||||||
|
|
||||||
@@ -49,22 +49,16 @@ export class ComBattleHandler {
|
|||||||
// 检查藏宝图Id是否合法
|
// 检查藏宝图Id是否合法
|
||||||
let goodData = getGoodById(blueprtId);
|
let goodData = getGoodById(blueprtId);
|
||||||
if (!blueprtIdValid(blueprtId)) return resResult(STATUS.COM_BATTLE_BLUEPRT_INVALID);
|
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);
|
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);
|
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 roleStatus = [];
|
||||||
let roleIds = [];
|
let roleIds = [];
|
||||||
roleIds.push(roleId);
|
roleIds.push(roleId);
|
||||||
|
topFiveCe = reduceCe(topFiveCe);
|
||||||
let capStatus = new RoleStatus(roleId, roleName, true, false, headHid, sHid, topFiveCe, lv);
|
let capStatus = new RoleStatus(roleId, roleName, true, false, headHid, sHid, topFiveCe, lv);
|
||||||
roleStatus.push(capStatus);
|
roleStatus.push(capStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ItemModel } from './../db/Item';
|
||||||
import { IT_TYPE } from './../consts/consts';
|
import { IT_TYPE } from './../consts/consts';
|
||||||
import { COM_BTL_QUALITY } from './../consts/constModules/itemConst';
|
import { COM_BTL_QUALITY } from './../consts/constModules/itemConst';
|
||||||
import { FriendRelationModel } from './../db/FriendRelation';
|
import { FriendRelationModel } from './../db/FriendRelation';
|
||||||
@@ -99,7 +100,8 @@ export function checkComBattleResult(teamStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 计算寻宝结算-deprecated
|
* ! deprecated
|
||||||
|
* @description 计算寻宝结算
|
||||||
* @export
|
* @export
|
||||||
* @param {string} roleId
|
* @param {string} roleId
|
||||||
* @param {string} battleCode
|
* @param {string} battleCode
|
||||||
@@ -540,4 +542,13 @@ export function createComTeamData(teamCode: string, pub: boolean, blueprtId: num
|
|||||||
return {
|
return {
|
||||||
teamCode, pub, blueprtId, status, capId, ceLimit, bossHp, bossCurHp, quality, bossHpArr, curRnd, roleCnt, timeout, lvRange
|
teamCode, pub, blueprtId, status, capId, ceLimit, bossHp, bossCurHp, quality, bossHpArr, curRnd, roleCnt, timeout, lvRange
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function hasEnoughBlueprt(roleId: string, blueprtId: number) {
|
||||||
|
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
|
||||||
|
if (!blueprt) return false;
|
||||||
|
// 检查是否有已创建未结束的寻宝,预先占用一张藏宝图
|
||||||
|
let teams = await ComBattleTeamModel.getTeamByCapAndStatus(roleId, COM_TEAM_STATUS.FIGHTING);
|
||||||
|
if (teams && blueprt.count <= teams.length) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user