道具使用:添加返回

This commit is contained in:
luying
2022-08-09 16:41:13 +08:00
parent ff5b28af7a
commit 5d9f59f4b3
3 changed files with 10 additions and 32 deletions

View File

@@ -9,6 +9,7 @@ import { decodeArrayListStr, resResult } from '../../pubUtils/util';
import { createHeroes } from '../role/createHero';
import { GuildModel } from '../../db/Guild';
import { pushGuildInfoUpdate } from '../guildService';
import { combineItems } from '../role/util';
@@ -22,7 +23,7 @@ import { pushGuildInfoUpdate } from '../guildService';
*/
export async function useGiftPackage(roleId: string, roleName: string, sid: string, serverId: number, guildCode: string, giftID: number, selected: Array<number> = [], giftCount: number) {
console.log("bbbbbbbb", giftID, selected)
let result = { goods: [], addHeros: [] }
let result: { goods: {id: number, count: number, seqId?: number, isBag?: boolean}[], addHeros: any[]} = { goods: [], addHeros: [] }
let giftPackageData = gameData.giftPackage.get(giftID);
if (!giftPackageData) {
return resResult(STATUS.SUCCESS, result);
@@ -105,17 +106,7 @@ export async function addReward(roleId: string, roleName: string, sid: string, s
addHeros = addHeros.concat(heroResult.heroes);
}
let newGoods: RewardInter[] = [];
for (let item of goods) {
let index = newGoods.findIndex(obj => { return obj.id == item.id });
if (index != -1) {
newGoods[index].count += item.count;
} else {
newGoods.push({ id: item.id, count: item.count })
}
}
return { goods: newGoods, addHeros }
return { goods: combineItems(goods), addHeros }
}
//表中的奖励数据(包括礼包)转换成具体对应奖励物品的实例