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