🐞 fix(名将擂台): 修复初次挑战对手失败时报错的问题

TypeError: Cannot destructure property 'battleGoods' of '(intermediate value)' as it is null
This commit is contained in:
luying
2022-10-24 11:00:13 +08:00
parent 91477a58a5
commit 687d096cdd
2 changed files with 3 additions and 2 deletions

View File

@@ -219,7 +219,8 @@ export class LadderHandler {
result.setLadderData(ladderData, rec); result.setLadderData(ladderData, rec);
// 获取奖励 // 获取奖励
let { battleGoods, breakGoods } = await ladderBattleEndReward(roleId, roleName, sid, ladderData.historyRank, isSuccess, historyRank, 1); let rewardResult = await ladderBattleEndReward(roleId, roleName, sid, ladderData.historyRank, isSuccess, historyRank, 1);
let { battleGoods = [], breakGoods = [] } = rewardResult||{};
await checkTaskInLadderEnd(serverId, roleId, sid, isSuccess, historyRank, atkLadderMatch.rank); await checkTaskInLadderEnd(serverId, roleId, sid, isSuccess, historyRank, atkLadderMatch.rank);
return resResult(STATUS.SUCCESS, {...pick(result, ['rank', 'historyRank', 'challengeCnt','status', 'time', 'oppPlayers']), battleGoods, breakGoods}); return resResult(STATUS.SUCCESS, {...pick(result, ['rank', 'historyRank', 'challengeCnt','status', 'time', 'oppPlayers']), battleGoods, breakGoods});

View File

@@ -344,7 +344,7 @@ async function refreshOpp(ladderMatch: LadderMatchType, needRefresh: boolean) {
export async function ladderBattleEndReward(roleId: string, roleName: string, sid: string, rank: number, isSuccess: boolean, historyRank: number, num: number) { export async function ladderBattleEndReward(roleId: string, roleName: string, sid: string, rank: number, isSuccess: boolean, historyRank: number, num: number) {
let dicLadderDifficultRatio = gameData.ladderDifficultRatio.get(rank); let dicLadderDifficultRatio = gameData.ladderDifficultRatio.get(rank);
if(!dicLadderDifficultRatio) return null; if(!dicLadderDifficultRatio) return { battleGoods: [], breakGoods: [] };
let warReward = new WarReward(roleId, roleName, sid, dicLadderDifficultRatio.gkId, isSuccess); let warReward = new WarReward(roleId, roleName, sid, dicLadderDifficultRatio.gkId, isSuccess);
warReward.setLadderReward(dicLadderDifficultRatio.randomWinReward, true); warReward.setLadderReward(dicLadderDifficultRatio.randomWinReward, true);
warReward.setLadderReward(dicLadderDifficultRatio.randomFailReward, false); warReward.setLadderReward(dicLadderDifficultRatio.randomFailReward, false);