diff --git a/game-server/app/services/role/util.ts b/game-server/app/services/role/util.ts index 8a5783e18..866fc5206 100644 --- a/game-server/app/services/role/util.ts +++ b/game-server/app/services/role/util.ts @@ -38,7 +38,7 @@ export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) { } } else if (table == ITEM_TABLE.ITEM) { // 可叠加道具 let index = items.findIndex(cur => cur.id == good.id); - if(index > 0) { + if(index >= 0) { items[index].count += good.count; } else { items.push({ id: good.id, count: good.count }); @@ -56,7 +56,7 @@ export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) { if(dicCurrency) { if(dicCurrency.type == CURRENCY_TYPE.GOLD) { // 金币,区分付费和免费,默认免费 let index = gold.findIndex(cur => cur.isPay == !!good.isPay); - if(index > 0) { + if(index >= 0) { gold[index].count += good.count; } else { gold.push({ count: good.count, isPay: !!good.isPay });