1
This commit is contained in:
parent
d625b7d9f7
commit
53ed83a0fb
@ -104,33 +104,32 @@ class Fragment {
|
||||
allocResult.set(PVP_TYPE, new Map());
|
||||
allocResult.set(PVE_TYPE, new Map());
|
||||
|
||||
const allocFunc = (list, node, num) => {
|
||||
const heros = [];
|
||||
{
|
||||
constant.ALL_HERO_FRAGMENT.forEach(
|
||||
(element) => {
|
||||
heros.push(
|
||||
{
|
||||
'item_id': element,
|
||||
'item_num': value.get(ITEM_PRE + element)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < heroNum; ++i) {
|
||||
const ret = utils.randItemByWeight(heros, 'item_num');
|
||||
if (ret.index >= 0) {
|
||||
if (heros[ret.index]['item_num'] > 0) {
|
||||
--heros[ret.index]['item_num'];
|
||||
const item = allocNode.get(element);
|
||||
if (item) {
|
||||
item.set(element, 1);
|
||||
} else {
|
||||
item.set(element, item.get(element) + 1);
|
||||
}
|
||||
const allocFunc = (allocNode, list, data, num) => {
|
||||
const items = [];
|
||||
list.forEach(
|
||||
(element) => {
|
||||
items.push(
|
||||
{
|
||||
'item_id': element,
|
||||
'item_num': data.get(ITEM_PRE + element)
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
for (let i = 0; i < num; ++i) {
|
||||
const ret = utils.randItemByWeight(items, 'item_num');
|
||||
if (ret.index >= 0) {
|
||||
if (items[ret.index]['item_num'] > 0) {
|
||||
--items[ret.index]['item_num'];
|
||||
const item = allocNode.get(element);
|
||||
if (item) {
|
||||
item.set(element, 1);
|
||||
} else {
|
||||
item.set(element, item.get(element) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const remainData = this.getRemainData(daySeconds, nowTime, hourSeconds, allocedFragments);
|
||||
@ -140,8 +139,8 @@ class Fragment {
|
||||
const heroNum = Math.floor(remainData[key]['remainHeroNum'] / remainHour);
|
||||
const gunNum = Math.floor(remainData[key]['remainGunNum'] / remainHour);
|
||||
|
||||
allocFunc(constant.ALL_HERO_FRAGMENT, value, heroNum);
|
||||
allocFunc(constant.ALL_GUN_FRAGMENT, value, gunNum);
|
||||
allocFunc(allocNode, constant.ALL_HERO_FRAGMENT, value, heroNum);
|
||||
allocFunc(allocNode, constant.ALL_GUN_FRAGMENT, value, gunNum);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user