@rpg-engine/long-bow 0.7.89 → 0.7.90
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/components/CraftBook/CraftBook.d.ts +1 -1
- package/dist/components/CraftBook/utils/calculateMaxCraftable.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +25 -1
- 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 +25 -1
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +11 -2
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +30 -0
- package/src/stories/Features/craftbook/CraftBook.stories.tsx +6 -5
package/dist/long-bow.esm.js
CHANGED
|
@@ -28589,6 +28589,26 @@ var MinCraftingRequirementsText = /*#__PURE__*/styled.p.withConfig({
|
|
|
28589
28589
|
return levelIsOk ? uiColors.lightGreen : uiColors.lightGray;
|
|
28590
28590
|
});
|
|
28591
28591
|
|
|
28592
|
+
function calculateMaxCraftable(recipe, inventory) {
|
|
28593
|
+
if (!inventory || !(recipe != null && recipe.ingredients)) {
|
|
28594
|
+
return 0;
|
|
28595
|
+
}
|
|
28596
|
+
return recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
28597
|
+
var _inventoryItem$stackQ;
|
|
28598
|
+
var inventoryItem = Object.values(inventory.slots).find(function (item) {
|
|
28599
|
+
return (item == null ? void 0 : item.key) === ingredient.key;
|
|
28600
|
+
});
|
|
28601
|
+
if (!inventoryItem) {
|
|
28602
|
+
return 0;
|
|
28603
|
+
}
|
|
28604
|
+
var possibleWithThisIngredient = Math.floor((_inventoryItem$stackQ = inventoryItem.stackQty) != null ? _inventoryItem$stackQ : 0 / ingredient.qty);
|
|
28605
|
+
if (maxPossible === -1) {
|
|
28606
|
+
return possibleWithThisIngredient;
|
|
28607
|
+
}
|
|
28608
|
+
return Math.min(maxPossible, possibleWithThisIngredient);
|
|
28609
|
+
}, -1);
|
|
28610
|
+
}
|
|
28611
|
+
|
|
28592
28612
|
var desktop = {
|
|
28593
28613
|
width: 'min(900px, 80%)',
|
|
28594
28614
|
height: 'min(700px, 80%)'
|
|
@@ -28733,7 +28753,11 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28733
28753
|
buttonType: ButtonTypes.RPGUIButton,
|
|
28734
28754
|
onPointerDown: function onPointerDown() {
|
|
28735
28755
|
if (!craftItemKey || isCraftingDisabled) return;
|
|
28736
|
-
|
|
28756
|
+
var selectedItem = craftablesItems.find(function (item) {
|
|
28757
|
+
return item.key === craftItemKey;
|
|
28758
|
+
});
|
|
28759
|
+
var maxCraftable = calculateMaxCraftable(selectedItem, inventory);
|
|
28760
|
+
onCraftItem(craftItemKey, maxCraftable);
|
|
28737
28761
|
setIsCraftingDisabled(true);
|
|
28738
28762
|
setTimeout(function () {
|
|
28739
28763
|
setIsCraftingDisabled(false);
|