字典表更新,物品分类
This commit is contained in:
@@ -9,6 +9,7 @@ import Actor from './actor';
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
||||
const _ = require('underscore');
|
||||
|
||||
const moment = require('moment');
|
||||
|
||||
@@ -502,4 +503,17 @@ export function parseNumberList(str: string) {
|
||||
res.push(parseInt(g));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function mergeSameGoods(goods: Array<{id: number, count: number}>) {
|
||||
let resGoods = [];
|
||||
for (let {id, count} of goods) {
|
||||
let index = _.findIndex(resGoods, {id});
|
||||
if (index > -1) {
|
||||
resGoods[index].count += count;
|
||||
} else {
|
||||
resGoods.push({id, count});
|
||||
}
|
||||
}
|
||||
return resGoods;
|
||||
}
|
||||
Reference in New Issue
Block a user