@rpg-engine/long-bow 0.6.82 → 0.6.83

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.82",
3
+ "version": "0.6.83",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -32,14 +32,18 @@ export const QuestList: React.FC<IQuestListProps> = ({ quests }) => {
32
32
  <Label>Description:</Label>
33
33
  <Value>{quest.description}</Value>
34
34
  </QuestItem>
35
- <QuestItem>
36
- <Label>Objectives:</Label>
37
- <Value>{formatObjectives(quest.objectives)}</Value>
38
- </QuestItem>
39
- <QuestItem>
40
- <Label>Rewards:</Label>
41
- <Value>{formatRewards(quest.rewards)}</Value>
42
- </QuestItem>
35
+ {quest.objectives && quest.objectives.length > 0 && (
36
+ <QuestItem>
37
+ <Label>Objectives:</Label>
38
+ <Value>{formatObjectives(quest.objectives)}</Value>
39
+ </QuestItem>
40
+ )}
41
+ {quest.rewards && quest.rewards.length > 0 && (
42
+ <QuestItem>
43
+ <Label>Rewards:</Label>
44
+ <Value>{formatRewards(quest.rewards)}</Value>
45
+ </QuestItem>
46
+ )}
43
47
  </QuestCard>
44
48
  ))
45
49
  ) : (
@@ -104,34 +108,35 @@ const formatObjectives = (
104
108
  objectives: (IQuestObjectiveKill | IQuestObjectiveInteraction)[]
105
109
  ) => {
106
110
  try {
107
- if (!objectives || !Array.isArray(objectives)) return 'No objectives';
111
+ if (!objectives || !Array.isArray(objectives)) return '';
108
112
  return objectives
109
113
  .map(objective => {
110
114
  if ('killCountTarget' in objective) {
111
115
  const killObjective = objective as IQuestObjectiveKill;
112
116
  return `Kill ${formatText(
113
- killObjective.creatureKeys?.join(', ') ?? 'Unknown'
117
+ killObjective.creatureKeys?.join(', ') ?? ''
114
118
  )}: ${killObjective.killCount ?? 0}/${killObjective.killCountTarget ??
115
119
  0}`;
116
120
  } else if ('targetNPCkey' in objective) {
117
121
  const interactionObjective = objective as IQuestObjectiveInteraction;
118
122
  return `Interact with NPC: ${formatText(
119
- interactionObjective.targetNPCkey ?? 'Unknown'
123
+ interactionObjective.targetNPCkey ?? ''
120
124
  )}`;
121
125
  } else {
122
- return 'Unknown objective';
126
+ return '';
123
127
  }
124
128
  })
129
+ .filter(Boolean)
125
130
  .join('; ');
126
131
  } catch (error) {
127
132
  console.error('Error formatting objectives:', error);
128
- return 'Error formatting objectives';
133
+ return '';
129
134
  }
130
135
  };
131
136
 
132
137
  const formatRewards = (rewards: IQuest['rewards']) => {
133
138
  try {
134
- if (!rewards || !Array.isArray(rewards)) return 'No rewards';
139
+ if (!rewards || !Array.isArray(rewards)) return '';
135
140
 
136
141
  return rewards
137
142
  .map(reward => {
@@ -158,7 +163,7 @@ const formatRewards = (rewards: IQuest['rewards']) => {
158
163
  : `Spells: ${formatText(spellKeysFormatted)}`;
159
164
  }
160
165
 
161
- return formattedReward || 'No rewards';
166
+ return formattedReward || '';
162
167
  })
163
168
  .filter(Boolean)
164
169
  .join('; ');
@@ -167,12 +172,12 @@ const formatRewards = (rewards: IQuest['rewards']) => {
167
172
  `Error formatting rewards: ${JSON.stringify(rewards)}:`,
168
173
  error
169
174
  );
170
- return 'Error on rewards';
175
+ return '';
171
176
  }
172
177
  };
173
178
 
174
179
  const formatText = (text: string) => {
175
- if (!text) return 'Unknown';
180
+ if (!text) return '';
176
181
  return text
177
182
  .split('-')
178
183
  .map(word => word.charAt(0).toUpperCase() + word.slice(1))
@@ -193,7 +198,7 @@ const getStatusColor = (status?: QuestStatus) => {
193
198
  };
194
199
 
195
200
  const formatStatus = (status?: QuestStatus) => {
196
- if (!status) return 'Unknown';
201
+ if (!status) return '';
197
202
  return status
198
203
  .split(/(?=[A-Z])/)
199
204
  .join(' ')