diff --git a/game-server/app/servers/battle/handler/normalBattleHandler.ts b/game-server/app/servers/battle/handler/normalBattleHandler.ts index d59fad12f..a179176f6 100644 --- a/game-server/app/servers/battle/handler/normalBattleHandler.ts +++ b/game-server/app/servers/battle/handler/normalBattleHandler.ts @@ -214,6 +214,9 @@ export class NormalBattleHandler { return towerEndResult.resResult; } towerStatus = towerEndResult.data.towerStatus; + + console.log('##### towerReward', JSON.stringify(towerEndResult.data.towerReward)); + if (towerEndResult.data.towerReward) warReward.setFixReward(towerEndResult.data.towerReward) } diff --git a/game-server/app/services/battleService.ts b/game-server/app/services/battleService.ts index 2a952e5f9..43f1b0732 100644 --- a/game-server/app/services/battleService.ts +++ b/game-server/app/services/battleService.ts @@ -233,7 +233,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb inc = wars.length == dicTower.warArray.length? 1: 0; } let newRec = await TowerRecordModel.updateRecord(roleId, towerLv, battleCode, battleId, heroes, inc); - let towerReward: RewardInter[] = null; + let towerReward: RewardInter[] = []; if (inc === 1) { let role = await RoleModel.towerLvUp(roleId); // 更新redis @@ -242,7 +242,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb await createNewTowerRecord(roleId, role.towerLv); const { reward } = gameData.tower.get(role.towerLv - 1); - if (reward) towerReward = reward; + if (reward) towerReward = [...reward]; await checkAndStartHungUp(roleId, roleName, role.towerLv); // 任务 await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, { towerLv: role.towerLv - 1 }); diff --git a/game-server/app/services/warRewardService.ts b/game-server/app/services/warRewardService.ts index f1d4ed489..a573f0906 100644 --- a/game-server/app/services/warRewardService.ts +++ b/game-server/app/services/warRewardService.ts @@ -37,9 +37,9 @@ export class WarReward { this.battleId = battleId; this.warInfo = gameData.war.get(battleId); let { fixReward, conditionReward, randomReward } = this.warInfo; - this.fixReward = fixReward; - this.conditionReward = conditionReward; - this.randomReward = randomReward; + this.setFixReward(fixReward); + this.setConditionReward(conditionReward); + this.setRandomReward(randomReward); } this.condition = new Map(); @@ -53,6 +53,7 @@ export class WarReward { public setFixReward(reward: RewardInter[]) { for(let r of reward) { + console.log('#####setFixReward', JSON.stringify(r)); this.fixReward.push(r); } } @@ -83,6 +84,7 @@ export class WarReward { if(!this.fixReward) return for(let i = 0; i < num; i++) { for(let obj of this.fixReward) { + console.log('##### handleFixReward', JSON.stringify(obj)); this.rewards.push({type: BATTLE_REWARD_TYPE.FIX_REWARD, times: i +1, ...obj, count: obj.count }); } } @@ -156,6 +158,7 @@ export class WarReward { if(combine) { rewards = combineItems(rewards); } + console.log('##### saveReward', JSON.stringify(rewards)) await addItems(this.roleId, this.roleName, this.sid, rewards, getReasonByWarType(this.warInfo.warType)); return rewards; }