远征添加战场前校验和战后掉落
This commit is contained in:
@@ -13,6 +13,7 @@ import { handleFixedReward } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ExpeditionBattleHandler(app);
|
||||
@@ -137,6 +138,9 @@ export class ExpeditionBattleHandler {
|
||||
if(!preBattle) return resResult(STATUS.BATTLE_NEED_PREVIOUS_GK);
|
||||
}
|
||||
|
||||
let checkHeroes = checkBattleHeroes(roleId, heroes);
|
||||
if(!checkHeroes) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
|
||||
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
|
||||
if(!expeditionWarRecord ) {
|
||||
return resResult(STATUS.EXPEDITION_MISS_WAR_RECORD);
|
||||
@@ -228,13 +232,16 @@ export class ExpeditionBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp)// 主公升级经验
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode, expeditionId,
|
||||
battleCode, battleId,
|
||||
battleStatus: expeditionWarRecord.battleStatus,
|
||||
...reward,
|
||||
apJson,
|
||||
expeditionPoint
|
||||
expeditionPoint,
|
||||
...actordata
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ export default class Hero extends BaseModel {
|
||||
{ $limit: num },
|
||||
{ $group: { _id: null, ce: { $sum: '$ce' } } }
|
||||
]);
|
||||
return ce[0].ce;
|
||||
return ce.length > 0?ce[0].ce:0;
|
||||
}
|
||||
|
||||
public static async sumHeroCe(roleId: string) {
|
||||
@@ -90,7 +90,7 @@ export default class Hero extends BaseModel {
|
||||
{ $match : { roleId } },
|
||||
{ $group: { _id: null, ce: { $sum: '$ce' } } }
|
||||
]);
|
||||
return ce[0].ce;
|
||||
return ce.length > 0?ce[0].ce:0;
|
||||
}
|
||||
|
||||
public static async deleteAccount(roleId: string, lean = true) {
|
||||
|
||||
Reference in New Issue
Block a user