@rpg-engine/long-bow 0.8.46 → 0.8.47

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/DailyTasks/DailyRewardsTooltip.d.ts +11 -0
  2. package/dist/components/DailyTasks/DailyTaskItem.d.ts +13 -0
  3. package/dist/components/DailyTasks/DailyTasks.d.ts +13 -0
  4. package/dist/components/DailyTasks/GlobalDailyProgress.d.ts +8 -0
  5. package/dist/components/DailyTasks/TaskProgress.d.ts +11 -0
  6. package/dist/components/DailyTasks/TaskProgressDetails.d.ts +7 -0
  7. package/dist/components/DailyTasks/utils/dailyTasks.utils.d.ts +8 -0
  8. package/dist/components/ReadOnlyCheckItem.d.ts +7 -0
  9. package/dist/constants/uiColors.d.ts +1 -0
  10. package/dist/index.d.ts +0 -1
  11. package/dist/long-bow.cjs.development.js +1 -0
  12. package/dist/long-bow.cjs.development.js.map +1 -1
  13. package/dist/long-bow.cjs.production.min.js.map +1 -1
  14. package/dist/long-bow.esm.js +1 -0
  15. package/dist/long-bow.esm.js.map +1 -1
  16. package/dist/mocks/dailyTasks.mocks.d.ts +2 -0
  17. package/dist/stories/Features/dailyTasks/DailyTasks.stories.d.ts +1 -0
  18. package/package.json +2 -2
  19. package/src/components/DailyTasks/DailyRewardsTooltip.tsx +158 -0
  20. package/src/components/DailyTasks/DailyTaskItem.tsx +161 -0
  21. package/src/components/DailyTasks/DailyTasks.tsx +151 -0
  22. package/src/components/DailyTasks/GlobalDailyProgress.tsx +132 -0
  23. package/src/components/DailyTasks/TaskProgress.tsx +92 -0
  24. package/src/components/DailyTasks/TaskProgressDetails.tsx +128 -0
  25. package/src/components/DailyTasks/utils/dailyTasks.utils.ts +96 -0
  26. package/src/components/ReadOnlyCheckItem.tsx +43 -0
  27. package/src/constants/uiColors.ts +1 -0
  28. package/src/index.tsx +0 -1
  29. package/src/mocks/dailyTasks.mocks.ts +212 -0
  30. package/src/stories/Features/dailyTasks/DailyTasks.stories.tsx +145 -0
  31. package/dist/components/Character/CharacterSkinSelectionModal.d.ts +0 -13
  32. package/dist/stories/Character/character/CharacterSkinSelectionModal.stories.d.ts +0 -5
  33. package/src/components/Character/CharacterSkinSelectionModal.tsx +0 -157
  34. package/src/stories/Character/character/CharacterSkinSelectionModal.stories.tsx +0 -49
@@ -0,0 +1,145 @@
1
+ import {
2
+ ICollectItemsRequirement,
3
+ ICraftRequirement,
4
+ IKillMobsRequirement,
5
+ IMapVisitRequirement,
6
+ ITaskIdentifier,
7
+ TaskStatus,
8
+ TaskType
9
+ } from '@rpg-engine/shared';
10
+ import { Meta, StoryObj } from '@storybook/react';
11
+ import React from 'react';
12
+ import { DailyTasks, IDailyTasksProps } from '../../../components/DailyTasks/DailyTasks';
13
+ import { RPGUIRoot } from '../../../components/RPGUI/RPGUIRoot';
14
+ import iconAtlasJSON from '../../../mocks/atlas/icons/icons.json';
15
+ import iconAtlasIMG from '../../../mocks/atlas/icons/icons.png';
16
+ import itemsAtlasJSON from '../../../mocks/atlas/items/items.json';
17
+ import itemsAtlasIMG from '../../../mocks/atlas/items/items.png';
18
+ import { mockTasks } from '../../../mocks/dailyTasks.mocks';
19
+
20
+ const meta = {
21
+ title: 'Features/Daily Tasks/Daily Tasks',
22
+ component: DailyTasks,
23
+ parameters: {
24
+ layout: 'centered',
25
+ },
26
+ } satisfies Meta<typeof DailyTasks>;
27
+
28
+ export default meta;
29
+ type Story = StoryObj<IDailyTasksProps>;
30
+
31
+ const Template = (args: IDailyTasksProps) => {
32
+ return (
33
+ <RPGUIRoot>
34
+ <DailyTasks
35
+ {...args}
36
+ />
37
+ </RPGUIRoot>
38
+ );
39
+ };
40
+
41
+ export const Default: Story = {
42
+ render: Template,
43
+ args: {
44
+ tasks: mockTasks,
45
+ itemsAtlasJSON,
46
+ itemsAtlasIMG,
47
+ iconAtlasJSON,
48
+ iconAtlasIMG,
49
+ onClaimReward: ({ taskKey, type }: ITaskIdentifier) => {
50
+ console.log('Reward collected:', taskKey, type);
51
+ },
52
+ onClose: () => {
53
+ console.log('Closing daily tasks window');
54
+ },
55
+ },
56
+ };
57
+
58
+ export const EmptyTasks: Story = {
59
+ render: Template,
60
+ args: {
61
+ tasks: [],
62
+ onClaimReward: ({ taskKey, type }: ITaskIdentifier) => {
63
+ console.log('Reward collected:', taskKey, type);
64
+ },
65
+ onClose: () => {
66
+ console.log('Closing daily tasks window');
67
+ },
68
+ },
69
+ };
70
+
71
+ export const AllCompletedClaimed: Story = {
72
+ render: Template,
73
+ args: {
74
+ itemsAtlasJSON,
75
+ itemsAtlasIMG,
76
+ iconAtlasJSON,
77
+ iconAtlasIMG,
78
+ tasks: mockTasks.map(task => {
79
+ const baseTask = {
80
+ ...task,
81
+ claimed: true,
82
+ status: TaskStatus.Completed,
83
+ };
84
+
85
+ switch (task.type) {
86
+ case TaskType.KillMobs:
87
+ const killMobsRequirement = task.requirements as IKillMobsRequirement;
88
+
89
+ return {
90
+ ...baseTask,
91
+ progress: {
92
+ kills: killMobsRequirement.targets.reduce((acc, target) => {
93
+ acc[target.key] = target.quantity;
94
+ return acc;
95
+ }, {} as Record<string, number>)
96
+ }
97
+ };
98
+ case TaskType.CollectItems:
99
+ const collectItemsRequirement = task.requirements as ICollectItemsRequirement;
100
+
101
+ return {
102
+ ...baseTask,
103
+ progress: {
104
+ collected: collectItemsRequirement.targets.reduce((acc, target) => {
105
+ acc[target.key] = target.quantity;
106
+ return acc;
107
+ }, {} as Record<string, number>)
108
+ }
109
+ };
110
+ case TaskType.CraftItems:
111
+ const craftItemsRequirement = task.requirements as ICraftRequirement;
112
+
113
+ return {
114
+ ...baseTask,
115
+ progress: {
116
+ crafted: craftItemsRequirement.targets.reduce((acc, target) => {
117
+ acc[target.key] = target.quantity;
118
+ return acc;
119
+ }, {} as Record<string, number>)
120
+ }
121
+ };
122
+ case TaskType.MapVisit:
123
+ const mapVisitRequirement = task.requirements as IMapVisitRequirement;
124
+ return {
125
+ ...baseTask,
126
+ progress: {
127
+ visitedMaps: mapVisitRequirement.mapKeys.reduce((acc, key) => {
128
+ acc[key] = true;
129
+ return acc;
130
+ }, {} as Record<string, boolean>)
131
+ }
132
+ };
133
+ default:
134
+ return baseTask;
135
+ }
136
+ }),
137
+ onClaimReward: ({ taskKey, type }: ITaskIdentifier) => {
138
+ console.log('Reward collected:', taskKey, type);
139
+ },
140
+ onClose: () => {
141
+ console.log('Closing daily tasks window');
142
+ },
143
+ },
144
+ };
145
+
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { ICharacterProps } from './CharacterSelection';
3
- export interface ICharacterSkinSelectionModalProps {
4
- isOpen: boolean;
5
- onClose: () => void;
6
- onConfirm: (textureKey: string) => void;
7
- availableCharacters: ICharacterProps[];
8
- atlasJSON: any;
9
- atlasIMG: any;
10
- initialSelectedSkin?: string;
11
- }
12
- declare const CharacterSkinSelectionModal: React.FC<ICharacterSkinSelectionModalProps>;
13
- export default CharacterSkinSelectionModal;
@@ -1,5 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { ICharacterSkinSelectionModalProps } from '../../../components/Character/CharacterSkinSelectionModal';
3
- declare const meta: Meta;
4
- export default meta;
5
- export declare const KnightSkins: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ICharacterSkinSelectionModalProps>;
@@ -1,157 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import styled from 'styled-components';
3
- import { Button, ButtonTypes } from '../Button';
4
- import { ErrorBoundary } from '../Item/Inventory/ErrorBoundary';
5
- import PropertySelect, { IPropertiesProps } from '../PropertySelect/PropertySelect';
6
- import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
7
- import { ICharacterProps } from './CharacterSelection';
8
-
9
- export interface ICharacterSkinSelectionModalProps {
10
- isOpen: boolean;
11
- onClose: () => void;
12
- onConfirm: (textureKey: string) => void;
13
- availableCharacters: ICharacterProps[];
14
- atlasJSON: any;
15
- atlasIMG: any;
16
- initialSelectedSkin?: string;
17
- }
18
-
19
- const CharacterSkinSelectionModal: React.FC<ICharacterSkinSelectionModalProps> = ({
20
- isOpen,
21
- onClose,
22
- onConfirm,
23
- availableCharacters,
24
- atlasJSON,
25
- atlasIMG,
26
- initialSelectedSkin = '',
27
- }) => {
28
- // Convert availableCharacters to the format used by PropertySelect
29
- const propertySelectValues = availableCharacters.map((item) => ({
30
- id: item.textureKey,
31
- name: item.name,
32
- }));
33
-
34
- // State to store the selected skin and the sprite key
35
- const [selectedValue, setSelectedValue] = useState<IPropertiesProps | undefined>();
36
- const [selectedSpriteKey, setSelectedSpriteKey] = useState('');
37
-
38
- // Update sprite when the selected value changes
39
- const updateSelectedSpriteKey = () => {
40
- const textureKey = selectedValue ? selectedValue.id : '';
41
- const spriteKey = textureKey ? textureKey + '/down/standing/0.png' : '';
42
-
43
- if (spriteKey === selectedSpriteKey) {
44
- return;
45
- }
46
-
47
- setSelectedSpriteKey(spriteKey);
48
- };
49
-
50
- // Update sprite when selectedValue changes
51
- useEffect(() => {
52
- updateSelectedSpriteKey();
53
- }, [selectedValue]);
54
-
55
- // Initialize selectedValue
56
- useEffect(() => {
57
- if (initialSelectedSkin) {
58
- const initialProperty = propertySelectValues.find(
59
- (prop) => prop.id === initialSelectedSkin
60
- );
61
- setSelectedValue(initialProperty || propertySelectValues[0]);
62
- } else if (propertySelectValues.length > 0) {
63
- setSelectedValue(propertySelectValues[0]);
64
- }
65
- }, [initialSelectedSkin, availableCharacters]);
66
-
67
- // Functions to handle confirmation and cancellation
68
- const handleConfirm = () => {
69
- if (selectedValue) {
70
- onConfirm(selectedValue.id);
71
- onClose();
72
- }
73
- };
74
-
75
- const handleCancel = () => {
76
- onClose();
77
- };
78
-
79
- if (!isOpen) return null;
80
-
81
- return (
82
-
83
- <Container>
84
- {selectedSpriteKey && atlasIMG && atlasJSON && (
85
- <ErrorBoundary>
86
- <SpriteFromAtlas
87
- spriteKey={selectedSpriteKey}
88
- atlasIMG={atlasIMG}
89
- atlasJSON={atlasJSON}
90
- imgScale={4}
91
- height={80}
92
- width={64}
93
- containerStyle={{
94
- display: 'flex',
95
- alignItems: 'center',
96
- paddingBottom: '15px',
97
- }}
98
- imgStyle={{
99
- left: '22px',
100
- }}
101
- />
102
- </ErrorBoundary>
103
- )}
104
-
105
-
106
- <PropertySelect
107
- availableProperties={propertySelectValues}
108
- onChange={(value) => {
109
- setSelectedValue(value);
110
- }}
111
- />
112
-
113
-
114
-
115
- <ButtonsContainer>
116
- <Button
117
- buttonType={ButtonTypes.RPGUIButton}
118
- onClick={handleCancel}
119
- >
120
- Cancel
121
- </Button>
122
- <Button
123
- buttonType={ButtonTypes.RPGUIButton}
124
- onClick={handleConfirm}
125
- disabled={!selectedValue}
126
- >
127
- Confirm
128
- </Button>
129
- </ButtonsContainer>
130
- </Container>
131
- );
132
- };
133
-
134
- // Styled components
135
-
136
- const Container = styled.div`
137
- display: flex;
138
- flex-direction: column;
139
- align-items: center;
140
- image-rendering: pixelated;
141
- `;
142
-
143
-
144
- const ButtonsContainer = styled.div`
145
- display: flex;
146
- justify-content: center;
147
- gap: 0.8rem;
148
- width: 100%;
149
- margin: 3rem 0 0.75rem;
150
-
151
- button {
152
- min-width: 95px;
153
- font-size: 0.9rem;
154
- }
155
- `;
156
-
157
- export default CharacterSkinSelectionModal;
@@ -1,49 +0,0 @@
1
- import { Meta, Story } from '@storybook/react';
2
- import React from 'react';
3
- import { RPGUIRoot } from '../../..';
4
- import CharacterSkinSelectionModal, {
5
- ICharacterSkinSelectionModalProps
6
- } from '../../../components/Character/CharacterSkinSelectionModal';
7
- import atlasJSON from '../../../mocks/atlas/entities/entities.json';
8
- import atlasIMG from '../../../mocks/atlas/entities/entities.png';
9
-
10
- const meta: Meta = {
11
- title: 'Character/Character/Skin Selection',
12
- component: CharacterSkinSelectionModal,
13
- };
14
-
15
- export default meta;
16
-
17
- const Template: Story<ICharacterSkinSelectionModalProps> = (args: ICharacterSkinSelectionModalProps) => (
18
- <RPGUIRoot>
19
- <CharacterSkinSelectionModal {...args} />
20
- </RPGUIRoot>
21
- );
22
-
23
- export const KnightSkins = Template.bind({});
24
-
25
- // Example of different knight skins
26
- const knightCharacters = [
27
- {
28
- name: 'Black Knight',
29
- textureKey: 'black-knight',
30
- },
31
- {
32
- name: 'Dragon Knight',
33
- textureKey: 'dragon-knight',
34
- },
35
- {
36
- name: 'Senior Knight',
37
- textureKey: 'senior-knight-1',
38
- }
39
- ];
40
-
41
- KnightSkins.args = {
42
- isOpen: true,
43
- onClose: () => console.log('Modal closed'),
44
- onConfirm: (textureKey: string) => console.log('Selected skin:', textureKey),
45
- availableCharacters: knightCharacters,
46
- atlasJSON: atlasJSON,
47
- atlasIMG: atlasIMG,
48
- initialSelectedSkin: 'black-knight',
49
- };