@rpg-engine/long-bow 0.8.118 → 0.8.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/long-bow.cjs.development.js +24 -21
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +24 -21
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +5 -8
- package/src/libs/itemCounter.ts +23 -15
package/dist/long-bow.esm.js
CHANGED
|
@@ -28845,20 +28845,26 @@ var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
|
|
|
28845
28845
|
}));
|
|
28846
28846
|
};
|
|
28847
28847
|
|
|
28848
|
-
var
|
|
28849
|
-
var
|
|
28850
|
-
if (inventory) {
|
|
28851
|
-
|
|
28852
|
-
var _inventory$slots$inde;
|
|
28853
|
-
var index = parseInt(i);
|
|
28854
|
-
if (((_inventory$slots$inde = inventory.slots[index]) == null ? void 0 : _inventory$slots$inde.key) === itemKey) {
|
|
28855
|
-
itemsFromInventory.push(inventory.slots[index]);
|
|
28856
|
-
}
|
|
28857
|
-
});
|
|
28848
|
+
var _countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
28849
|
+
var totalQty = 0;
|
|
28850
|
+
if (!inventory) {
|
|
28851
|
+
return totalQty;
|
|
28858
28852
|
}
|
|
28859
|
-
|
|
28860
|
-
|
|
28861
|
-
|
|
28853
|
+
Object.keys(inventory.slots).forEach(function (i) {
|
|
28854
|
+
var index = parseInt(i);
|
|
28855
|
+
var item = inventory.slots[index];
|
|
28856
|
+
if (!item) {
|
|
28857
|
+
return;
|
|
28858
|
+
}
|
|
28859
|
+
// Count matching items
|
|
28860
|
+
if (item.key === itemKey) {
|
|
28861
|
+
totalQty += item.stackQty || 1;
|
|
28862
|
+
}
|
|
28863
|
+
// Recursively check nested containers
|
|
28864
|
+
if (item.isItemContainer && item.itemContainer && typeof item.itemContainer !== "string") {
|
|
28865
|
+
totalQty += _countItemFromInventory(itemKey, item.itemContainer);
|
|
28866
|
+
}
|
|
28867
|
+
});
|
|
28862
28868
|
return totalQty;
|
|
28863
28869
|
};
|
|
28864
28870
|
|
|
@@ -28958,7 +28964,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28958
28964
|
}, React.createElement(TooltipTitle, null, "Skill Requirements"), React.createElement(MinCraftingRequirementsText, {
|
|
28959
28965
|
levelIsOk: levelIsOk
|
|
28960
28966
|
}, modifyString("" + ((_recipe$minCraftingRe3 = recipe == null ? void 0 : (_recipe$minCraftingRe4 = recipe.minCraftingRequirements) == null ? void 0 : _recipe$minCraftingRe4[0]) != null ? _recipe$minCraftingRe3 : '')), " lvl", ' ', (_recipe$minCraftingRe5 = recipe == null ? void 0 : (_recipe$minCraftingRe6 = recipe.minCraftingRequirements) == null ? void 0 : _recipe$minCraftingRe6[1]) != null ? _recipe$minCraftingRe5 : 0, " (", levelInSkill, ")"), React.createElement(TooltipTitle, null, "Ingredients"), recipe.ingredients.map(function (ingredient, index) {
|
|
28961
|
-
var itemQtyInInventory = !inventory ? 0 :
|
|
28967
|
+
var itemQtyInInventory = !inventory ? 0 : _countItemFromInventory(ingredient.key, inventory);
|
|
28962
28968
|
var isQuantityOk = ingredient.qty <= itemQtyInInventory;
|
|
28963
28969
|
return React.createElement(Recipe, {
|
|
28964
28970
|
key: index
|
|
@@ -29108,14 +29114,11 @@ function calculateMaxCraftable(recipe, inventory) {
|
|
|
29108
29114
|
return 0;
|
|
29109
29115
|
}
|
|
29110
29116
|
return (_recipe$ingredients$r = recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
29111
|
-
var
|
|
29112
|
-
|
|
29113
|
-
return (item == null ? void 0 : item.key) === ingredient.key;
|
|
29114
|
-
});
|
|
29115
|
-
if (!inventoryItem) {
|
|
29117
|
+
var totalQty = _countItemFromInventory(ingredient.key, inventory);
|
|
29118
|
+
if (totalQty === 0) {
|
|
29116
29119
|
return 0;
|
|
29117
29120
|
}
|
|
29118
|
-
var possibleWithThisIngredient = Math.floor(
|
|
29121
|
+
var possibleWithThisIngredient = Math.floor(totalQty / ingredient.qty);
|
|
29119
29122
|
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
29120
29123
|
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
29121
29124
|
}
|
|
@@ -36422,7 +36425,7 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36422
36425
|
}
|
|
36423
36426
|
});
|
|
36424
36427
|
}
|
|
36425
|
-
var totalQty = _payload && inventory ?
|
|
36428
|
+
var totalQty = _payload && inventory ? _countItemFromInventory(_payload.key, inventory) : 0;
|
|
36426
36429
|
return React.createElement(StyledShortcut$1, {
|
|
36427
36430
|
key: i,
|
|
36428
36431
|
onPointerDown: handleShortcutCast.bind(null, i),
|