@rpg-engine/long-bow 0.1.66 → 0.1.69

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 (35) hide show
  1. package/dist/components/DraggableContainer.d.ts +4 -1
  2. package/dist/components/Item/Inventory/ItemContainer.d.ts +7 -3
  3. package/dist/components/Item/Inventory/ItemSlot.d.ts +3 -2
  4. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +7 -0
  5. package/dist/components/Item/SpriteFromAtlas.d.ts +2 -0
  6. package/dist/components/SimpleProgressBar.d.ts +3 -4
  7. package/dist/components/SkillProgressBar.d.ts +6 -4
  8. package/dist/components/SkillsContainer.d.ts +7 -0
  9. package/dist/constants/uiColors.d.ts +7 -0
  10. package/dist/hooks/useOutsideAlerter.d.ts +1 -0
  11. package/dist/long-bow.cjs.development.js +4221 -644
  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 +4223 -646
  16. package/dist/long-bow.esm.js.map +1 -1
  17. package/dist/mocks/skills.mocks.d.ts +115 -0
  18. package/dist/types/eventTypes.d.ts +4 -0
  19. package/package.json +7 -7
  20. package/src/components/DraggableContainer.tsx +20 -5
  21. package/src/components/I_Book.png +0 -0
  22. package/src/components/Item/Cards/ItemCard.tsx +7 -1
  23. package/src/components/Item/Inventory/ItemContainer.tsx +141 -136
  24. package/src/components/Item/Inventory/ItemSlot.tsx +24 -9
  25. package/src/components/Item/Inventory/itemContainerHelper.ts +44 -0
  26. package/src/components/Item/SpriteFromAtlas.tsx +10 -0
  27. package/src/components/SimpleProgressBar.tsx +14 -10
  28. package/src/components/SkillProgressBar.tsx +74 -20
  29. package/src/components/SkillsContainer.tsx +235 -0
  30. package/src/constants/uiColors.ts +7 -0
  31. package/src/hooks/useOutsideAlerter.ts +25 -0
  32. package/src/mocks/atlas/items/items.json +3920 -460
  33. package/src/mocks/atlas/items/items.png +0 -0
  34. package/src/mocks/skills.mocks.ts +116 -0
  35. package/src/types/eventTypes.ts +4 -0
@@ -1,42 +1,99 @@
1
+ import { getSPForLevel } from '@rpg-engine/shared';
1
2
  import React from 'react';
2
3
  import styled from 'styled-components';
3
- import imgSrcTemplate from './imgExp.png';
4
+ import atlasJSON from '../mocks/atlas/items/items.json';
5
+ import atlasIMG from '../mocks/atlas/items/items.png';
6
+ import { SpriteFromAtlas } from './Item/SpriteFromAtlas';
4
7
  import { SimpleProgressBar } from './SimpleProgressBar';
5
8
 
6
9
  export interface ISkillProgressBarProps {
7
- value: number;
8
-
9
- height: string;
10
+ skillName: string;
10
11
  bgColor: string;
11
- titleName: string;
12
-
13
- logoSrc?: string;
12
+ level: number;
13
+ skillPoints: number;
14
+ skillPointsToNextLevel?: number;
15
+ texturePath: string;
16
+ showSkillPoints?: boolean;
14
17
  }
15
18
 
16
19
  export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
17
- value,
18
20
  bgColor,
19
- titleName,
20
-
21
- logoSrc = imgSrcTemplate,
21
+ skillName,
22
+ level,
23
+ skillPoints,
24
+ texturePath,
25
+ showSkillPoints = true,
22
26
  }) => {
27
+ const spForNextLevel = getSPForLevel(level + 1);
28
+
29
+ const ratio = (skillPoints / spForNextLevel) * 100;
30
+
23
31
  return (
24
32
  <>
25
33
  <ProgressTitle>
26
- <TitleName>{titleName}</TitleName>
27
- <ValueDisplay>{value}</ValueDisplay>
34
+ <TitleName>{skillName}</TitleName>
35
+ <ValueDisplay>lv {level}</ValueDisplay>
28
36
  </ProgressTitle>
29
37
  <ProgressBody>
30
38
  <ProgressIconContainer>
31
- <Icon src={logoSrc} />
39
+ {atlasIMG && atlasJSON ? (
40
+ <SpriteContainer>
41
+ <SpriteFromAtlas
42
+ atlasIMG={atlasIMG}
43
+ atlasJSON={atlasJSON}
44
+ spriteKey={texturePath}
45
+ scale={1}
46
+ grayScale
47
+ opacity={0.5}
48
+ />
49
+ </SpriteContainer>
50
+ ) : (
51
+ <></>
52
+ )}
32
53
  </ProgressIconContainer>
33
54
 
34
- <SimpleProgressBar value={value} bgColor={bgColor} />
55
+ <ProgressBarContainer>
56
+ <SimpleProgressBar value={ratio} bgColor={bgColor} />
57
+ </ProgressBarContainer>
35
58
  </ProgressBody>
59
+ {showSkillPoints && (
60
+ <SkillDisplayContainer>
61
+ <SkillPointsDisplay>
62
+ {skillPoints}/{spForNextLevel}
63
+ </SkillPointsDisplay>
64
+ </SkillDisplayContainer>
65
+ )}
36
66
  </>
37
67
  );
38
68
  };
39
69
 
70
+ const ProgressBarContainer = styled.div`
71
+ position: relative;
72
+ top: 8px;
73
+ width: 100%;
74
+ height: auto;
75
+ `;
76
+
77
+ const SpriteContainer = styled.div`
78
+ position: relative;
79
+ top: -3px;
80
+ left: 0;
81
+ `;
82
+
83
+ const SkillDisplayContainer = styled.div`
84
+ margin: 5px auto;
85
+
86
+ p {
87
+ margin: 0;
88
+ }
89
+ `;
90
+
91
+ const SkillPointsDisplay = styled.p`
92
+ font-size: 0.6rem !important;
93
+ font-weight: bold;
94
+ text-align: center;
95
+ `;
96
+
40
97
  const TitleName = styled.span`
41
98
  margin-left: 5px;
42
99
  `;
@@ -52,6 +109,7 @@ const ProgressIconContainer = styled.div`
52
109
  const ProgressBody = styled.div`
53
110
  display: flex;
54
111
  flex-direction: row;
112
+ width: 100%;
55
113
  `;
56
114
 
57
115
  const ProgressTitle = styled.div`
@@ -62,9 +120,5 @@ const ProgressTitle = styled.div`
62
120
  span {
63
121
  font-size: 0.6rem;
64
122
  }
65
- `;
66
-
67
- const Icon = styled.img`
68
- margin-right: 10px;
69
- height: 30px;
123
+ margin-top: 10px;
70
124
  `;
@@ -0,0 +1,235 @@
1
+ import { ISkill } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { colors } from '../constants/uiColors';
5
+ import { DraggableContainer } from './DraggableContainer';
6
+ import { SkillProgressBar } from './SkillProgressBar';
7
+
8
+ export interface ISkillContainerProps {
9
+ skill: ISkill;
10
+ onCloseButton: () => void;
11
+ }
12
+
13
+ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
14
+ onCloseButton,
15
+ skill,
16
+ }) => {
17
+ return (
18
+ <SkillsDraggableContainer title="Skills" onCloseButton={onCloseButton}>
19
+ <SkillSplitDiv>
20
+ <p>Combat Skills</p>
21
+ <hr className="golden" />
22
+ </SkillSplitDiv>
23
+ <SkillProgressBar
24
+ skillName={'First'}
25
+ bgColor={colors.cardinal}
26
+ level={skill?.first?.level || 0}
27
+ skillPoints={skill?.first?.skillPoints || 0}
28
+ skillPointsToNextLevel={skill?.first?.skillPointsToNextLevel || 0}
29
+ texturePath={'gloves/leather-gloves.png'}
30
+ />
31
+ <SkillProgressBar
32
+ skillName={'Club'}
33
+ bgColor={colors.cardinal}
34
+ level={skill?.club?.level || 0}
35
+ skillPoints={skill?.club?.skillPoints || 0}
36
+ skillPointsToNextLevel={skill?.club?.skillPointsToNextLevel || 0}
37
+ texturePath={'maces/club.png'}
38
+ />
39
+ <SkillProgressBar
40
+ skillName={'Sword'}
41
+ bgColor={colors.cardinal}
42
+ level={skill?.sword?.level || 0}
43
+ skillPoints={skill?.sword?.skillPoints || 0}
44
+ skillPointsToNextLevel={skill?.sword?.skillPointsToNextLevel || 0}
45
+ texturePath={'swords/double-edged-sword.png'}
46
+ />
47
+ <SkillProgressBar
48
+ skillName={'Axe'}
49
+ bgColor={colors.cardinal}
50
+ level={skill?.axe?.level || 0}
51
+ skillPoints={skill?.axe?.skillPoints || 0}
52
+ skillPointsToNextLevel={skill?.axe?.skillPointsToNextLevel || 0}
53
+ texturePath={'axes/double-axe.png'}
54
+ />
55
+ <SkillProgressBar
56
+ skillName={'Distance'}
57
+ bgColor={colors.cardinal}
58
+ level={skill?.distance?.level || 0}
59
+ skillPoints={skill?.distance?.skillPoints || 0}
60
+ skillPointsToNextLevel={skill?.distance?.skillPointsToNextLevel || 0}
61
+ texturePath={'bows/horse-bow.png'}
62
+ />
63
+ <SkillProgressBar
64
+ skillName={'Shielding'}
65
+ bgColor={colors.cardinal}
66
+ level={skill?.shielding?.level || 0}
67
+ skillPoints={skill?.shielding?.skillPoints || 0}
68
+ skillPointsToNextLevel={skill?.shielding?.skillPointsToNextLevel || 0}
69
+ texturePath={'shields/studded-shield.png'}
70
+ />
71
+ <SkillSplitDiv>
72
+ <p>Crafting Skills</p>
73
+ <hr className="golden" />
74
+ </SkillSplitDiv>
75
+ <SkillProgressBar
76
+ skillName={'Fishing'}
77
+ bgColor={colors.blue}
78
+ level={skill?.fishing?.level || 0}
79
+ skillPoints={skill?.fishing?.skillPoints || 0}
80
+ skillPointsToNextLevel={skill?.fishing?.skillPointsToNextLevel || 0}
81
+ texturePath={'foods/fish.png'}
82
+ />
83
+ <SkillProgressBar
84
+ skillName={'Mining'}
85
+ bgColor={colors.blue}
86
+ level={skill?.mining?.level || 0}
87
+ skillPoints={skill?.mining?.skillPoints || 0}
88
+ skillPointsToNextLevel={skill?.mining?.skillPointsToNextLevel || 0}
89
+ texturePath={'crafting-resources/iron-ingot.png'}
90
+ />
91
+ <SkillProgressBar
92
+ skillName={'Lumberjacking'}
93
+ bgColor={colors.blue}
94
+ level={skill?.lumberjacking?.level || 0}
95
+ skillPoints={skill?.lumberjacking?.skillPoints || 0}
96
+ skillPointsToNextLevel={
97
+ skill?.lumberjacking?.skillPointsToNextLevel || 0
98
+ }
99
+ texturePath={'crafting-resources/greater-wood-log.png'}
100
+ />
101
+ <SkillProgressBar
102
+ skillName={'Cooking'}
103
+ bgColor={colors.blue}
104
+ level={skill?.cooking?.level || 0}
105
+ skillPoints={skill?.cooking?.skillPoints || 0}
106
+ skillPointsToNextLevel={skill?.cooking?.skillPointsToNextLevel || 0}
107
+ texturePath={'foods/chickens-meat.png'}
108
+ />
109
+ <SkillProgressBar
110
+ skillName={'Alchemy'}
111
+ bgColor={colors.blue}
112
+ level={skill?.alchemy?.level || 0}
113
+ skillPoints={skill?.alchemy?.skillPoints || 0}
114
+ skillPointsToNextLevel={skill?.alchemy?.skillPointsToNextLevel || 0}
115
+ texturePath={'potions/greater-mana-potion.png'}
116
+ />
117
+
118
+ <SkillSplitDiv>
119
+ <p>Basic Attributes</p>
120
+ <hr className="golden" />
121
+ </SkillSplitDiv>
122
+ <SkillProgressBar
123
+ skillName={'Stamina'}
124
+ bgColor={colors.darkYellow}
125
+ level={skill?.stamina?.level || 0}
126
+ skillPoints={skill?.stamina?.skillPoints || 0}
127
+ skillPointsToNextLevel={skill?.stamina?.skillPointsToNextLevel || 0}
128
+ texturePath={'spell-icons/regenerate.png'}
129
+ />
130
+ <SkillProgressBar
131
+ skillName={'Magic'}
132
+ bgColor={colors.purple}
133
+ level={skill?.magic?.level || 0}
134
+ skillPoints={skill?.magic?.skillPoints || 0}
135
+ skillPointsToNextLevel={skill?.magic?.skillPointsToNextLevel || 0}
136
+ texturePath={'spell-icons/fireball.png'}
137
+ />
138
+ <SkillProgressBar
139
+ skillName={'Magic Resistance'}
140
+ bgColor={colors.navyBlue}
141
+ level={skill?.magicResistance?.level || 0}
142
+ skillPoints={skill?.magicResistance?.skillPoints || 0}
143
+ skillPointsToNextLevel={
144
+ skill?.magicResistance?.skillPointsToNextLevel || 0
145
+ }
146
+ texturePath={'spell-icons/freeze.png'}
147
+ />
148
+ <SkillProgressBar
149
+ skillName={'Strength'}
150
+ bgColor={colors.cardinal}
151
+ level={skill?.strength?.level || 0}
152
+ skillPoints={skill?.strength?.skillPoints || 0}
153
+ skillPointsToNextLevel={skill?.strength?.skillPointsToNextLevel || 0}
154
+ texturePath={'spell-icons/enchanted-blow.png'}
155
+ />
156
+ <SkillProgressBar
157
+ skillName={'Resistance'}
158
+ bgColor={colors.raisinBlack}
159
+ level={skill?.resistance?.level || 0}
160
+ skillPoints={skill?.resistance?.skillPoints || 0}
161
+ skillPointsToNextLevel={skill?.resistance?.skillPointsToNextLevel || 0}
162
+ texturePath={'spell-icons/magic-shield.png'}
163
+ />
164
+ <SkillProgressBar
165
+ skillName={'Dexterity'}
166
+ bgColor={colors.blue}
167
+ level={skill?.dexterity?.level || 0}
168
+ skillPoints={skill?.dexterity?.skillPoints || 0}
169
+ skillPointsToNextLevel={skill?.dexterity?.skillPointsToNextLevel || 0}
170
+ texturePath={'spell-icons/haste.png'}
171
+ />
172
+
173
+ {/* <SkillSplitDiv>
174
+ <p>Magic Skills</p>
175
+ <hr className="golden" />
176
+ </SkillSplitDiv>
177
+ <SkillProgressBar
178
+ skillName={'Ice'}
179
+ bgColor={'red'}
180
+ level={skill?.ice?.level || 0}
181
+ skillPoints={skill?.ice?.skillPoints || 0}
182
+ skillPointsToNextLevel={skill?.ice?.skillPointsToNextLevel || 0}
183
+ texturePath={'spell-icons/freeze.png'}
184
+ />
185
+ <SkillProgressBar
186
+ skillName={'Earth'}
187
+ bgColor={'red'}
188
+ level={skill?.earth?.level || 0}
189
+ skillPoints={skill?.earth?.skillPoints || 0}
190
+ skillPointsToNextLevel={skill?.earth?.skillPointsToNextLevel || 0}
191
+ texturePath={'spell-icons/earth-barrier.png'}
192
+ />
193
+ <SkillProgressBar
194
+ skillName={'Air'}
195
+ bgColor={'red'}
196
+ level={skill?.air?.level || 0}
197
+ skillPoints={skill?.air?.skillPoints || 0}
198
+ skillPointsToNextLevel={skill?.air?.skillPointsToNextLevel || 0}
199
+ texturePath={'spell-icons/poison-tornado.png'}
200
+ />
201
+ <SkillProgressBar
202
+ skillName={'Water'}
203
+ bgColor={'red'}
204
+ level={skill?.water?.level || 0}
205
+ skillPoints={skill?.water?.skillPoints || 0}
206
+ skillPointsToNextLevel={skill?.water?.skillPointsToNextLevel || 0}
207
+ texturePath={'spell-icons/tsunami.png'}
208
+ /> */}
209
+ </SkillsDraggableContainer>
210
+ );
211
+ };
212
+
213
+ const SkillsDraggableContainer = styled(DraggableContainer)`
214
+ border: 1px solid black;
215
+ width: 400px;
216
+ height: 800px;
217
+ overflow-y: scroll;
218
+ .DraggableContainer__TitleContainer-sc-184mpyl-2 {
219
+ width: auto;
220
+ height: auto;
221
+ }
222
+ `;
223
+
224
+ const SkillSplitDiv = styled.div`
225
+ width: 100%;
226
+ font-size: 11px;
227
+ margin-top: 10px;
228
+ hr {
229
+ margin: 0px;
230
+ padding: 0px;
231
+ }
232
+ p {
233
+ margin-bottom: 0px;
234
+ }
235
+ `;
@@ -1,3 +1,10 @@
1
1
  export const colors = {
2
2
  darkGrey: '#3e3e3e',
3
+ darkYellow: '#FFC857',
4
+ orange: '#E9724C',
5
+ cardinal: '#C5283D',
6
+ raisinBlack: '#191923',
7
+ navyBlue: '#0E79B2',
8
+ purple: '#8C3D8C',
9
+ blue: '#3772FF',
3
10
  };
@@ -0,0 +1,25 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export function useOutsideClick(ref: any, id: string) {
4
+ useEffect(() => {
5
+ /**
6
+ * Alert if clicked on outside of element
7
+ */
8
+ function handleClickOutside(event: any) {
9
+ if (ref.current && !ref.current.contains(event.target)) {
10
+ const event = new CustomEvent('clickOutside', {
11
+ detail: {
12
+ id,
13
+ },
14
+ });
15
+ document.dispatchEvent(event);
16
+ }
17
+ }
18
+ // Bind the event listener
19
+ document.addEventListener('mousedown', handleClickOutside);
20
+ return () => {
21
+ // Unbind the event listener on clean up
22
+ document.removeEventListener('mousedown', handleClickOutside);
23
+ };
24
+ }, [ref]);
25
+ }