全局:加载json方法全部改为最新

This commit is contained in:
luying
2021-05-06 20:25:05 +08:00
parent 2ef00e8179
commit 0315269387
36 changed files with 401 additions and 920 deletions
@@ -1,5 +1,4 @@
import { Application, BackendSession } from 'pinus';
import { getGamedata, getWarById, hasExpeditionById } from '../../../pubUtils/gamedata';
import { BattleRecordModel } from '../../../db/BattleRecord';
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
@@ -9,12 +8,13 @@ import { calculateSumCE, genCode } from '../../../pubUtils/util';
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies } from '../../../services/expeditionService';
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM, TASK_TYPE } from '../../../consts';
import { WarReward } from '../../../services/warRewardService';
import { handleFixedReward } from '../../../services/rewardService';
import { addItems } 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';
import { checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
import { gameData } from '../../../pubUtils/data';
export default function(app: Application) {
return new ExpeditionBattleHandler(app);
@@ -127,7 +127,7 @@ export class ExpeditionBattleHandler {
let { battleId, enemyFrom, enemies, battleStatus, ce: curCe } = curExpeditionWarRecord;
let nextCe = 0; // 下一关战力
if(hasExpeditionById(expeditionId + 1)) {
if(gameData.expedition.has(expeditionId + 1)) {
let nextExpeditionWarRecord = await findOrCreateEnemies(roleId, myCe, expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.HIDE);
if(nextExpeditionWarRecord) nextCe = nextExpeditionWarRecord.ce;
}
@@ -150,7 +150,7 @@ export class ExpeditionBattleHandler {
const { expeditionCode, expeditionId, battleId, heroes: seqIds = [] } = msg;
let roleId = session.get('roleId');
let roleName = session.get('roleName');
let warInfo = getWarById(battleId);
let warInfo = gameData.war.get(battleId);
if(!warInfo) {
return resResult(STATUS.BATTLE_MISS_INFO);
}
@@ -214,13 +214,10 @@ export class ExpeditionBattleHandler {
let sid = session.get('sid');
let funcs: number[] = session.get('funcs');
let warInfo = getWarById(battleId);
let warInfo = gameData.war.get(battleId);
if(!warInfo) {
return resResult(STATUS.BATTLE_MISS_INFO);
}
if(!warInfo.hasOwnProperty('cost')) {
warInfo['cost'] = 0;
}
const BattleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode);
if(!BattleRecord || BattleRecord.status != 0) {
@@ -297,8 +294,8 @@ export class ExpeditionBattleHandler {
let role = await RoleModel.findByRoleId(roleId);
let {expeditionPoint} = role;
let dicExpeditionPoint = getGamedata('dic_expedition_point');
let curDicExpeditionPoint = dicExpeditionPoint.find(cur => cur.point == point);
let dicExpeditionPoint = gameData.expeditionPoint;
let curDicExpeditionPoint = dicExpeditionPoint.get(point);
if(!curDicExpeditionPoint) {
return resResult(STATUS.EXPEDITION_MISS_POINT_INFO);
}
@@ -318,12 +315,12 @@ export class ExpeditionBattleHandler {
// 标记状态
let {rewards: resultRewards} = await ExpeditionPointModel.updatePointStatus(roleId, point, curDicExpeditionPoint.reward);
let hasReceivedAll = true, maxPoint = 0;
for(let dic of dicExpeditionPoint) {
let curReward = resultRewards.find(cur => cur.point == dic.point);
for(let [ point ] of dicExpeditionPoint) {
let curReward = resultRewards.find(cur => cur.point == point);
if(!curReward || !curReward.received) {
hasReceivedAll = false;
}
if(dic.point > maxPoint) maxPoint = dic.point;
if(point > maxPoint) maxPoint = point;
}
if(hasReceivedAll) { // 全部领取了,刷新
await ExpeditionPointModel.completeStatus(roleId);
@@ -334,7 +331,7 @@ export class ExpeditionBattleHandler {
// 任务
await checkTask(roleId, sid, funcs, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1, true, { point });
let goods = await handleFixedReward(roleId, roleName, sid, curDicExpeditionPoint.reward, 1);
let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward);
return resResult(STATUS.SUCCESS, {
costPoint: hasReceivedAll?maxPoint: 0,