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