@rpg-engine/long-bow 0.5.13 → 0.5.14

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.5.13",
3
+ "version": "0.5.14",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@rollup/plugin-image": "^2.1.1",
86
- "@rpg-engine/shared": "^0.8.74",
86
+ "@rpg-engine/shared": "^0.8.83",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -13,7 +13,6 @@ import { ItemQuantitySelector } from './ItemQuantitySelector';
13
13
 
14
14
  import { IPosition } from '../../../types/eventTypes';
15
15
  import ModalPortal from '../../Abstractions/ModalPortal';
16
- import SelectArrow from '../../Arrow/SelectArrow';
17
16
  import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
18
17
  import { ItemSlot } from './ItemSlot';
19
18
 
@@ -82,15 +81,12 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
82
81
  onPositionChangeEnd,
83
82
  onPositionChangeStart,
84
83
  }) => {
85
- const MAX_SLOTS_PER_PAGE = 20;
86
84
  const [quantitySelect, setQuantitySelect] = useState({
87
85
  isOpen: false,
88
86
  maxQuantity: 1,
89
- callback: (_quantity: number) => { },
87
+ callback: (_quantity: number) => {},
90
88
  });
91
89
  const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
92
- const [currentPage, setCurrentPage] = useState(1);
93
- const totalPages = Math.ceil(itemContainer.slotQty / MAX_SLOTS_PER_PAGE);
94
90
 
95
91
  const handleSetShortcut = (item: IItem, index: number) => {
96
92
  if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
@@ -100,11 +96,8 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
100
96
 
101
97
  const onRenderSlots = () => {
102
98
  const slots = [];
103
- const start = (currentPage - 1) * MAX_SLOTS_PER_PAGE;
104
- const end = start + MAX_SLOTS_PER_PAGE;
105
99
 
106
- for (let i = start; i < end && i < itemContainer.slotQty; i++) {
107
- console.log(itemContainer)
100
+ for (let i = 0; i < itemContainer.slotQty; i++) {
108
101
  slots.push(
109
102
  <ItemSlot
110
103
  isContextMenuDisabled={disableContextMenu}
@@ -163,14 +156,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
163
156
  return slots;
164
157
  };
165
158
 
166
- const goToNextPage = () => {
167
- setCurrentPage(current => Math.min(current + 1, totalPages));
168
- };
169
-
170
- const goToPreviousPage = () => {
171
- setCurrentPage(current => Math.max(current - 1, 1));
172
- };
173
-
174
159
  return (
175
160
  <>
176
161
  <SlotsContainer
@@ -196,32 +181,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
196
181
  <ItemsContainer className="item-container-body">
197
182
  {onRenderSlots()}
198
183
  </ItemsContainer>
199
- {totalPages > 1 && (
200
- <ArrowContainer>
201
- {currentPage > 1 && (
202
- <SelectArrow
203
- className='arrow .arrow-up'
204
- direction="left"
205
- onPointerDown={() => {
206
- if (currentPage > 1) {
207
- goToPreviousPage();
208
- }
209
- }}
210
- />
211
- )}
212
- {currentPage < totalPages && (
213
- <SelectArrow
214
- className='arrow .arrow-down'
215
- direction="right"
216
- onPointerDown={() => {
217
- if (currentPage < totalPages) {
218
- goToNextPage();
219
- }
220
- }}
221
- />
222
- )}
223
- </ArrowContainer>
224
- )}
225
184
  </SlotsContainer>
226
185
  {quantitySelect.isOpen && (
227
186
  <ModalPortal>
@@ -233,7 +192,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
233
192
  setQuantitySelect({
234
193
  isOpen: false,
235
194
  maxQuantity: 1,
236
- callback: () => { },
195
+ callback: () => {},
237
196
  });
238
197
  }}
239
198
  onClose={() => {
@@ -241,7 +200,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
241
200
  setQuantitySelect({
242
201
  isOpen: false,
243
202
  maxQuantity: 1,
244
- callback: () => { },
203
+ callback: () => {},
245
204
  });
246
205
  }}
247
206
  />
@@ -270,17 +229,3 @@ const QuantitySelectorContainer = styled.div`
270
229
  align-items: center;
271
230
  background-color: rgba(0, 0, 0, 0.5);
272
231
  `;
273
-
274
- const ArrowContainer = styled.div`
275
- margin-top: 10px;
276
- margin-bottom: 30px;
277
- /* Aplica a margem ao primeiro span (seta para a esquerda) */
278
- span:first-child {
279
- margin-left: 20px;
280
- }
281
-
282
- /* Aplica a margem ao último span (seta para a direita) */
283
- span:last-child {
284
- margin-right: 20px;
285
- }
286
- `;
@@ -23,6 +23,7 @@ export const mockSpells: ISpell[] = [
23
23
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
24
24
  projectileAnimationKey: AnimationEffectKeys.Energy,
25
25
  usableEffect: () => {},
26
+ onlyPremiumAccountType: [],
26
27
  },
27
28
  {
28
29
  key: (SpellsBlueprint.ArrowCreationSpell + '2') as SpellsBlueprint,
@@ -41,6 +42,7 @@ export const mockSpells: ISpell[] = [
41
42
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
42
43
  projectileAnimationKey: AnimationEffectKeys.Energy,
43
44
  usableEffect: () => {},
45
+ onlyPremiumAccountType: [],
44
46
  },
45
47
  {
46
48
  key: (SpellsBlueprint.ArrowCreationSpell + '3') as SpellsBlueprint,
@@ -59,6 +61,7 @@ export const mockSpells: ISpell[] = [
59
61
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
60
62
  projectileAnimationKey: AnimationEffectKeys.Energy,
61
63
  usableEffect: () => {},
64
+ onlyPremiumAccountType: [],
62
65
  },
63
66
  {
64
67
  key: (SpellsBlueprint.ArrowCreationSpell + '4') as SpellsBlueprint,
@@ -77,6 +80,7 @@ export const mockSpells: ISpell[] = [
77
80
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
78
81
  projectileAnimationKey: AnimationEffectKeys.Energy,
79
82
  usableEffect: () => {},
83
+ onlyPremiumAccountType: [],
80
84
  },
81
85
  {
82
86
  key: (SpellsBlueprint.ArrowCreationSpell + '5') as SpellsBlueprint,
@@ -95,5 +99,6 @@ export const mockSpells: ISpell[] = [
95
99
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
96
100
  projectileAnimationKey: AnimationEffectKeys.Energy,
97
101
  usableEffect: () => {},
102
+ onlyPremiumAccountType: [],
98
103
  },
99
104
  ];
@@ -2,6 +2,7 @@ import {
2
2
  getItemTextureKeyPath,
3
3
  IEquipmentSet,
4
4
  ITradeResponseItem,
5
+ UserAccountTypes,
5
6
  } from '@rpg-engine/shared';
6
7
  import capitalize from 'lodash/capitalize';
7
8
  import React from 'react';
@@ -23,6 +24,7 @@ export interface ITradeComponentProps {
23
24
  selectedQty: number;
24
25
  equipmentSet?: IEquipmentSet | null;
25
26
  scale?: number;
27
+ isBuy?: boolean;
26
28
  }
27
29
 
28
30
  const outerQty = 10;
@@ -35,6 +37,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
35
37
  selectedQty,
36
38
  equipmentSet,
37
39
  scale,
40
+ isBuy,
38
41
  }) => {
39
42
  const onLeftClick = (qty = 1) => {
40
43
  onQuantityChange(traderItem, Math.max(0, selectedQty - qty));
@@ -47,6 +50,46 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
47
50
  );
48
51
  };
49
52
 
53
+ const renderAccountTypeIndicator = () => {
54
+ if (isBuy && traderItem.canBePurchasedOnlyByPremiumPlans) {
55
+ return traderItem.canBePurchasedOnlyByPremiumPlans.map(accountType => {
56
+ if (accountType !== UserAccountTypes.Free) {
57
+ let backgroundColor;
58
+ let textColor = 'black';
59
+
60
+ switch (accountType) {
61
+ case UserAccountTypes.PremiumBronze:
62
+ backgroundColor = '#CD7F32';
63
+ break;
64
+ case UserAccountTypes.PremiumSilver:
65
+ backgroundColor = '#C0C0C0';
66
+ break;
67
+ case UserAccountTypes.PremiumGold:
68
+ backgroundColor = '#FFD700';
69
+ break;
70
+ case UserAccountTypes.PremiumUltimate:
71
+ backgroundColor = '#002E99';
72
+ break;
73
+ default:
74
+ return null;
75
+ }
76
+
77
+ return (
78
+ <PremiumLabel
79
+ backgroundColor={backgroundColor}
80
+ textColor={textColor}
81
+ key={accountType}
82
+ >
83
+ {capitalize(accountType) + ' PA'}
84
+ </PremiumLabel>
85
+ );
86
+ }
87
+ return null;
88
+ });
89
+ }
90
+ return null;
91
+ };
92
+
50
93
  return (
51
94
  <ItemWrapper>
52
95
  <ItemIconContainer>
@@ -84,6 +127,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
84
127
  </Ellipsis>
85
128
  </p>
86
129
  <p>${traderItem.price}</p>
130
+ <p>{renderAccountTypeIndicator()}</p>
87
131
  </NameValue>
88
132
  </ItemNameContainer>
89
133
  <QuantityContainer>
@@ -121,6 +165,20 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
121
165
  );
122
166
  };
123
167
 
168
+ const PremiumLabel = styled.span<{
169
+ backgroundColor: string;
170
+ textColor: string;
171
+ }>`
172
+ background-color: ${({ backgroundColor }) => backgroundColor};
173
+ color: ${({ textColor }) => textColor};
174
+ font-weight: bold;
175
+ padding: 2px 5px;
176
+ border-radius: 5px;
177
+ margin-right: 5px;
178
+ margin-bottom: 5px;
179
+ display: inline-block;
180
+ `;
181
+
124
182
  const StyledArrow = styled(SelectArrow)`
125
183
  margin: 40px;
126
184
  `;
@@ -110,6 +110,7 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
110
110
  selectedQty={qtyMap.get(tradeItem.key) ?? 0}
111
111
  equipmentSet={equipmentSet}
112
112
  scale={scale}
113
+ isBuy={isBuy()}
113
114
  />
114
115
  </ItemWrapper>
115
116
  ))}
@@ -5,6 +5,7 @@ import {
5
5
  ItemSlotType,
6
6
  ItemSubType,
7
7
  ItemType,
8
+ UserAccountTypes,
8
9
  } from '@rpg-engine/shared';
9
10
 
10
11
  export const items: IItem[] = [
@@ -42,16 +43,20 @@ export const items: IItem[] = [
42
43
  createdAt: '2022-06-04T03:18:09.335Z',
43
44
  updatedAt: '2022-06-04T18:16:49.056Z',
44
45
  rarity: ItemRarities.Legendary,
46
+ canBePurchasedOnlyByPremiumPlans: [
47
+ UserAccountTypes.PremiumGold,
48
+ UserAccountTypes.PremiumUltimate,
49
+ ],
45
50
  minRequirements: {
46
51
  level: 10,
47
52
  skill: {
48
53
  name: 'sword',
49
54
  level: 5,
50
- }
55
+ },
51
56
  },
52
- equippedBuffDescription: "Character speed +10%",
57
+ equippedBuffDescription: 'Character speed +10%',
53
58
  entityEffectChance: 50,
54
- entityEffects: ['freezing']
59
+ entityEffects: ['freezing'],
55
60
  },
56
61
  {
57
62
  _id: '629acef1c7c8e8002ff73564',
@@ -541,43 +546,43 @@ export const items: IItem[] = [
541
546
  rarity: ItemRarities.Common,
542
547
  },
543
548
  {
544
- "type": ItemType.Consumable,
545
- "subType": ItemSubType.Food,
546
- "rarity": "Common",
547
- "textureAtlas": "items",
548
- "allowedEquipSlotType": [],
549
- "maxStackSize": 100,
550
- "isUsable": false,
551
- "isStorable": true,
552
- "isItemContainer": false,
553
- "isSolid": false,
554
- "requiredAmmoKeys": [],
555
- "isTwoHanded": false,
556
- "hasUseWith": false,
557
- "entityEffects": [],
558
- "entityEffectChance": 0,
559
- "_id": "64529049d45546003b2c6c6d",
560
- "key": "apple",
561
- "texturePath": "foods/apple.png",
549
+ type: ItemType.Consumable,
550
+ subType: ItemSubType.Food,
551
+ rarity: 'Common',
552
+ textureAtlas: 'items',
553
+ allowedEquipSlotType: [],
554
+ maxStackSize: 100,
555
+ isUsable: false,
556
+ isStorable: true,
557
+ isItemContainer: false,
558
+ isSolid: false,
559
+ requiredAmmoKeys: [],
560
+ isTwoHanded: false,
561
+ hasUseWith: false,
562
+ entityEffects: [],
563
+ entityEffectChance: 0,
564
+ _id: '64529049d45546003b2c6c6d',
565
+ key: 'apple',
566
+ texturePath: 'foods/apple.png',
562
567
  textureKey: 'apple',
563
568
  isEquipable: false,
564
569
  isStackable: true,
565
- "name": "Apple",
566
- "description": "A red apple.",
567
- "weight": 0.05,
568
- "stackQty": 16,
569
- "attack": 0,
570
- "defense": 0,
571
- fullDescription: "",
572
- usableEffectDescription: "Regenerates 10 HP and Mana 5 times"
573
- }
570
+ name: 'Apple',
571
+ description: 'A red apple.',
572
+ weight: 0.05,
573
+ stackQty: 16,
574
+ attack: 0,
575
+ defense: 0,
576
+ fullDescription: '',
577
+ usableEffectDescription: 'Regenerates 10 HP and Mana 5 times',
578
+ },
574
579
  ];
575
580
 
576
581
  export const itemContainerMock: IItemContainer = {
577
582
  _id: '629ba0b6fe3f43002f58f23b',
578
583
  name: 'Item Container',
579
584
  owner: '629ba0b6fe3f43002f58f23b',
580
- slotQty: 60,
585
+ slotQty: 20,
581
586
  slots: {
582
587
  0: items[0],
583
588
  1: items[1],
@@ -595,7 +600,6 @@ export const itemContainerMock: IItemContainer = {
595
600
  13: items[13],
596
601
  14: items[14],
597
602
  15: items[15],
598
- 21: items[15],
599
603
  //remaining slots are considered null by default
600
604
  },
601
605
  allowedItemTypes: [],