整理代码结构,使用service
This commit is contained in:
@@ -3,11 +3,12 @@ import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { getWarById, } from '../../../util/gamedata';
|
||||
import { genCode } from '../../../util/util';
|
||||
import { getAp, setAp, WarReward } from './battleUtils';
|
||||
import { WAR_TYPE, EVENT_START_BATTLE } from '../../../consts/consts';
|
||||
import { checkDaily, checkDailyAndIncrease } from './dailyBattleHandler';
|
||||
import { setBattleStatus, startEvent } from './eventBattleHandler';
|
||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { setBattleStatus, startEvent } from '../../../services/eventSercive';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new NormalBattleHandler(app);
|
||||
@@ -160,16 +161,8 @@ export class NormalBattleHandler {
|
||||
}
|
||||
|
||||
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
|
||||
let params = {};
|
||||
if(isSuccess) { // 挑战胜利
|
||||
params = {
|
||||
$set: {
|
||||
status: 1,
|
||||
star,
|
||||
record: { heroes }
|
||||
}
|
||||
}
|
||||
|
||||
if(isSuccess) { // 挑战胜利
|
||||
// 是否首通
|
||||
let condition1 = await BattleRecordModel.getBattleRecordByIdAndStatus(roleId, battleId, 1);
|
||||
if(!condition1) warReward.setCondition(0, true);
|
||||
@@ -178,19 +171,13 @@ export class NormalBattleHandler {
|
||||
let condition2 = await BattleRecordModel.getBattleRecordByIdAndStar(roleId, battleId, 3);
|
||||
if(!condition2) warReward.setCondition(1, true);
|
||||
}
|
||||
|
||||
} else { // 挑战失败
|
||||
params = {
|
||||
$set: {
|
||||
status: 2,
|
||||
record: { heroes }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
const updateResult = await BattleRecordModel.updateBattleRecordByCode(battleCode, params, true);
|
||||
const updateResult = await BattleRecordModel.updateBattleRecordByCode(battleCode, {
|
||||
$set: { status: isSuccess?1:2, star, record: { heroes } }
|
||||
}, true);
|
||||
let { status } = updateResult;
|
||||
|
||||
// 主线关卡某个关卡触发事件开启
|
||||
|
||||
Reference in New Issue
Block a user