@rpg-engine/long-bow 0.6.0 → 0.6.1

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.6.0",
3
+ "version": "0.6.1",
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.9.32",
86
+ "@rpg-engine/shared": "^0.9.52",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { uiFonts } from '../../../constants/uiFonts';
4
+ import { Ellipsis } from '../../shared/Ellipsis';
5
+
6
+ interface IProps {
7
+ itemId: string;
8
+ gemQty: number;
9
+ qtyClassName: string;
10
+ }
11
+
12
+ export const onRenderGems = (itemId: string, gemQty: number) => {
13
+ let qtyClassName = 'small';
14
+ if (gemQty <= 2) {
15
+ qtyClassName = 'regular';
16
+ }
17
+
18
+ if (gemQty > 0) {
19
+ return (
20
+ <ItemSlotQty
21
+ itemId={itemId}
22
+ gemQty={gemQty}
23
+ qtyClassName={qtyClassName}
24
+ />
25
+ );
26
+ }
27
+ return undefined;
28
+ };
29
+
30
+ export const ItemSlotQty = ({
31
+ itemId,
32
+ gemQty,
33
+ qtyClassName,
34
+ }: IProps): JSX.Element => {
35
+ const gemArray = Array.from({ length: gemQty }, () => '🔶');
36
+
37
+ return (
38
+ <ItemQtyContainer key={`qty-${itemId}`} className="item-slot-qty">
39
+ <Ellipsis maxLines={1} maxWidth="48px">
40
+ <ItemQty className={qtyClassName}>{gemArray.join('')}</ItemQty>
41
+ </Ellipsis>
42
+ </ItemQtyContainer>
43
+ );
44
+ };
45
+
46
+ const ItemQtyContainer = styled.div`
47
+ position: relative;
48
+ width: 85%;
49
+ height: 16px;
50
+ top: 25px;
51
+ left: 5px;
52
+ pointer-events: none;
53
+
54
+ display: flex;
55
+ `;
56
+
57
+ const ItemQty = styled.span`
58
+ &.regular {
59
+ font-size: ${uiFonts.size.small};
60
+ }
61
+ &.small {
62
+ font-size: ${uiFonts.size.xsmall};
63
+ }
64
+ `;
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import { v4 as uuidv4 } from 'uuid';
9
9
  import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
10
10
  import { ErrorBoundary } from './ErrorBoundary';
11
+ import { onRenderGems } from './ItemGem';
11
12
  import { EquipmentSlotSpriteByType } from './ItemSlot';
12
13
  import { onRenderStackInfo } from './ItemSlotQty/ItemSlotQty';
13
14
 
@@ -26,6 +27,20 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
26
27
  slotSpriteMask,
27
28
  item,
28
29
  }) => {
30
+ const renderStackInfo = (item: IItem) => {
31
+ return (
32
+ item.stackQty &&
33
+ item.stackQty > 1 &&
34
+ onRenderStackInfo(item._id, item.stackQty)
35
+ );
36
+ };
37
+
38
+ const renderGems = (item: IItem) => {
39
+ return (
40
+ item.attachedGems && onRenderGems(item._id, item.attachedGems.length)
41
+ );
42
+ };
43
+
29
44
  const renderItem = (item: IItem | null) => {
30
45
  if (!item?.texturePath) {
31
46
  return null;
@@ -48,7 +63,8 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
48
63
  imgScale={3}
49
64
  imgClassname="sprite-from-atlas-img--item"
50
65
  />
51
- {onRenderStackInfo(item._id, item.stackQty ?? 0)}
66
+ {renderStackInfo(item)}
67
+ {renderGems(item)}
52
68
  </ErrorBoundary>
53
69
  );
54
70
  };
@@ -117,7 +117,7 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
117
117
  </TradingComponentScrollWrapper>
118
118
  <GoldWrapper>
119
119
  <p>Available Gold:</p>
120
- <p>${characterAvailableGold.toFixed(2)}</p>
120
+ <p>${characterAvailableGold}</p>
121
121
  </GoldWrapper>
122
122
  <TotalWrapper>
123
123
  <p>Total:</p>
@@ -130,7 +130,7 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
130
130
  ) : (
131
131
  <GoldWrapper>
132
132
  <p>Final Gold:</p>
133
- <p>${getFinalGold().toFixed(2)}</p>
133
+ <p>${getFinalGold()}</p>
134
134
  </GoldWrapper>
135
135
  )}
136
136
 
package/src/index.tsx CHANGED
@@ -40,7 +40,6 @@ export * from './components/Shortcuts/Shortcuts';
40
40
  export * from './components/SkillProgressBar';
41
41
  export * from './components/SkillsContainer';
42
42
  export * from './components/Spellbook/Spellbook';
43
- export * from './components/Stepper';
44
43
  export * from './components/TextArea';
45
44
  export * from './components/TimeWidget/TimeWidget';
46
45
  export * from './components/TradingMenu/TradingMenu';
@@ -54,6 +54,44 @@ export const items: IItem[] = [
54
54
  level: 5,
55
55
  },
56
56
  },
57
+ attachedGems: [
58
+ {
59
+ gemEntityEffectsAdd: ['poison'],
60
+ key: 'emerald-gem',
61
+ name: 'Emerald Gem',
62
+ gemStatBuff: {
63
+ attack: 5,
64
+ defense: 4,
65
+ },
66
+ },
67
+ {
68
+ gemEntityEffectsAdd: ['poison'],
69
+ key: 'emerald-gem',
70
+ name: 'Emerald Gem',
71
+ gemStatBuff: {
72
+ attack: 5,
73
+ defense: 4,
74
+ },
75
+ },
76
+ {
77
+ gemEntityEffectsAdd: ['poison'],
78
+ key: 'emerald-gem',
79
+ name: 'Emerald Gem',
80
+ gemStatBuff: {
81
+ attack: 5,
82
+ defense: 4,
83
+ },
84
+ },
85
+ {
86
+ gemEntityEffectsAdd: ['poison'],
87
+ key: 'emerald-gem',
88
+ name: 'Emerald Gem',
89
+ gemStatBuff: {
90
+ attack: 5,
91
+ defense: 4,
92
+ },
93
+ },
94
+ ],
57
95
  equippedBuffDescription: 'Character speed +10%',
58
96
  entityEffectChance: 50,
59
97
  entityEffects: ['freezing'],
@@ -91,6 +129,26 @@ export const items: IItem[] = [
91
129
  createdAt: '2022-06-04T03:18:09.335Z',
92
130
  updatedAt: '2022-06-04T18:16:49.056Z',
93
131
  rarity: ItemRarities.Epic,
132
+ attachedGems: [
133
+ {
134
+ gemEntityEffectsAdd: ['poison'],
135
+ key: 'emerald-gem',
136
+ name: 'Emerald Gem',
137
+ gemStatBuff: {
138
+ attack: 5,
139
+ defense: 4,
140
+ },
141
+ },
142
+ {
143
+ gemEntityEffectsAdd: ['poison'],
144
+ key: 'emerald-gem',
145
+ name: 'Emerald Gem',
146
+ gemStatBuff: {
147
+ attack: 5,
148
+ defense: 4,
149
+ },
150
+ },
151
+ ],
94
152
  },
95
153
  {
96
154
  _id: '629acef1c7c8e8002ff60723',
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- interface IStep {
3
- component: React.ReactNode;
4
- id: number;
5
- }
6
- interface IStepperProps {
7
- steps: IStep[];
8
- finalCTAButton?: {
9
- label: string;
10
- onClick: (() => void) | (() => Promise<void>) | ((e: any) => Promise<void>);
11
- };
12
- }
13
- export declare const Stepper: React.FC<IStepperProps>;
14
- export {};
@@ -1,5 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { ArrowBarProps } from '../components/Arrow/SelectArrow';
3
- declare const meta: Meta;
4
- export default meta;
5
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ArrowBarProps>;
@@ -1,115 +0,0 @@
1
- import React, { useState } from 'react';
2
- import styled from 'styled-components';
3
- import { uiColors } from '../constants/uiColors';
4
- import SelectArrow from './Arrow/SelectArrow';
5
- import { Button, ButtonTypes } from './Button';
6
-
7
- interface IStep {
8
- component: React.ReactNode;
9
- id: number;
10
- }
11
-
12
- interface IStepperProps {
13
- steps: IStep[];
14
- finalCTAButton?: {
15
- label: string;
16
- onClick: (() => void) | (() => Promise<void>) | ((e: any) => Promise<void>);
17
- };
18
- }
19
-
20
- export const Stepper: React.FC<IStepperProps> = ({ steps, finalCTAButton }) => {
21
- const [currentStep, setCurrentStep] = useState(0);
22
-
23
- const currentComponent = steps[currentStep]?.component;
24
-
25
- const totalSteps = steps.length;
26
-
27
- const onStepChange = (step: number) => {
28
- setCurrentStep(step);
29
- };
30
-
31
- return (
32
- <StepperContainer className="stepper-container">
33
- <StepperTop>
34
- {Array.from({ length: totalSteps }, (_, i) => (
35
- <ProgressIndicator
36
- key={i}
37
- isActive={i <= currentStep}
38
- onClick={() => onStepChange(i)}
39
- />
40
- ))}
41
- </StepperTop>
42
-
43
- <StepperBody>{currentComponent}</StepperBody>
44
-
45
- <StepperFooter>
46
- {currentStep > 0 && (
47
- <SelectArrow
48
- direction="left"
49
- onPointerDown={() => onStepChange(Math.max(0, currentStep - 1))}
50
- />
51
- )}
52
-
53
- {currentStep < totalSteps - 1 && (
54
- <SelectArrow
55
- direction="right"
56
- onPointerDown={() =>
57
- onStepChange(Math.min(totalSteps - 1, currentStep + 1))
58
- }
59
- />
60
- )}
61
-
62
- {currentStep === totalSteps - 1 && finalCTAButton && (
63
- <Button
64
- buttonType={ButtonTypes.RPGUIButton}
65
- onPointerDown={() => finalCTAButton.onClick}
66
- >
67
- {finalCTAButton.label}
68
- </Button>
69
- )}
70
- </StepperFooter>
71
- </StepperContainer>
72
- );
73
- };
74
-
75
- const StepperContainer = styled.div`
76
- display: flex;
77
- flex-direction: column;
78
- height: 100%; // Ensure the container takes up full height
79
- `;
80
-
81
- const StepperTop = styled.div`
82
- flex: 1; // Small top
83
-
84
- display: flex;
85
- flex-wrap: wrap;
86
- justify-content: center;
87
- align-items: center;
88
-
89
- margin-bottom: 1rem;
90
- `;
91
-
92
- const StepperBody = styled.div`
93
- flex: 8; // Big content space
94
- `;
95
-
96
- const StepperFooter = styled.div`
97
- margin-top: 1rem;
98
- flex: 1; // Small footer
99
-
100
- display: flex;
101
- justify-content: flex-end;
102
- `;
103
-
104
- const ProgressIndicator = styled.div<{ isActive: boolean }>`
105
- width: 20px;
106
- height: 20px;
107
- border-radius: 50%;
108
- background-color: ${({ isActive }) =>
109
- isActive ? uiColors.orange : uiColors.lightGray};
110
- margin: 0 5px;
111
- transition: background-color 0.3s;
112
- opacity: ${({ isActive }) => (isActive ? 1 : 0.25)};
113
- border: 1px solid ${uiColors.raisinBlack};
114
- cursor: pointer;
115
- `;
@@ -1,48 +0,0 @@
1
- import { Meta, Story } from '@storybook/react';
2
- import React from 'react';
3
- import { RPGUIRoot } from '..';
4
- import { ArrowBarProps } from '../components/Arrow/SelectArrow';
5
- import { Stepper } from '../components/Stepper';
6
-
7
- const meta: Meta = {
8
- title: 'Stepper',
9
- component: Stepper,
10
- };
11
-
12
- export default meta;
13
-
14
- const Template: Story<ArrowBarProps> = args => (
15
- <RPGUIRoot>
16
- <Stepper
17
- steps={[
18
- {
19
- component: <div>Step 1</div>,
20
- id: 0,
21
- },
22
- {
23
- component: <div>Step 2</div>,
24
- id: 1,
25
- },
26
- {
27
- component: <div>Step 3</div>,
28
- id: 2,
29
- },
30
- ]}
31
- finalCTAButton={{
32
- label: 'Submit',
33
- onClick: () => {
34
- console.log('Submitting your data');
35
- },
36
- }}
37
- ></Stepper>
38
- </RPGUIRoot>
39
- );
40
-
41
- export const Default = Template.bind({});
42
-
43
- Default.args = {
44
- direction: 'left',
45
- onPointerDown: () => {
46
- console.log('clicked');
47
- },
48
- };