@rpg-engine/long-bow 0.8.4 → 0.8.5

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.
Files changed (34) hide show
  1. package/dist/components/InformationCenter/sections/bestiary/BestiarySection.d.ts +1 -0
  2. package/dist/components/InformationCenter/sections/faq/FaqSection.d.ts +1 -0
  3. package/dist/components/InformationCenter/sections/items/ItemsSection.d.ts +1 -0
  4. package/dist/components/InternalTabs/InternalTabs.d.ts +2 -0
  5. package/dist/components/Store/InternalStoreTab.d.ts +15 -0
  6. package/dist/components/Store/Store.d.ts +3 -0
  7. package/dist/components/Store/StoreItemRow.d.ts +13 -0
  8. package/dist/components/Store/StoreTabContent.d.ts +14 -0
  9. package/dist/components/Store/StoreTypes.d.ts +19 -0
  10. package/dist/components/shared/PaginatedContent/PaginatedContent.d.ts +24 -0
  11. package/dist/long-bow.cjs.development.js +19 -7
  12. package/dist/long-bow.cjs.development.js.map +1 -1
  13. package/dist/long-bow.cjs.production.min.js +1 -1
  14. package/dist/long-bow.cjs.production.min.js.map +1 -1
  15. package/dist/long-bow.esm.js +19 -7
  16. package/dist/long-bow.esm.js.map +1 -1
  17. package/dist/stories/Features/store/Store.stories.d.ts +1 -0
  18. package/dist/utils/itemUtils.d.ts +8 -0
  19. package/package.json +1 -1
  20. package/src/components/InformationCenter/InformationCenter.tsx +15 -1
  21. package/src/components/InformationCenter/InformationCenterCell.tsx +7 -0
  22. package/src/components/InformationCenter/sections/bestiary/BestiarySection.tsx +31 -42
  23. package/src/components/InformationCenter/sections/faq/FaqSection.tsx +14 -34
  24. package/src/components/InformationCenter/sections/items/ItemsSection.tsx +40 -40
  25. package/src/components/InternalTabs/InternalTabs.tsx +9 -5
  26. package/src/components/Item/Inventory/itemContainerHelper.ts +13 -0
  27. package/src/components/Store/InternalStoreTab.tsx +142 -0
  28. package/src/components/Store/Store.tsx +192 -0
  29. package/src/components/Store/StoreItemRow.tsx +198 -0
  30. package/src/components/Store/StoreTabContent.tsx +46 -0
  31. package/src/components/Store/StoreTypes.ts +21 -0
  32. package/src/components/shared/PaginatedContent/PaginatedContent.tsx +182 -0
  33. package/src/stories/Features/store/Store.stories.tsx +102 -0
  34. package/src/utils/itemUtils.ts +36 -0
@@ -0,0 +1,102 @@
1
+ import { UserAccountTypes } from '@rpg-engine/shared';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import React from 'react';
4
+ import { RPGUIRoot } from '../../../components/RPGUI/RPGUIRoot';
5
+ import { Store } from '../../../components/Store/Store';
6
+ import { IStoreItem } from '../../../components/Store/StoreTypes';
7
+ import itemsAtlasJSON from '../../../mocks/atlas/items/items.json';
8
+ import itemsAtlasIMG from '../../../mocks/atlas/items/items.png';
9
+ import { mockItems } from '../../../mocks/informationCenter.mocks';
10
+
11
+ const meta = {
12
+ title: 'Features/Store',
13
+ component: Store,
14
+ parameters: {
15
+ layout: 'centered',
16
+ },
17
+ decorators: [
18
+ Story => (
19
+ <RPGUIRoot>
20
+ <Story />
21
+ </RPGUIRoot>
22
+ ),
23
+ ],
24
+ } satisfies Meta<typeof Store>;
25
+
26
+ export default meta;
27
+ type Story = StoryObj<typeof Store>;
28
+
29
+ // Create mock items once, with fixed stock values
30
+ const storeItems: IStoreItem[] = mockItems.map((item, index) => ({
31
+ _id: `original-${item.key}-${index}`,
32
+ key: `original-${item.key}-${index}`,
33
+ name: item.name,
34
+ description: item.description,
35
+ fullDescription: item.description,
36
+ texturePath: item.texturePath,
37
+ textureAtlas: 'items',
38
+ textureKey: item.texturePath,
39
+ price: item.basePrice,
40
+ stock: 5 + (index % 5), // Fixed stock values based on index
41
+ type: item.type,
42
+ subType: item.subType,
43
+ attack: item.attack || 0,
44
+ defense: item.defense || 0,
45
+ weight: item.weight,
46
+ rarity: item.rarity,
47
+ isEquipable: true,
48
+ isStackable: item.maxStackSize > 1,
49
+ isUsable: true,
50
+ isStorable: true,
51
+ hasUseWith: false,
52
+ isSolid: false,
53
+ isTwoHanded: false,
54
+ isItemContainer: false,
55
+ layer: 1,
56
+ allowedEquipSlotType: item.allowedEquipSlotType || [],
57
+ maxStackSize: item.maxStackSize || 1,
58
+ usableEffectDescription: item.usableEffectDescription || '',
59
+ canSell: item.canSell ?? true,
60
+ rangeType: item.rangeType,
61
+ entityEffects: item.entityEffects || [],
62
+ entityEffectChance: item.entityEffectChance || 0,
63
+ equippedBuff: item.equippedBuff || [],
64
+ equippedBuffDescription: item.equippedBuffDescription || '',
65
+ requiredAccountType: item.rarity === 'Legendary' ? [UserAccountTypes.PremiumGold] : [],
66
+ }));
67
+
68
+ // Create duplicated items once with unique keys
69
+ const duplicatedItems: IStoreItem[] = [
70
+ ...storeItems,
71
+ ...storeItems.map((item, index) => ({
72
+ ...item,
73
+ _id: `copy1-${item.key}-${index}`,
74
+ key: `copy1-${item.key}-${index}`,
75
+ })),
76
+ ...storeItems.map((item, index) => ({
77
+ ...item,
78
+ _id: `copy2-${item.key}-${index}`,
79
+ key: `copy2-${item.key}-${index}`,
80
+ })),
81
+ ...storeItems.map((item, index) => ({
82
+ ...item,
83
+ _id: `copy3-${item.key}-${index}`,
84
+ key: `copy3-${item.key}-${index}`,
85
+ })),
86
+ ];
87
+
88
+ // Create the story with the static mock data
89
+ export const Default: Story = {
90
+ render: () => (
91
+ <Store
92
+ items={duplicatedItems}
93
+ userGold={1000}
94
+ userAccountType={UserAccountTypes.Free}
95
+ onPurchase={(item: IStoreItem, quantity: number) => {
96
+ console.log('Purchased', quantity, 'x', item.name);
97
+ }}
98
+ atlasJSON={itemsAtlasJSON}
99
+ atlasIMG={itemsAtlasIMG}
100
+ />
101
+ ),
102
+ };
@@ -0,0 +1,36 @@
1
+ interface IItemSprite {
2
+ key: string;
3
+ stackQty?: number;
4
+ texturePath: string;
5
+ isStackable?: boolean;
6
+ }
7
+
8
+ export const getItemTextureKeyPath = (
9
+ item: IItemSprite,
10
+ atlasJSON: Record<string, any>
11
+ ): string => {
12
+ if (!item.texturePath) {
13
+ return '';
14
+ }
15
+
16
+ const textureKey = item.texturePath
17
+ .split('/')
18
+ .pop()
19
+ ?.split('.')[0];
20
+
21
+ if (!textureKey) {
22
+ return '';
23
+ }
24
+
25
+ const stackQty = item.stackQty || 1;
26
+ const isStackable = item.isStackable || false;
27
+
28
+ if (isStackable && stackQty > 1) {
29
+ const stackKey = `${textureKey}-stack`;
30
+ if (atlasJSON.frames[stackKey]) {
31
+ return stackKey;
32
+ }
33
+ }
34
+
35
+ return textureKey;
36
+ };