fix 修复联调时发现的bug

This commit is contained in:
luying
2020-10-27 16:50:16 +08:00
parent a74b659590
commit c25f95942c
5 changed files with 54 additions and 23 deletions
@@ -8,7 +8,7 @@ import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattle
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
import { WarReward } from '../../../services/warRewardService';
import { getAp, setAp } from '../../../services/actionPointService';
import { setBattleStatus } from '../../../services/eventSercive';
import { setBattleStatus, checkEventBattle } from '../../../services/eventSercive';
import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { HeroModel } from '../../../db/Hero';
@@ -53,6 +53,7 @@ export class NormalBattleHandler {
let checkHeroes = checkBattleHeroes(roleId, heroes);
if(!checkHeroes) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
const battleCode = genCode(8); // 关卡唯一值
let dailyNum = {};
let towerData = {};
if(warInfo.warType == WAR_TYPE.DAILY) {
@@ -63,12 +64,18 @@ export class NormalBattleHandler {
dailyNum = { type: checkResult.type, count: checkResult.count, sum: checkResult.sum };
} else if (warInfo.warType == WAR_TYPE.TOWER) {
let checkResult = await checkTowerWar(roleId, battleId, heroes);
if(checkResult.status) {
if(checkResult.status == -1) {
return checkResult.resResult
}
towerData = Object.assign(towerData, checkResult.data);
} else if (warInfo.warType == WAR_TYPE.EVENT) {
// 记录事件状态
let checkResult = await checkEventBattle( roleId, session.get('eventStatus'), battleId, battleCode);
if(checkResult.status == -1) {
return checkResult.resResult
}
}
const battleCode = genCode(8);
const BattleRecord = await BattleRecordModel.updateBattleRecordByCode(battleCode, {
$set: {
roleId, roleName, battleId,
@@ -204,6 +211,8 @@ export class NormalBattleHandler {
let condition2 = await BattleRecordModel.getBattleRecordByIdAndStar(roleId, battleId, 3);
if(!condition2) warReward.setCondition(1, true);
}
await updateWarStar(roleId, battleId, warInfo.warType, star);
}
let reward = await warReward.saveReward(1);
@@ -213,9 +222,7 @@ export class NormalBattleHandler {
}, true);
let { status } = updateResult;
await updateWarStar(roleId, battleId, warInfo.warType, star);
let actordata = await roleLevelup(roleId, warInfo.kingExp)// 主公升级经验
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0);// 主公升级经验
let curHeroes = [];
for(let hid of heroes) {