diff --git a/game-server/app/servers/battle/handler/normalBattleHandler.ts b/game-server/app/servers/battle/handler/normalBattleHandler.ts index afa7ad522..a72075e45 100644 --- a/game-server/app/servers/battle/handler/normalBattleHandler.ts +++ b/game-server/app/servers/battle/handler/normalBattleHandler.ts @@ -318,7 +318,7 @@ export class NormalBattleHandler { // 发奖励 let warReward = new WarReward(roleId, roleName, sid, battleId, true); - let result = await warReward.saveReward(count); + let result = await warReward.saveReward(count, true); let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp * count, session)// 主公升级经验 @@ -339,7 +339,7 @@ export class NormalBattleHandler { return resResult(STATUS.SUCCESS, { battleId, count, - battleGoods: result, + battleGoods: result, dailyNum, dungeonNum, ...actordata }); diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index 90392b140..984c765ef 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -293,6 +293,25 @@ export function combineItems(items: { id?: number, count?: number }[]) { return result; } +export function combineItemAndEquips(items: { id?: number, count?: number }[]) { + let result: { id: number, count: number }[] = []; + for(let { id, count = 1 } of items) { + let dicGoods = gameData.goods.get(id); + let dicItid = ITID.get(dicGoods.itid); + if(dicItid.table != 'equip') { + let index = result.findIndex(cur => cur.id == id); + if(index == -1) { + result.push({ id, count }); + } else { + result[index].count += count; + } + } else { + result.push({ id, count }); + } + } + return result; +} + function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) { let items: { id: number, count: number }[] = []; // 可叠加道具 let equips: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备 diff --git a/game-server/app/services/warRewardService.ts b/game-server/app/services/warRewardService.ts index 5739cc2b6..b95399edc 100644 --- a/game-server/app/services/warRewardService.ts +++ b/game-server/app/services/warRewardService.ts @@ -6,7 +6,7 @@ import { BattleDropModel } from '../db/BattleDrop'; import { getRandEelmWithWeight, getRandSingleEelm } from '../pubUtils/util'; import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts'; -import { addItems } from './rewardService'; +import { addItems, combineItemAndEquips } from './rewardService'; import { BattleBlueprtDropModel } from '../db/BattleBlueprtDrop' import { RoleModel } from '../db/Role'; import { gameData } from '../pubUtils/data'; @@ -22,7 +22,7 @@ export class WarReward { private condition: Map; private warInfo: DicWar; private isSuccess: boolean; - private rewards: Array<{type: number, id: number, count: number, times: number}>; + private rewards: Array<{type?: number, id: number, count: number, times?: number}>; private fixReward: Array<{id: number, count: number}>; private conditionReward: Array<{id: number, count: number, condition: number}>; private randomReward: Array<{id: number, count: number, frequency: number}>; @@ -169,7 +169,7 @@ export class WarReward { } } - public async saveReward(num: number) { + public async saveReward(num: number, combine: boolean = false) { this.rewards = new Array(); // let warType = this.warInfo.warType; @@ -179,10 +179,13 @@ export class WarReward { if(this.conditionReward) this.handleConditionReward(num, this.conditionReward); if(this.randomReward) await this.handleRandomReward(num, this.randomReward); - if(this.costAp > 0) await this.handlerBlueprtReward(num); + // if(this.costAp > 0) await this.handlerBlueprtReward(num); } - let rewards = this.rewards.sort((a, b) => a.times - b.times) + let rewards = this.rewards; + if(combine) { + rewards = combineItemAndEquips(rewards); + } await addItems(this.roleId, this.roleName, this.sid, rewards); return rewards; } diff --git a/shared/pubUtils/dictionary/DicWar.ts b/shared/pubUtils/dictionary/DicWar.ts index 868f088c0..86f6079dd 100644 --- a/shared/pubUtils/dictionary/DicWar.ts +++ b/shared/pubUtils/dictionary/DicWar.ts @@ -59,7 +59,7 @@ export function loadWar() { arr.forEach(o => { o.fixReward = parseFixReward(o.fixReward); o.conditionReward = parseConditionReward(o.conditionReward); - o.parseRandomReward = parseRandomReward(o.RandomReward||o.randomReward); + o.randomReward = parseRandomReward(o.RandomReward||o.randomReward); o.detailUIBg = parseDetailUIBg(o.detailUIBg); o.jackpotReward = parseJackpotReward(o.jackpotReward); o.teammateReward = parseFixReward(o.teammateReward);