@rpg-engine/long-bow 0.8.119 → 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 +1 -1
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +5 -8
- package/src/libs/itemCounter.ts +23 -15
|
@@ -28852,20 +28852,26 @@ var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
|
|
|
28852
28852
|
}));
|
|
28853
28853
|
};
|
|
28854
28854
|
|
|
28855
|
-
var
|
|
28856
|
-
var
|
|
28857
|
-
if (inventory) {
|
|
28858
|
-
|
|
28859
|
-
var _inventory$slots$inde;
|
|
28860
|
-
var index = parseInt(i);
|
|
28861
|
-
if (((_inventory$slots$inde = inventory.slots[index]) == null ? void 0 : _inventory$slots$inde.key) === itemKey) {
|
|
28862
|
-
itemsFromInventory.push(inventory.slots[index]);
|
|
28863
|
-
}
|
|
28864
|
-
});
|
|
28855
|
+
var _countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
28856
|
+
var totalQty = 0;
|
|
28857
|
+
if (!inventory) {
|
|
28858
|
+
return totalQty;
|
|
28865
28859
|
}
|
|
28866
|
-
|
|
28867
|
-
|
|
28868
|
-
|
|
28860
|
+
Object.keys(inventory.slots).forEach(function (i) {
|
|
28861
|
+
var index = parseInt(i);
|
|
28862
|
+
var item = inventory.slots[index];
|
|
28863
|
+
if (!item) {
|
|
28864
|
+
return;
|
|
28865
|
+
}
|
|
28866
|
+
// Count matching items
|
|
28867
|
+
if (item.key === itemKey) {
|
|
28868
|
+
totalQty += item.stackQty || 1;
|
|
28869
|
+
}
|
|
28870
|
+
// Recursively check nested containers
|
|
28871
|
+
if (item.isItemContainer && item.itemContainer && typeof item.itemContainer !== "string") {
|
|
28872
|
+
totalQty += _countItemFromInventory(itemKey, item.itemContainer);
|
|
28873
|
+
}
|
|
28874
|
+
});
|
|
28869
28875
|
return totalQty;
|
|
28870
28876
|
};
|
|
28871
28877
|
|
|
@@ -28965,7 +28971,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28965
28971
|
}, React__default.createElement(TooltipTitle, null, "Skill Requirements"), React__default.createElement(MinCraftingRequirementsText, {
|
|
28966
28972
|
levelIsOk: levelIsOk
|
|
28967
28973
|
}, 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__default.createElement(TooltipTitle, null, "Ingredients"), recipe.ingredients.map(function (ingredient, index) {
|
|
28968
|
-
var itemQtyInInventory = !inventory ? 0 :
|
|
28974
|
+
var itemQtyInInventory = !inventory ? 0 : _countItemFromInventory(ingredient.key, inventory);
|
|
28969
28975
|
var isQuantityOk = ingredient.qty <= itemQtyInInventory;
|
|
28970
28976
|
return React__default.createElement(Recipe, {
|
|
28971
28977
|
key: index
|
|
@@ -29115,14 +29121,11 @@ function calculateMaxCraftable(recipe, inventory) {
|
|
|
29115
29121
|
return 0;
|
|
29116
29122
|
}
|
|
29117
29123
|
return (_recipe$ingredients$r = recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
29118
|
-
var
|
|
29119
|
-
|
|
29120
|
-
return (item == null ? void 0 : item.key) === ingredient.key;
|
|
29121
|
-
});
|
|
29122
|
-
if (!inventoryItem) {
|
|
29124
|
+
var totalQty = _countItemFromInventory(ingredient.key, inventory);
|
|
29125
|
+
if (totalQty === 0) {
|
|
29123
29126
|
return 0;
|
|
29124
29127
|
}
|
|
29125
|
-
var possibleWithThisIngredient = Math.floor(
|
|
29128
|
+
var possibleWithThisIngredient = Math.floor(totalQty / ingredient.qty);
|
|
29126
29129
|
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
29127
29130
|
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
29128
29131
|
}
|
|
@@ -36425,7 +36428,7 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36425
36428
|
}
|
|
36426
36429
|
});
|
|
36427
36430
|
}
|
|
36428
|
-
var totalQty = _payload && inventory ?
|
|
36431
|
+
var totalQty = _payload && inventory ? _countItemFromInventory(_payload.key, inventory) : 0;
|
|
36429
36432
|
return React__default.createElement(StyledShortcut$1, {
|
|
36430
36433
|
key: i,
|
|
36431
36434
|
onPointerDown: handleShortcutCast.bind(null, i),
|