@rpg-engine/long-bow 0.6.75 → 0.6.76

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.75",
3
+ "version": "0.6.76",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -122,18 +122,35 @@ const formatObjectives = (
122
122
  const formatRewards = (rewards: IQuest['rewards']) => {
123
123
  try {
124
124
  if (!rewards || !Array.isArray(rewards)) return 'No rewards';
125
+
125
126
  return rewards
126
127
  .map(reward => {
127
- return `${formatText(
128
- reward?.itemKeys
129
- ?.map(itemKey => itemKey + ' x' + reward?.qty)
130
- .join(', ')
131
- )}${
132
- reward?.spellKeys
133
- ? `, Spells: ${formatText(reward.spellKeys.join(', '))}`
134
- : ''
135
- }`;
128
+ const itemKeysFormatted = reward?.itemKeys
129
+ ?.map(itemKey =>
130
+ itemKey && reward?.qty !== undefined
131
+ ? `${itemKey} x${reward.qty}`
132
+ : ''
133
+ )
134
+ .filter(Boolean)
135
+ .join(', ');
136
+
137
+ const spellKeysFormatted = reward?.spellKeys
138
+ ?.filter(Boolean)
139
+ .join(', ');
140
+
141
+ const formattedReward = itemKeysFormatted
142
+ ? `${formatText(itemKeysFormatted)}`
143
+ : '';
144
+
145
+ if (spellKeysFormatted) {
146
+ return formattedReward
147
+ ? `${formattedReward}, Spells: ${formatText(spellKeysFormatted)}`
148
+ : `Spells: ${formatText(spellKeysFormatted)}`;
149
+ }
150
+
151
+ return formattedReward || 'No rewards';
136
152
  })
153
+ .filter(Boolean)
137
154
  .join('; ');
138
155
  } catch (error) {
139
156
  console.error(
@@ -143,6 +160,7 @@ const formatRewards = (rewards: IQuest['rewards']) => {
143
160
  return 'Error on rewards';
144
161
  }
145
162
  };
163
+
146
164
  const formatText = (text: string) => {
147
165
  return text
148
166
  .split('-')