@rpg-engine/long-bow 0.7.89 → 0.7.91
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 +50 -6
- 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 +50 -6
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +55 -4
- 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%)'
|
|
@@ -28622,9 +28642,12 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28622
28642
|
var _useState3 = useState(),
|
|
28623
28643
|
size = _useState3[0],
|
|
28624
28644
|
setSize = _useState3[1];
|
|
28625
|
-
var _useState4 = useState(
|
|
28626
|
-
|
|
28627
|
-
|
|
28645
|
+
var _useState4 = useState(''),
|
|
28646
|
+
searchTerm = _useState4[0],
|
|
28647
|
+
setSearchTerm = _useState4[1];
|
|
28648
|
+
var _useState5 = useState(false),
|
|
28649
|
+
isCraftingDisabled = _useState5[0],
|
|
28650
|
+
setIsCraftingDisabled = _useState5[1];
|
|
28628
28651
|
useEffect(function () {
|
|
28629
28652
|
var handleResize = function handleResize() {
|
|
28630
28653
|
if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
|
|
@@ -28690,6 +28713,11 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28690
28713
|
}, row);
|
|
28691
28714
|
});
|
|
28692
28715
|
};
|
|
28716
|
+
var filteredCraftableItems = craftablesItems == null ? void 0 : craftablesItems.filter(function (item) {
|
|
28717
|
+
var matchesSearch = item.name.toLowerCase().includes(searchTerm.toLowerCase());
|
|
28718
|
+
var matchesCategory = selectedType === 'Suggested' || item.type === selectedType;
|
|
28719
|
+
return matchesSearch && matchesCategory;
|
|
28720
|
+
});
|
|
28693
28721
|
if (!size) return null;
|
|
28694
28722
|
return React.createElement(DraggableContainer, {
|
|
28695
28723
|
type: RPGUIContainerTypes.Framed,
|
|
@@ -28706,13 +28734,21 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28706
28734
|
style: {
|
|
28707
28735
|
width: '100%'
|
|
28708
28736
|
}
|
|
28709
|
-
}, React.createElement(Title$2, null, "Craftbook"), React.createElement(Subtitle, null, "Select an item to craft"), React.createElement("
|
|
28737
|
+
}, React.createElement(Title$2, null, "Craftbook"), React.createElement(Subtitle, null, "Select an item to craft"), React.createElement(SearchContainer$1, null, React.createElement("input", {
|
|
28738
|
+
type: "text",
|
|
28739
|
+
className: "rpgui-input",
|
|
28740
|
+
placeholder: "Search items...",
|
|
28741
|
+
value: searchTerm,
|
|
28742
|
+
onChange: function onChange(e) {
|
|
28743
|
+
return setSearchTerm(e.target.value);
|
|
28744
|
+
}
|
|
28745
|
+
})), React.createElement("hr", {
|
|
28710
28746
|
className: "golden"
|
|
28711
28747
|
})), React.createElement(ContentContainer, null, React.createElement(ItemTypes, {
|
|
28712
28748
|
className: "inputRadioCraftBook"
|
|
28713
28749
|
}, renderItemTypes()), React.createElement(RadioInputScroller, {
|
|
28714
28750
|
className: "inputRadioCraftBook"
|
|
28715
|
-
},
|
|
28751
|
+
}, filteredCraftableItems == null ? void 0 : filteredCraftableItems.map(function (item) {
|
|
28716
28752
|
return React.createElement(CraftingRecipe, {
|
|
28717
28753
|
key: item.key,
|
|
28718
28754
|
atlasIMG: atlasIMG,
|
|
@@ -28733,7 +28769,11 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28733
28769
|
buttonType: ButtonTypes.RPGUIButton,
|
|
28734
28770
|
onPointerDown: function onPointerDown() {
|
|
28735
28771
|
if (!craftItemKey || isCraftingDisabled) return;
|
|
28736
|
-
|
|
28772
|
+
var selectedItem = craftablesItems.find(function (item) {
|
|
28773
|
+
return item.key === craftItemKey;
|
|
28774
|
+
});
|
|
28775
|
+
var maxCraftable = calculateMaxCraftable(selectedItem, inventory);
|
|
28776
|
+
onCraftItem(craftItemKey, maxCraftable);
|
|
28737
28777
|
setIsCraftingDisabled(true);
|
|
28738
28778
|
setTimeout(function () {
|
|
28739
28779
|
setIsCraftingDisabled(false);
|
|
@@ -28769,6 +28809,10 @@ var ItemTypes = /*#__PURE__*/styled.div.withConfig({
|
|
|
28769
28809
|
displayName: "CraftBook__ItemTypes",
|
|
28770
28810
|
componentId: "sc-19q95ue-6"
|
|
28771
28811
|
})(["display:flex;overflow-y:scroll;overflow-x:hidden;width:max-content;flex-direction:column;padding-right:5px;@media (max-width:", "){overflow-x:scroll;overflow-y:hidden;padding-right:0;width:100%;}"], mobilePortrait.width);
|
|
28812
|
+
var SearchContainer$1 = /*#__PURE__*/styled.div.withConfig({
|
|
28813
|
+
displayName: "CraftBook__SearchContainer",
|
|
28814
|
+
componentId: "sc-19q95ue-7"
|
|
28815
|
+
})(["margin:8px 0;padding:0 16px;input{width:100%;font-size:0.8rem;padding:8px 12px;background-color:rgba(0,0,0,0.3);border:none;color:white;border-radius:4px;&::placeholder{color:rgba(255,255,255,0.5);}&:focus{outline:none;background-color:rgba(0,0,0,0.4);}}"]);
|
|
28772
28816
|
|
|
28773
28817
|
var Dropdown = function Dropdown(_ref) {
|
|
28774
28818
|
var options = _ref.options,
|