fix bug 远征关卡最后一关获取失败

This commit is contained in:
luying
2020-11-20 16:49:55 +08:00
parent b304dee798
commit d9e1bc2bcb
3 changed files with 10 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { Application, BackendSession } from 'pinus';
import { getGamedata, getWarById } from '../../../pubUtils/gamedata';
import { getGamedata, getWarById, hasExpeditionById } from '../../../pubUtils/gamedata';
import { BattleRecordModel } from '../../../db/BattleRecord';
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
@@ -125,8 +125,11 @@ export class ExpeditionBattleHandler {
}
let { battleId, enemyFrom, enemies, battleStatus, ce: curCe } = curExpeditionWarRecord;
let nextCe = 0; // 下一关战力
let nextExpeditionWarRecord = await findOrCreateEnemies(roleId, myCe, expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.HIDE);
if(nextExpeditionWarRecord) nextCe = nextExpeditionWarRecord.ce;
if(hasExpeditionById(expeditionId + 1)) {
let nextExpeditionWarRecord = await findOrCreateEnemies(roleId, myCe, expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.HIDE);
if(nextExpeditionWarRecord) nextCe = nextExpeditionWarRecord.ce;
}
return resResult(STATUS.SUCCESS, {
expeditionCode, expeditionId, battleId,

View File

@@ -8,7 +8,6 @@ import { decodeStr, resResult, setLocalHours, shouldRefresh } from '../pubUtils/
import { WAR_JSON_ATTRIBUTE_TYPE, EXPEDITION_CONST } from '../consts/consts';
import Actor from '../pubUtils/actor';
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
import { stat } from 'fs';
export async function findOrCreateEnemies(roleId: string, myCe: number, expeditionCode: string, expeditionId: number, battleStatus: number) {
@@ -46,7 +45,6 @@ export async function findOrCreateEnemies(roleId: string, myCe: number, expediti
let {enemiesCurHpAp, enemies} = expeditionWarRecord;
for(let enemy of enemies) {
let cur = {"hp": 0, "ap": 0};
console.log(enemiesCurHpAp)
let getHp = enemiesCurHpAp && enemiesCurHpAp.find(cur => cur.dataId == enemy.dataId);
if(getHp) {
cur.hp = getHp.hp;

View File

@@ -300,3 +300,7 @@ export function getOlySeidByType(type: number) {
export function getExpeditionById(id: number) {
return expeditionInfo.get(id);
}
export function hasExpeditionById(id: number) {
return expeditionInfo.has(id);
}