@rpg-engine/long-bow 0.7.13 → 0.7.14
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 +25 -73
- 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 +23 -74
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Quests/QuestList.tsx +24 -87
package/package.json
CHANGED
|
@@ -1,31 +1,42 @@
|
|
|
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>{formatText(quest.title)}</Value>
|
|
23
|
+
<Label style={styles?.label}>Title:</Label>
|
|
24
|
+
<Value style={styles?.value}>{formatText(quest.title)}</Value>
|
|
19
25
|
</QuestItem>
|
|
20
26
|
<QuestItem>
|
|
21
|
-
<Label>Status:</Label>
|
|
22
|
-
<Value
|
|
27
|
+
<Label style={styles?.label}>Status:</Label>
|
|
28
|
+
<Value
|
|
29
|
+
style={{
|
|
30
|
+
...styles?.value,
|
|
31
|
+
color: getStatusColor(quest.status),
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
23
34
|
{formatStatus(quest.status) ?? 'Unknown'}
|
|
24
35
|
</Value>
|
|
25
36
|
</QuestItem>
|
|
26
37
|
<QuestItem>
|
|
27
|
-
<Label>Description:</Label>
|
|
28
|
-
<Value>{quest.description}</Value>
|
|
38
|
+
<Label style={styles?.label}>Description:</Label>
|
|
39
|
+
<Value style={styles?.value}>{quest.description}</Value>
|
|
29
40
|
</QuestItem>
|
|
30
41
|
</QuestCard>
|
|
31
42
|
))
|
|
@@ -39,8 +50,6 @@ export const QuestList: React.FC<IQuestListProps> = ({ quests }) => {
|
|
|
39
50
|
};
|
|
40
51
|
|
|
41
52
|
const QuestListContainer = styled.div`
|
|
42
|
-
margin-top: 20px;
|
|
43
|
-
margin-bottom: 40px;
|
|
44
53
|
max-height: 400px;
|
|
45
54
|
padding: 10px;
|
|
46
55
|
border-radius: 10px;
|
|
@@ -87,79 +96,7 @@ const NoQuestContainer = styled.div`
|
|
|
87
96
|
}
|
|
88
97
|
`;
|
|
89
98
|
|
|
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) => {
|
|
99
|
+
export const formatText = (text: string) => {
|
|
163
100
|
if (!text) return '';
|
|
164
101
|
return text
|
|
165
102
|
.split('-')
|
|
@@ -167,7 +104,7 @@ const formatText = (text: string) => {
|
|
|
167
104
|
.join(' ');
|
|
168
105
|
};
|
|
169
106
|
|
|
170
|
-
const getStatusColor = (status?: QuestStatus) => {
|
|
107
|
+
export const getStatusColor = (status?: QuestStatus) => {
|
|
171
108
|
switch (status) {
|
|
172
109
|
case QuestStatus.Pending:
|
|
173
110
|
return uiColors.orange;
|
|
@@ -180,7 +117,7 @@ const getStatusColor = (status?: QuestStatus) => {
|
|
|
180
117
|
}
|
|
181
118
|
};
|
|
182
119
|
|
|
183
|
-
const formatStatus = (status?: QuestStatus) => {
|
|
120
|
+
export const formatStatus = (status?: QuestStatus) => {
|
|
184
121
|
if (!status) return '';
|
|
185
122
|
return status
|
|
186
123
|
.split(/(?=[A-Z])/)
|