@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICraftableItem, IEquipmentSet,
|
|
1
|
+
import { ICraftableItem, IEquipmentSet, ISkill } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface ICraftingRecipeProps {
|
|
4
4
|
atlasJSON: any;
|
|
@@ -8,7 +8,6 @@ interface ICraftingRecipeProps {
|
|
|
8
8
|
scale?: number;
|
|
9
9
|
handleRecipeSelect: () => void;
|
|
10
10
|
selectedCraftItemKey?: string;
|
|
11
|
-
inventory?: IItemContainer | null;
|
|
12
11
|
skills?: ISkill | null;
|
|
13
12
|
}
|
|
14
13
|
export declare const CraftingRecipe: React.FC<ICraftingRecipeProps>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ICraftableItem,
|
|
1
|
+
import { ICraftableItem, ISkill } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface ICraftingTooltipProps {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
recipe: ICraftableItem;
|
|
7
|
-
inventory?: IItemContainer | null;
|
|
8
7
|
skills?: ISkill | null;
|
|
9
8
|
atlasIMG: any;
|
|
10
9
|
atlasJSON: any;
|
|
@@ -28852,23 +28852,6 @@ var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
|
|
|
28852
28852
|
}));
|
|
28853
28853
|
};
|
|
28854
28854
|
|
|
28855
|
-
var countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
28856
|
-
var itemsFromInventory = [];
|
|
28857
|
-
if (inventory) {
|
|
28858
|
-
Object.keys(inventory.slots).forEach(function (i) {
|
|
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
|
-
});
|
|
28865
|
-
}
|
|
28866
|
-
var totalQty = itemsFromInventory.reduce(function (acc, item) {
|
|
28867
|
-
return acc + ((item == null ? void 0 : item.stackQty) || 1);
|
|
28868
|
-
}, 0);
|
|
28869
|
-
return totalQty;
|
|
28870
|
-
};
|
|
28871
|
-
|
|
28872
28855
|
var modifyString = function modifyString(str) {
|
|
28873
28856
|
var parts = str.split('/');
|
|
28874
28857
|
var fileName = parts[parts.length - 1];
|
|
@@ -28917,7 +28900,6 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28917
28900
|
var x = _ref3.x,
|
|
28918
28901
|
y = _ref3.y,
|
|
28919
28902
|
recipe = _ref3.recipe,
|
|
28920
|
-
inventory = _ref3.inventory,
|
|
28921
28903
|
skills = _ref3.skills,
|
|
28922
28904
|
atlasIMG = _ref3.atlasIMG,
|
|
28923
28905
|
atlasJSON = _ref3.atlasJSON;
|
|
@@ -28965,8 +28947,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28965
28947
|
}, React__default.createElement(TooltipTitle, null, "Skill Requirements"), React__default.createElement(MinCraftingRequirementsText, {
|
|
28966
28948
|
levelIsOk: levelIsOk
|
|
28967
28949
|
}, 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
|
|
28969
|
-
var isQuantityOk = ingredient.qty <= itemQtyInInventory;
|
|
28950
|
+
var isQuantityOk = ingredient.qty <= ingredient.qtyInInventory;
|
|
28970
28951
|
return React__default.createElement(Recipe, {
|
|
28971
28952
|
key: index
|
|
28972
28953
|
}, React__default.createElement(SpriteFromAtlas, {
|
|
@@ -28976,7 +28957,7 @@ var CraftingTooltip = function CraftingTooltip(_ref3) {
|
|
|
28976
28957
|
imgScale: 1.2
|
|
28977
28958
|
}), React__default.createElement(Ingredient, {
|
|
28978
28959
|
isQuantityOk: isQuantityOk
|
|
28979
|
-
}, modifyString(ingredient.key), " x", ingredient.qty, " (",
|
|
28960
|
+
}, modifyString(ingredient.key), " x", ingredient.qty, " (", ingredient.qtyInInventory, ")"));
|
|
28980
28961
|
}));
|
|
28981
28962
|
};
|
|
28982
28963
|
|
|
@@ -29004,7 +28985,6 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
29004
28985
|
scale = _ref.scale,
|
|
29005
28986
|
handleRecipeSelect = _ref.handleRecipeSelect,
|
|
29006
28987
|
selectedCraftItemKey = _ref.selectedCraftItemKey,
|
|
29007
|
-
inventory = _ref.inventory,
|
|
29008
28988
|
skills = _ref.skills;
|
|
29009
28989
|
var _useState = React.useState(false),
|
|
29010
28990
|
showTooltip = _useState[0],
|
|
@@ -29067,7 +29047,6 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
29067
29047
|
x: tooltipPosition.x,
|
|
29068
29048
|
y: tooltipPosition.y,
|
|
29069
29049
|
recipe: recipe,
|
|
29070
|
-
inventory: inventory,
|
|
29071
29050
|
skills: skills,
|
|
29072
29051
|
atlasIMG: atlasIMG,
|
|
29073
29052
|
atlasJSON: atlasJSON
|
|
@@ -29109,20 +29088,40 @@ var useResponsiveSize = function useResponsiveSize(scale) {
|
|
|
29109
29088
|
return size;
|
|
29110
29089
|
};
|
|
29111
29090
|
|
|
29091
|
+
var _countItemFromInventory = function countItemFromInventory(itemKey, inventory) {
|
|
29092
|
+
var totalQty = 0;
|
|
29093
|
+
if (!inventory) {
|
|
29094
|
+
return totalQty;
|
|
29095
|
+
}
|
|
29096
|
+
Object.keys(inventory.slots).forEach(function (i) {
|
|
29097
|
+
var index = parseInt(i);
|
|
29098
|
+
var item = inventory.slots[index];
|
|
29099
|
+
if (!item) {
|
|
29100
|
+
return;
|
|
29101
|
+
}
|
|
29102
|
+
// Count matching items
|
|
29103
|
+
if (item.key === itemKey) {
|
|
29104
|
+
totalQty += item.stackQty || 1;
|
|
29105
|
+
}
|
|
29106
|
+
// Recursively check nested containers
|
|
29107
|
+
if (item.isItemContainer && item.itemContainer && typeof item.itemContainer !== "string") {
|
|
29108
|
+
totalQty += _countItemFromInventory(itemKey, item.itemContainer);
|
|
29109
|
+
}
|
|
29110
|
+
});
|
|
29111
|
+
return totalQty;
|
|
29112
|
+
};
|
|
29113
|
+
|
|
29112
29114
|
function calculateMaxCraftable(recipe, inventory) {
|
|
29113
29115
|
var _recipe$ingredients$r;
|
|
29114
29116
|
if (!inventory || !(recipe != null && recipe.ingredients)) {
|
|
29115
29117
|
return 0;
|
|
29116
29118
|
}
|
|
29117
29119
|
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) {
|
|
29120
|
+
var totalQty = _countItemFromInventory(ingredient.key, inventory);
|
|
29121
|
+
if (totalQty === 0) {
|
|
29123
29122
|
return 0;
|
|
29124
29123
|
}
|
|
29125
|
-
var possibleWithThisIngredient = Math.floor(
|
|
29124
|
+
var possibleWithThisIngredient = Math.floor(totalQty / ingredient.qty);
|
|
29126
29125
|
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
29127
29126
|
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
29128
29127
|
}
|
|
@@ -29268,7 +29267,6 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
29268
29267
|
scale: scale,
|
|
29269
29268
|
handleRecipeSelect: setCraftItemKey.bind(null, item.key),
|
|
29270
29269
|
selectedCraftItemKey: craftItemKey,
|
|
29271
|
-
inventory: inventory,
|
|
29272
29270
|
skills: skills
|
|
29273
29271
|
}));
|
|
29274
29272
|
})) : React__default.createElement(EmptyState, null, React__default.createElement(fa.FaBoxOpen, {
|
|
@@ -36425,7 +36423,7 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36425
36423
|
}
|
|
36426
36424
|
});
|
|
36427
36425
|
}
|
|
36428
|
-
var totalQty = _payload && inventory ?
|
|
36426
|
+
var totalQty = _payload && inventory ? _countItemFromInventory(_payload.key, inventory) : 0;
|
|
36429
36427
|
return React__default.createElement(StyledShortcut$1, {
|
|
36430
36428
|
key: i,
|
|
36431
36429
|
onPointerDown: handleShortcutCast.bind(null, i),
|