@rpg-engine/long-bow 0.8.120 → 0.8.122

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.120",
3
+ "version": "0.8.122",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -208,7 +208,6 @@ export const CraftBook: React.FC<IItemCraftSelectorProps> = ({
208
208
  scale={scale}
209
209
  handleRecipeSelect={setCraftItemKey.bind(null, item.key)}
210
210
  selectedCraftItemKey={craftItemKey}
211
- inventory={inventory}
212
211
  skills={skills}
213
212
  />
214
213
  </CraftingRecipeWrapper>
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ICraftableItem,
3
3
  IEquipmentSet,
4
- IItemContainer,
5
4
  ISkill,
6
5
  } from '@rpg-engine/shared';
7
6
  import React, { useEffect, useRef, useState } from 'react';
@@ -20,7 +19,6 @@ interface ICraftingRecipeProps {
20
19
  scale?: number;
21
20
  handleRecipeSelect: () => void;
22
21
  selectedCraftItemKey?: string;
23
- inventory?: IItemContainer | null;
24
22
  skills?: ISkill | null;
25
23
  }
26
24
 
@@ -71,7 +69,6 @@ export const CraftingRecipe: React.FC<ICraftingRecipeProps> = ({
71
69
  scale,
72
70
  handleRecipeSelect,
73
71
  selectedCraftItemKey,
74
- inventory,
75
72
  skills,
76
73
  }) => {
77
74
  const [showTooltip, setShowTooltip] = useState(false);
@@ -150,7 +147,6 @@ export const CraftingRecipe: React.FC<ICraftingRecipeProps> = ({
150
147
  x={tooltipPosition.x}
151
148
  y={tooltipPosition.y}
152
149
  recipe={recipe}
153
- inventory={inventory}
154
150
  skills={skills}
155
151
  atlasIMG={atlasIMG}
156
152
  atlasJSON={atlasJSON}
@@ -1,8 +1,7 @@
1
- import { ICraftableItem, IItemContainer, ISkill } from '@rpg-engine/shared';
1
+ import { ICraftableItem, ISkill } from '@rpg-engine/shared';
2
2
  import React, { useEffect, useRef } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { uiColors } from '../../constants/uiColors';
5
- import { countItemFromInventory } from '../../libs/itemCounter';
6
5
  import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
7
6
  import { modifyString } from './utils/modifyString';
8
7
 
@@ -10,7 +9,6 @@ interface ICraftingTooltipProps {
10
9
  x: number;
11
10
  y: number;
12
11
  recipe: ICraftableItem;
13
- inventory?: IItemContainer | null;
14
12
  skills?: ISkill | null;
15
13
  atlasIMG: any;
16
14
  atlasJSON: any;
@@ -85,7 +83,6 @@ export const CraftingTooltip: React.FC<ICraftingTooltipProps> = ({
85
83
  x,
86
84
  y,
87
85
  recipe,
88
- inventory,
89
86
  skills,
90
87
  atlasIMG,
91
88
  atlasJSON,
@@ -144,10 +141,7 @@ export const CraftingTooltip: React.FC<ICraftingTooltipProps> = ({
144
141
 
145
142
  <TooltipTitle>Ingredients</TooltipTitle>
146
143
  {recipe.ingredients.map((ingredient, index) => {
147
- const itemQtyInInventory = !inventory
148
- ? 0
149
- : countItemFromInventory(ingredient.key, inventory);
150
- const isQuantityOk = ingredient.qty <= itemQtyInInventory;
144
+ const isQuantityOk = ingredient.qty <= ingredient.qtyInInventory;
151
145
 
152
146
  return (
153
147
  <Recipe key={index}>
@@ -159,7 +153,7 @@ export const CraftingTooltip: React.FC<ICraftingTooltipProps> = ({
159
153
  />
160
154
  <Ingredient isQuantityOk={isQuantityOk}>
161
155
  {modifyString(ingredient.key)} x{ingredient.qty} (
162
- {itemQtyInInventory})
156
+ {ingredient.qtyInInventory})
163
157
  </Ingredient>
164
158
  </Recipe>
165
159
  );
@@ -11,18 +11,21 @@ export const craftableItems: ICraftableItem[] = [
11
11
  name: 'leather',
12
12
  qty: 5,
13
13
  texturePath: 'crafting-resources/leather.png',
14
+ qtyInInventory: 10,
14
15
  },
15
16
  {
16
17
  key: 'leather1',
17
18
  name: 'leather',
18
19
  qty: 10,
19
20
  texturePath: 'crafting-resources/leather.png',
21
+ qtyInInventory: 5,
20
22
  },
21
23
  {
22
24
  key: 'leather2',
23
25
  name: 'leather',
24
26
  qty: 100,
25
27
  texturePath: 'crafting-resources/leather.png',
28
+ qtyInInventory: 0,
26
29
  },
27
30
  ],
28
31
  minCraftingRequirements: ['blacksmithing', 4],
@@ -37,6 +40,7 @@ export const craftableItems: ICraftableItem[] = [
37
40
  name: 'leather',
38
41
  qty: 10,
39
42
  texturePath: 'crafting-resources/leather.png',
43
+ qtyInInventory: 15,
40
44
  },
41
45
  ],
42
46
  minCraftingRequirements: ['blacksmithing', 4],
@@ -51,6 +55,7 @@ export const craftableItems: ICraftableItem[] = [
51
55
  name: 'leather',
52
56
  qty: 10,
53
57
  texturePath: 'crafting-resources/leather.png',
58
+ qtyInInventory: 15,
54
59
  },
55
60
  ],
56
61
  minCraftingRequirements: ['blacksmithing', 4],
@@ -65,6 +70,7 @@ export const craftableItems: ICraftableItem[] = [
65
70
  name: 'leather',
66
71
  qty: 10,
67
72
  texturePath: 'crafting-resources/leather.png',
73
+ qtyInInventory: 15,
68
74
  },
69
75
  ],
70
76
  minCraftingRequirements: ['blacksmithing', 4],
@@ -79,6 +85,7 @@ export const craftableItems: ICraftableItem[] = [
79
85
  name: 'leather',
80
86
  qty: 10,
81
87
  texturePath: 'crafting-resources/leather.png',
88
+ qtyInInventory: 15,
82
89
  },
83
90
  ],
84
91
  minCraftingRequirements: ['blacksmithing', 1],
@@ -93,6 +100,7 @@ export const craftableItems: ICraftableItem[] = [
93
100
  name: 'leather',
94
101
  qty: 10,
95
102
  texturePath: 'crafting-resources/leather.png',
103
+ qtyInInventory: 15,
96
104
  },
97
105
  ],
98
106
  minCraftingRequirements: ['blacksmithing', 4],
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { UI_BREAKPOINT_MOBILE } from '../../constants/uiBreakpoints';
4
4
 
@@ -29,7 +29,13 @@ export const InternalTabs: React.FC<TableTabProps> = ({
29
29
  onTabChange,
30
30
  activeTab: externalActiveTab,
31
31
  }) => {
32
- const activeTabId = externalActiveTab ?? tabs[0].id;
32
+ const [internalActiveTab, setInternalActiveTab] = useState(tabs[0]?.id);
33
+ const activeTabId = externalActiveTab ?? internalActiveTab;
34
+
35
+ const handleTabClick = (tabId: string): void => {
36
+ setInternalActiveTab(tabId);
37
+ onTabChange?.(tabId);
38
+ };
33
39
 
34
40
  return (
35
41
  <TableWrapper>
@@ -43,7 +49,7 @@ export const InternalTabs: React.FC<TableTabProps> = ({
43
49
  inactiveColor={inactiveColor}
44
50
  borderColor={borderColor}
45
51
  hoverColor={hoverColor}
46
- onClick={() => onTabChange?.(tab.id)}
52
+ onClick={() => handleTabClick(tab.id)}
47
53
  >
48
54
  {tab.title}
49
55
  </TabButton>