@rpg-engine/long-bow 0.7.13 → 0.7.15
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/dist/components/Quests/QuestList.d.ts +11 -1
- package/dist/long-bow.cjs.development.js +30 -78
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +28 -79
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Quests/QuestList.tsx +27 -88
package/package.json
CHANGED
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
import { IQuest, QuestStatus } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
3
|
+
import styled, { CSSProperties } from 'styled-components';
|
|
4
4
|
import { uiColors } from '../../constants/uiColors';
|
|
5
5
|
|
|
6
6
|
export interface IQuestListProps {
|
|
7
7
|
quests?: IQuest[];
|
|
8
|
+
styles?: {
|
|
9
|
+
container?: CSSProperties;
|
|
10
|
+
card?: CSSProperties;
|
|
11
|
+
label?: CSSProperties;
|
|
12
|
+
value?: CSSProperties;
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
15
|
|
|
10
|
-
export const QuestList: React.FC<IQuestListProps> = ({ quests }) => {
|
|
16
|
+
export const QuestList: React.FC<IQuestListProps> = ({ quests, styles }) => {
|
|
11
17
|
return (
|
|
12
|
-
<QuestListContainer>
|
|
18
|
+
<QuestListContainer style={styles?.container}>
|
|
13
19
|
{quests && quests.length > 0 ? (
|
|
14
20
|
quests.map((quest, i) => (
|
|
15
|
-
<QuestCard key={i}>
|
|
21
|
+
<QuestCard key={i} style={styles?.card}>
|
|
16
22
|
<QuestItem>
|
|
17
|
-
<Label>Title:</Label>
|
|
18
|
-
<Value
|
|
23
|
+
<Label style={styles?.label}>Title:</Label>
|
|
24
|
+
<Value style={styles?.value}>
|
|
25
|
+
{formatQuestText(quest.title)}
|
|
26
|
+
</Value>
|
|
19
27
|
</QuestItem>
|
|
20
28
|
<QuestItem>
|
|
21
|
-
<Label>Status:</Label>
|
|
22
|
-
<Value
|
|
23
|
-
{
|
|
29
|
+
<Label style={styles?.label}>Status:</Label>
|
|
30
|
+
<Value
|
|
31
|
+
style={{
|
|
32
|
+
...styles?.value,
|
|
33
|
+
color: getQuestStatusColor(quest.status),
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{formatQuestStatus(quest.status) ?? 'Unknown'}
|
|
24
37
|
</Value>
|
|
25
38
|
</QuestItem>
|
|
26
39
|
<QuestItem>
|
|
27
|
-
<Label>Description:</Label>
|
|
28
|
-
<Value>{quest.description}</Value>
|
|
40
|
+
<Label style={styles?.label}>Description:</Label>
|
|
41
|
+
<Value style={styles?.value}>{quest.description}</Value>
|
|
29
42
|
</QuestItem>
|
|
30
43
|
</QuestCard>
|
|
31
44
|
))
|
|
@@ -39,8 +52,6 @@ export const QuestList: React.FC<IQuestListProps> = ({ quests }) => {
|
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
const QuestListContainer = styled.div`
|
|
42
|
-
margin-top: 20px;
|
|
43
|
-
margin-bottom: 40px;
|
|
44
55
|
max-height: 400px;
|
|
45
56
|
padding: 10px;
|
|
46
57
|
border-radius: 10px;
|
|
@@ -87,79 +98,7 @@ const NoQuestContainer = styled.div`
|
|
|
87
98
|
}
|
|
88
99
|
`;
|
|
89
100
|
|
|
90
|
-
|
|
91
|
-
// objectives: (IQuestObjectiveKill | IQuestObjectiveInteraction)[]
|
|
92
|
-
// ) => {
|
|
93
|
-
// try {
|
|
94
|
-
// if (!objectives || !Array.isArray(objectives)) return '';
|
|
95
|
-
// return objectives
|
|
96
|
-
// .map(objective => {
|
|
97
|
-
// if ('killCountTarget' in objective) {
|
|
98
|
-
// const killObjective = objective as IQuestObjectiveKill;
|
|
99
|
-
// return `Kill ${formatText(
|
|
100
|
-
// killObjective.creatureKeys?.join(', ') ?? ''
|
|
101
|
-
// )}: ${killObjective.killCount ?? 0}/${killObjective.killCountTarget ??
|
|
102
|
-
// 0}`;
|
|
103
|
-
// } else if ('targetNPCkey' in objective) {
|
|
104
|
-
// const interactionObjective = objective as IQuestObjectiveInteraction;
|
|
105
|
-
// return `Interact with NPC: ${formatText(
|
|
106
|
-
// interactionObjective.targetNPCkey ?? ''
|
|
107
|
-
// )}`;
|
|
108
|
-
// } else {
|
|
109
|
-
// return '';
|
|
110
|
-
// }
|
|
111
|
-
// })
|
|
112
|
-
// .filter(Boolean)
|
|
113
|
-
// .join('; ');
|
|
114
|
-
// } catch (error) {
|
|
115
|
-
// console.error('Error formatting objectives:', error);
|
|
116
|
-
// return '';
|
|
117
|
-
// }
|
|
118
|
-
// };
|
|
119
|
-
|
|
120
|
-
// const formatRewards = (rewards: IQuest['rewards']) => {
|
|
121
|
-
// try {
|
|
122
|
-
// if (!rewards || !Array.isArray(rewards)) return '';
|
|
123
|
-
|
|
124
|
-
// return rewards
|
|
125
|
-
// .map(reward => {
|
|
126
|
-
// const itemKeysFormatted = reward?.itemKeys
|
|
127
|
-
// ?.map(itemKey =>
|
|
128
|
-
// itemKey && reward?.qty !== undefined
|
|
129
|
-
// ? `${itemKey} x${reward.qty}`
|
|
130
|
-
// : ''
|
|
131
|
-
// )
|
|
132
|
-
// .filter(Boolean)
|
|
133
|
-
// .join(', ');
|
|
134
|
-
|
|
135
|
-
// const spellKeysFormatted = reward?.spellKeys
|
|
136
|
-
// ?.filter(Boolean)
|
|
137
|
-
// .join(', ');
|
|
138
|
-
|
|
139
|
-
// const formattedReward = itemKeysFormatted
|
|
140
|
-
// ? `${formatText(itemKeysFormatted)}`
|
|
141
|
-
// : '';
|
|
142
|
-
|
|
143
|
-
// if (spellKeysFormatted) {
|
|
144
|
-
// return formattedReward
|
|
145
|
-
// ? `${formattedReward}, Spells: ${formatText(spellKeysFormatted)}`
|
|
146
|
-
// : `Spells: ${formatText(spellKeysFormatted)}`;
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
|
-
// return formattedReward || '';
|
|
150
|
-
// })
|
|
151
|
-
// .filter(Boolean)
|
|
152
|
-
// .join('; ');
|
|
153
|
-
// } catch (error) {
|
|
154
|
-
// console.error(
|
|
155
|
-
// `Error formatting rewards: ${JSON.stringify(rewards)}:`,
|
|
156
|
-
// error
|
|
157
|
-
// );
|
|
158
|
-
// return '';
|
|
159
|
-
// }
|
|
160
|
-
// };
|
|
161
|
-
|
|
162
|
-
const formatText = (text: string) => {
|
|
101
|
+
export const formatQuestText = (text: string) => {
|
|
163
102
|
if (!text) return '';
|
|
164
103
|
return text
|
|
165
104
|
.split('-')
|
|
@@ -167,7 +106,7 @@ const formatText = (text: string) => {
|
|
|
167
106
|
.join(' ');
|
|
168
107
|
};
|
|
169
108
|
|
|
170
|
-
const
|
|
109
|
+
export const getQuestStatusColor = (status?: QuestStatus) => {
|
|
171
110
|
switch (status) {
|
|
172
111
|
case QuestStatus.Pending:
|
|
173
112
|
return uiColors.orange;
|
|
@@ -180,7 +119,7 @@ const getStatusColor = (status?: QuestStatus) => {
|
|
|
180
119
|
}
|
|
181
120
|
};
|
|
182
121
|
|
|
183
|
-
const
|
|
122
|
+
export const formatQuestStatus = (status?: QuestStatus) => {
|
|
184
123
|
if (!status) return '';
|
|
185
124
|
return status
|
|
186
125
|
.split(/(?=[A-Z])/)
|