@rpg-engine/long-bow 0.5.8 → 0.5.10

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.
@@ -1,4 +1,4 @@
1
- import { TopCharacterEntry, TopSkillEntry } from '@rpg-engine/shared';
2
- export declare const leaderboardLevelRankingItems: Set<TopCharacterEntry>;
3
- export declare const leaderboardClassRankingItems: Set<TopCharacterEntry>;
4
- export declare const leaderboardSkillRankingItems: Set<TopSkillEntry>;
1
+ import { IRankingTopCharacterEntry, IRankingTopSkillEntry } from '@rpg-engine/shared';
2
+ export declare const leaderboardLevelRankingItems: Set<IRankingTopCharacterEntry>;
3
+ export declare const leaderboardClassRankingItems: Set<IRankingTopCharacterEntry>;
4
+ export declare const leaderboardSkillRankingItems: Set<IRankingTopSkillEntry>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
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.72",
86
+ "@rpg-engine/shared": "^0.8.74",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -13,6 +13,7 @@ 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';
16
17
  import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
17
18
  import { ItemSlot } from './ItemSlot';
18
19
 
@@ -81,12 +82,15 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
81
82
  onPositionChangeEnd,
82
83
  onPositionChangeStart,
83
84
  }) => {
85
+ const MAX_SLOTS_PER_PAGE = 20;
84
86
  const [quantitySelect, setQuantitySelect] = useState({
85
87
  isOpen: false,
86
88
  maxQuantity: 1,
87
- callback: (_quantity: number) => {},
89
+ callback: (_quantity: number) => { },
88
90
  });
89
91
  const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
92
+ const [currentPage, setCurrentPage] = useState(1);
93
+ const totalPages = Math.ceil(itemContainer.slotQty / MAX_SLOTS_PER_PAGE);
90
94
 
91
95
  const handleSetShortcut = (item: IItem, index: number) => {
92
96
  if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
@@ -96,8 +100,10 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
96
100
 
97
101
  const onRenderSlots = () => {
98
102
  const slots = [];
103
+ const start = (currentPage - 1) * MAX_SLOTS_PER_PAGE;
104
+ const end = start + MAX_SLOTS_PER_PAGE;
99
105
 
100
- for (let i = 0; i < itemContainer.slotQty; i++) {
106
+ for (let i = start; i < end && i < itemContainer.slotQty; i++) {
101
107
  slots.push(
102
108
  <ItemSlot
103
109
  isContextMenuDisabled={disableContextMenu}
@@ -156,6 +162,14 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
156
162
  return slots;
157
163
  };
158
164
 
165
+ const goToNextPage = () => {
166
+ setCurrentPage(current => Math.min(current + 1, totalPages));
167
+ };
168
+
169
+ const goToPreviousPage = () => {
170
+ setCurrentPage(current => Math.max(current - 1, 1));
171
+ };
172
+
159
173
  return (
160
174
  <>
161
175
  <SlotsContainer
@@ -181,6 +195,28 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
181
195
  <ItemsContainer className="item-container-body">
182
196
  {onRenderSlots()}
183
197
  </ItemsContainer>
198
+ {totalPages > 1 && (
199
+ <ArrowContainer>
200
+ <SelectArrow
201
+ className='arrow .arrow-up'
202
+ direction="left"
203
+ onPointerDown={() => {
204
+ if (currentPage > 1) {
205
+ goToPreviousPage();
206
+ }
207
+ }}
208
+ />
209
+ <SelectArrow
210
+ className='arrow .arrow-down'
211
+ direction="right"
212
+ onPointerDown={() => {
213
+ if (currentPage < totalPages) {
214
+ goToNextPage();
215
+ }
216
+ }}
217
+ />
218
+ </ArrowContainer>
219
+ )}
184
220
  </SlotsContainer>
185
221
  {quantitySelect.isOpen && (
186
222
  <ModalPortal>
@@ -192,7 +228,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
192
228
  setQuantitySelect({
193
229
  isOpen: false,
194
230
  maxQuantity: 1,
195
- callback: () => {},
231
+ callback: () => { },
196
232
  });
197
233
  }}
198
234
  onClose={() => {
@@ -200,7 +236,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
200
236
  setQuantitySelect({
201
237
  isOpen: false,
202
238
  maxQuantity: 1,
203
- callback: () => {},
239
+ callback: () => { },
204
240
  });
205
241
  }}
206
242
  />
@@ -229,3 +265,17 @@ const QuantitySelectorContainer = styled.div`
229
265
  align-items: center;
230
266
  background-color: rgba(0, 0, 0, 0.5);
231
267
  `;
268
+
269
+ const ArrowContainer = styled.div`
270
+ margin-top: 10px;
271
+ margin-bottom: 30px;
272
+ /* Aplica a margem ao primeiro span (seta para a esquerda) */
273
+ span:first-child {
274
+ margin-left: 20px;
275
+ }
276
+
277
+ /* Aplica a margem ao último span (seta para a direita) */
278
+ span:last-child {
279
+ margin-right: 20px;
280
+ }
281
+ `;
@@ -1,46 +1,63 @@
1
- import { CharacterClass, TopCharacterEntry, TopSkillEntry } from '@rpg-engine/shared';
1
+ import {
2
+ IRankingTopCharacterEntry,
3
+ IRankingTopSkillEntry,
4
+ } from '@rpg-engine/shared';
2
5
  import React, { useEffect, useRef } from 'react';
3
6
  import styled from 'styled-components';
4
7
  import { Dropdown, IOptionsProps } from '../Dropdown';
5
8
  import { LeaderboardTable } from './LeaderboardTable';
6
9
 
7
-
8
10
  export interface ILeaderboardProps {
9
- items: Set<TopCharacterEntry> | Set<TopSkillEntry> | null;
11
+ items: Set<IRankingTopCharacterEntry> | Set<IRankingTopSkillEntry> | null;
10
12
  onChangeClassType: (value: string) => void;
11
13
  onChangeRankType: (value: string) => void;
12
14
  onChangeSkillType: (value: string) => void;
13
- skills: string[];
15
+ skillOptions: string[];
16
+ rankOptions: string[];
17
+ classOptions: string[];
14
18
  rankType: string;
15
19
  }
16
20
 
17
- const rankTypeOptions: IOptionsProps[] = ['Level', 'Class', 'Skill'].map(
18
- (itemType, index) => ({
19
- id: index + 1,
20
- value: itemType,
21
- option: itemType,
22
- })
23
- );
24
-
25
- const classTypeOptions: IOptionsProps[] = Object.keys(CharacterClass).map((itemType, index) => ({
26
- id: index + 1,
27
- value: itemType,
28
- option: itemType,
29
- }));
30
-
31
21
  export const Leaderboard = (props: ILeaderboardProps) => {
32
- const { items, onChangeRankType, onChangeClassType, rankType, skills, onChangeSkillType } = props;
22
+ const {
23
+ items,
24
+ onChangeRankType,
25
+ onChangeClassType,
26
+ rankType,
27
+ skillOptions,
28
+ onChangeSkillType,
29
+ classOptions,
30
+ rankOptions,
31
+ } = props;
33
32
  const itemsContainer = useRef<HTMLDivElement>(null);
34
33
 
35
34
  useEffect(() => {
36
35
  itemsContainer.current?.scrollTo(0, 0);
37
36
  }, []);
38
37
 
39
- const skillTypeOptions: IOptionsProps[] = skills.map((itemType, index) => ({
40
- id: index + 1,
41
- value: itemType,
42
- option: itemType,
43
- }));
38
+ const rankTypeOptions: IOptionsProps[] = rankOptions.map(
39
+ (itemType, index) => ({
40
+ id: index + 1,
41
+ value: itemType,
42
+ option: itemType,
43
+ })
44
+ );
45
+
46
+ const skillTypeOptions: IOptionsProps[] = skillOptions.map(
47
+ (itemType, index) => ({
48
+ id: index + 1,
49
+ value: itemType,
50
+ option: itemType,
51
+ })
52
+ );
53
+
54
+ const classTypeOptions: IOptionsProps[] = classOptions.map(
55
+ (itemType, index) => ({
56
+ id: index + 1,
57
+ value: itemType,
58
+ option: itemType,
59
+ })
60
+ );
44
61
 
45
62
  return (
46
63
  <>
@@ -1,11 +1,14 @@
1
- import { TopCharacterEntry, TopSkillEntry } from '@rpg-engine/shared';
1
+ import {
2
+ IRankingTopCharacterEntry,
3
+ IRankingTopSkillEntry,
4
+ } from '@rpg-engine/shared';
2
5
  import React from 'react';
3
6
  import styled from 'styled-components';
4
7
  import { uiColors } from '../../constants/uiColors';
5
8
  import { Ellipsis } from '../shared/Ellipsis';
6
9
 
7
10
  export interface ILeaderboardLevelProps {
8
- items: Set<TopCharacterEntry> | Set<TopSkillEntry> | null;
11
+ items: Set<IRankingTopCharacterEntry> | Set<IRankingTopSkillEntry> | null;
9
12
  rankType: string;
10
13
  }
11
14
 
@@ -13,7 +16,7 @@ export const LeaderboardTable: React.FC<ILeaderboardLevelProps> = props => {
13
16
  const { items, rankType } = props;
14
17
  if (!items) return null;
15
18
 
16
- function isTopSkillEntry(entry: any): entry is TopSkillEntry {
19
+ function isTopSkillEntry(entry: any): entry is IRankingTopSkillEntry {
17
20
  return 'skill' in entry;
18
21
  }
19
22
 
@@ -577,7 +577,7 @@ export const itemContainerMock: IItemContainer = {
577
577
  _id: '629ba0b6fe3f43002f58f23b',
578
578
  name: 'Item Container',
579
579
  owner: '629ba0b6fe3f43002f58f23b',
580
- slotQty: 20,
580
+ slotQty: 60,
581
581
  slots: {
582
582
  0: items[0],
583
583
  1: items[1],
@@ -595,6 +595,7 @@ export const itemContainerMock: IItemContainer = {
595
595
  13: items[13],
596
596
  14: items[14],
597
597
  15: items[15],
598
+ 21: items[15],
598
599
  //remaining slots are considered null by default
599
600
  },
600
601
  allowedItemTypes: [],
@@ -1,110 +1,119 @@
1
- import { TopCharacterEntry, TopSkillEntry } from '@rpg-engine/shared';
1
+ import {
2
+ IRankingTopCharacterEntry,
3
+ IRankingTopSkillEntry,
4
+ } from '@rpg-engine/shared';
2
5
 
3
- export const leaderboardLevelRankingItems: Set<TopCharacterEntry> = new Set([
4
- {
5
- name: 'Player 1',
6
- level: 1,
7
- },
8
- {
9
- name: 'Player 2',
10
- level: 2,
11
- },
12
- {
13
- name: 'Player 3',
14
- level: 3,
15
- },
16
- {
17
- name: 'Player 4',
18
- level: 4,
19
- },
20
- {
21
- name: 'Player 5',
22
- level: 5,
23
- },
24
- {
25
- name: 'Player 6',
26
- level: 6,
27
- },
28
- {
29
- name: 'Player 7',
30
- level: 7,
31
- },
32
- {
33
- name: 'Player 8',
34
- level: 8,
35
- },
36
- {
37
- name: 'Player 9',
38
- level: 9,
39
- },
40
- {
41
- name: 'Player 10',
42
- level: 10,
43
- },
44
- ]);
6
+ export const leaderboardLevelRankingItems: Set<IRankingTopCharacterEntry> = new Set(
7
+ [
8
+ {
9
+ name: 'Player 1',
10
+ level: 1,
11
+ },
12
+ {
13
+ name: 'Player 2',
14
+ level: 2,
15
+ },
16
+ {
17
+ name: 'Player 3',
18
+ level: 3,
19
+ },
20
+ {
21
+ name: 'Player 4',
22
+ level: 4,
23
+ },
24
+ {
25
+ name: 'Player 5',
26
+ level: 5,
27
+ },
28
+ {
29
+ name: 'Player 6',
30
+ level: 6,
31
+ },
32
+ {
33
+ name: 'Player 7',
34
+ level: 7,
35
+ },
36
+ {
37
+ name: 'Player 8',
38
+ level: 8,
39
+ },
40
+ {
41
+ name: 'Player 9',
42
+ level: 9,
43
+ },
44
+ {
45
+ name: 'Player 10',
46
+ level: 10,
47
+ },
48
+ ]
49
+ );
45
50
 
46
- export const leaderboardClassRankingItems: Set<TopCharacterEntry> = new Set([
47
- {
48
- name: 'Player 1',
49
- level: 1,
50
- },
51
- {
52
- name: 'Player 2',
53
- level: 2,
54
- },
55
- {
56
- name: 'Player 3',
57
- level: 3,
58
- },
59
- {
60
- name: 'Player 4',
61
- level: 4,
62
- },
63
- {
64
- name: 'Player 5',
65
- level: 5,
66
- },
67
- {
68
- name: 'Player 6',
69
- level: 6,
70
- },
71
- {
72
- name: 'Player 7',
73
- level: 7,
74
- },
75
- {
76
- name: 'Player 8',
77
- level: 8,
78
- },
79
- {
80
- name: 'Player 9',
81
- level: 9,
82
- },
83
- {
84
- name: 'Player 10',
85
- level: 10,
86
- },
87
- ]);
51
+ export const leaderboardClassRankingItems: Set<IRankingTopCharacterEntry> = new Set(
52
+ [
53
+ {
54
+ name: 'Player 1',
55
+ level: 1,
56
+ },
57
+ {
58
+ name: 'Player 2',
59
+ level: 2,
60
+ },
61
+ {
62
+ name: 'Player 3',
63
+ level: 3,
64
+ },
65
+ {
66
+ name: 'Player 4',
67
+ level: 4,
68
+ },
69
+ {
70
+ name: 'Player 5',
71
+ level: 5,
72
+ },
73
+ {
74
+ name: 'Player 6',
75
+ level: 6,
76
+ },
77
+ {
78
+ name: 'Player 7',
79
+ level: 7,
80
+ },
81
+ {
82
+ name: 'Player 8',
83
+ level: 8,
84
+ },
85
+ {
86
+ name: 'Player 9',
87
+ level: 9,
88
+ },
89
+ {
90
+ name: 'Player 10',
91
+ level: 10,
92
+ },
93
+ ]
94
+ );
88
95
 
89
- export const leaderboardSkillRankingItems: Set<TopSkillEntry> = new Set([
90
- {
91
- name: 'Player 1',
92
- level: 1,
93
- skill: 'skill 1',
94
- },
95
- {
96
- name: 'Player 2',
97
- level: 2,
98
- skill: 'skill 2',
99
- },
100
- {
101
- name: 'Player 3',
102
- level: 3,
103
- skill: 'skill 3',
104
- },
105
- {
106
- name: 'Player 4',
107
- level: 4,
108
- skill: 'skill 4',
109
- },
110
- ]);
96
+ export const leaderboardSkillRankingItems: Set<IRankingTopSkillEntry> = new Set(
97
+ [
98
+ {
99
+ name: 'Player 1',
100
+ level: 1,
101
+ skill: 'skill 1',
102
+ },
103
+ {
104
+ name: 'Player 2',
105
+ level: 2,
106
+ skill: 'skill 2',
107
+ },
108
+ {
109
+ name: 'Player 3',
110
+ level: 3,
111
+ skill: 'skill 3',
112
+ },
113
+ {
114
+ name: 'Player 4',
115
+ level: 4,
116
+ skill: 'skill 4',
117
+ },
118
+ ]
119
+ );
@@ -31,9 +31,11 @@ export const Default = Template.bind({});
31
31
  Default.args = {
32
32
  items: leaderboardLevelRankingItems,
33
33
  rankType: 'Level',
34
- skills: ['Lumbarjacking'],
35
- onChangeRankType: () => { },
36
- onChangeClassType: () => { },
34
+ skillOptions: ['Lumbarjacking'],
35
+ classOptions: ['Warrior'],
36
+ rankOptions: ['Level', 'Class', 'Skill'],
37
+ onChangeRankType: () => {},
38
+ onChangeClassType: () => {},
37
39
  };
38
40
 
39
41
  export const ClassRanking = Template.bind({});
@@ -41,9 +43,11 @@ export const ClassRanking = Template.bind({});
41
43
  ClassRanking.args = {
42
44
  items: leaderboardClassRankingItems,
43
45
  rankType: 'Class',
44
- skills: ['Lumbarjacking'],
45
- onChangeRankType: () => { },
46
- onChangeClassType: () => { },
46
+ skillOptions: ['Lumbarjacking'],
47
+ classOptions: ['Warrior'],
48
+ rankOptions: ['Level', 'Class', 'Skill'],
49
+ onChangeRankType: () => {},
50
+ onChangeClassType: () => {},
47
51
  };
48
52
 
49
53
  export const SkillRanking = Template.bind({});
@@ -51,7 +55,9 @@ export const SkillRanking = Template.bind({});
51
55
  SkillRanking.args = {
52
56
  items: leaderboardSkillRankingItems,
53
57
  rankType: 'Skill',
54
- skills: ['Lumbarjacking'],
55
- onChangeRankType: () => { },
56
- onChangeClassType: () => { },
57
- };
58
+ skillOptions: ['Lumbarjacking'],
59
+ classOptions: ['Warrior'],
60
+ rankOptions: ['Level', 'Class', 'Skill'],
61
+ onChangeRankType: () => {},
62
+ onChangeClassType: () => {},
63
+ };