@rpg-engine/long-bow 0.8.119 → 0.8.121
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/CraftingRecipe.d.ts +1 -2
- package/dist/components/CraftBook/CraftingTooltip.d.ts +1 -2
- package/dist/long-bow.cjs.development.js +29 -31
- 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 +29 -31
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +0 -1
- package/src/components/CraftBook/CraftingRecipe.tsx +0 -4
- package/src/components/CraftBook/CraftingTooltip.tsx +3 -9
- package/src/components/CraftBook/MockItems.ts +8 -0
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +5 -8
- package/src/libs/itemCounter.ts +23 -15
package/dist/long-bow.esm.js
CHANGED
|
@@ -28845,23 +28845,6 @@ var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
|
|
|
28845
28845
|
}));
|
|
28846
28846
|
};
|
|
28847
28847
|
|
|
28848
|
-
var countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
28849
|
-
var itemsFromInventory = [];
|
|
28850
|
-
if (inventory) {
|
|
28851
|
-
Object.keys(inventory.slots).forEach(function (i) {
|
|
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
|
-
});
|
|
28858
|
-
}
|
|
28859
|
-
var totalQty = itemsFromInventory.reduce(function (acc, item) {
|
|
28860
|
-
return acc + ((item == null ? void 0 : item.stackQty) || 1);
|
|
28861
|
-
}, 0);
|
|
28862
|
-
return totalQty;
|
|
28863
|
-
};
|
|
28864
|
-
|
|
28865
28848
|
var modifyString = function modifyString(str) {
|
|
28866
28849
|
var parts = str.split('/');
|
|
28867
28850
|
var fileName = parts[parts.length - 1];
|
|
@@ -28910,7 +28893,6 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28910
28893
|
var x = _ref3.x,
|
|
28911
28894
|
y = _ref3.y,
|
|
28912
28895
|
recipe = _ref3.recipe,
|
|
28913
|
-
inventory = _ref3.inventory,
|
|
28914
28896
|
skills = _ref3.skills,
|
|
28915
28897
|
atlasIMG = _ref3.atlasIMG,
|
|
28916
28898
|
atlasJSON = _ref3.atlasJSON;
|
|
@@ -28958,8 +28940,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28958
28940
|
}, React.createElement(TooltipTitle, null, "Skill Requirements"), React.createElement(MinCraftingRequirementsText, {
|
|
28959
28941
|
levelIsOk: levelIsOk
|
|
28960
28942
|
}, 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
|
|
28962
|
-
var isQuantityOk = ingredient.qty <= itemQtyInInventory;
|
|
28943
|
+
var isQuantityOk = ingredient.qty <= ingredient.qtyInInventory;
|
|
28963
28944
|
return React.createElement(Recipe, {
|
|
28964
28945
|
key: index
|
|
28965
28946
|
}, React.createElement(SpriteFromAtlas, {
|
|
@@ -28969,7 +28950,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28969
28950
|
imgScale: 1.2
|
|
28970
28951
|
}), React.createElement(Ingredient, {
|
|
28971
28952
|
isQuantityOk: isQuantityOk
|
|
28972
|
-
}, modifyString(ingredient.key), " x", ingredient.qty, " (",
|
|
28953
|
+
}, modifyString(ingredient.key), " x", ingredient.qty, " (", ingredient.qtyInInventory, ")"));
|
|
28973
28954
|
}));
|
|
28974
28955
|
};
|
|
28975
28956
|
|
|
@@ -28997,7 +28978,6 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
28997
28978
|
scale = _ref.scale,
|
|
28998
28979
|
handleRecipeSelect = _ref.handleRecipeSelect,
|
|
28999
28980
|
selectedCraftItemKey = _ref.selectedCraftItemKey,
|
|
29000
|
-
inventory = _ref.inventory,
|
|
29001
28981
|
skills = _ref.skills;
|
|
29002
28982
|
var _useState = useState(false),
|
|
29003
28983
|
showTooltip = _useState[0],
|
|
@@ -29060,7 +29040,6 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
29060
29040
|
x: tooltipPosition.x,
|
|
29061
29041
|
y: tooltipPosition.y,
|
|
29062
29042
|
recipe: recipe,
|
|
29063
|
-
inventory: inventory,
|
|
29064
29043
|
skills: skills,
|
|
29065
29044
|
atlasIMG: atlasIMG,
|
|
29066
29045
|
atlasJSON: atlasJSON
|
|
@@ -29102,20 +29081,40 @@ var useResponsiveSize = function useResponsiveSize(scale) {
|
|
|
29102
29081
|
return size;
|
|
29103
29082
|
};
|
|
29104
29083
|
|
|
29084
|
+
var _countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
29085
|
+
var totalQty = 0;
|
|
29086
|
+
if (!inventory) {
|
|
29087
|
+
return totalQty;
|
|
29088
|
+
}
|
|
29089
|
+
Object.keys(inventory.slots).forEach(function (i) {
|
|
29090
|
+
var index = parseInt(i);
|
|
29091
|
+
var item = inventory.slots[index];
|
|
29092
|
+
if (!item) {
|
|
29093
|
+
return;
|
|
29094
|
+
}
|
|
29095
|
+
// Count matching items
|
|
29096
|
+
if (item.key === itemKey) {
|
|
29097
|
+
totalQty += item.stackQty || 1;
|
|
29098
|
+
}
|
|
29099
|
+
// Recursively check nested containers
|
|
29100
|
+
if (item.isItemContainer && item.itemContainer && typeof item.itemContainer !== "string") {
|
|
29101
|
+
totalQty += _countItemFromInventory(itemKey, item.itemContainer);
|
|
29102
|
+
}
|
|
29103
|
+
});
|
|
29104
|
+
return totalQty;
|
|
29105
|
+
};
|
|
29106
|
+
|
|
29105
29107
|
function calculateMaxCraftable(recipe, inventory) {
|
|
29106
29108
|
var _recipe$ingredients$r;
|
|
29107
29109
|
if (!inventory || !(recipe != null && recipe.ingredients)) {
|
|
29108
29110
|
return 0;
|
|
29109
29111
|
}
|
|
29110
29112
|
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) {
|
|
29113
|
+
var totalQty = _countItemFromInventory(ingredient.key, inventory);
|
|
29114
|
+
if (totalQty === 0) {
|
|
29116
29115
|
return 0;
|
|
29117
29116
|
}
|
|
29118
|
-
var possibleWithThisIngredient = Math.floor(
|
|
29117
|
+
var possibleWithThisIngredient = Math.floor(totalQty / ingredient.qty);
|
|
29119
29118
|
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
29120
29119
|
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
29121
29120
|
}
|
|
@@ -29261,7 +29260,6 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
29261
29260
|
scale: scale,
|
|
29262
29261
|
handleRecipeSelect: setCraftItemKey.bind(null, item.key),
|
|
29263
29262
|
selectedCraftItemKey: craftItemKey,
|
|
29264
|
-
inventory: inventory,
|
|
29265
29263
|
skills: skills
|
|
29266
29264
|
}));
|
|
29267
29265
|
})) : React.createElement(EmptyState, null, React.createElement(FaBoxOpen, {
|
|
@@ -36422,7 +36420,7 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36422
36420
|
}
|
|
36423
36421
|
});
|
|
36424
36422
|
}
|
|
36425
|
-
var totalQty = _payload && inventory ?
|
|
36423
|
+
var totalQty = _payload && inventory ? _countItemFromInventory(_payload.key, inventory) : 0;
|
|
36426
36424
|
return React.createElement(StyledShortcut$1, {
|
|
36427
36425
|
key: i,
|
|
36428
36426
|
onPointerDown: handleShortcutCast.bind(null, i),
|