From 9913bca97d41ffb9d7d5f1b177c71300bd5aad13 Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Fri, 19 Feb 2021 15:34:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E5=AE=9D=EF=BC=9A=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E8=97=8F=E5=AE=9D=E5=9B=BE=E6=95=B0=E9=87=8F=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/battle/handler/comBattleHandler.ts | 14 ++++---------- game-server/app/services/comBattleService.ts | 13 ++++++++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index 5a29a4d1c..bba152dca 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -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); diff --git a/game-server/app/services/comBattleService.ts b/game-server/app/services/comBattleService.ts index 7c26c2353..8ca08fb9e 100644 --- a/game-server/app/services/comBattleService.ts +++ b/game-server/app/services/comBattleService.ts @@ -1,3 +1,4 @@ +import { ItemModel } from './../db/Item'; import { IT_TYPE } from './../consts/consts'; import { COM_BTL_QUALITY } from './../consts/constModules/itemConst'; import { FriendRelationModel } from './../db/FriendRelation'; @@ -99,7 +100,8 @@ export function checkComBattleResult(teamStatus) { } /** - * @description 计算寻宝结算-deprecated + * ! deprecated + * @description 计算寻宝结算 * @export * @param {string} roleId * @param {string} battleCode @@ -540,4 +542,13 @@ export function createComTeamData(teamCode: string, pub: boolean, blueprtId: num return { 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; } \ No newline at end of file