5etools-utils 0.13.5 → 0.13.7

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/lib/UtilMisc.js CHANGED
@@ -37,6 +37,27 @@ export default class MiscUtil {
37
37
 
38
38
  /* -------------------------------------------- */
39
39
 
40
+ /** Delete a prop from a nested object, then all now-empty objects backwards from that point. */
41
+ static deleteObjectPath (object, ...path) {
42
+ const stack = [object];
43
+
44
+ if (object == null) return object;
45
+ for (let i = 0; i < path.length - 1; ++i) {
46
+ object = object[path[i]];
47
+ stack.push(object);
48
+ if (object === undefined) return object;
49
+ }
50
+ const out = delete object[path.at(-1)];
51
+
52
+ for (let i = path.length - 1; i > 0; --i) {
53
+ if (!Object.keys(stack[i]).length) delete stack[i - 1][path[i - 1]];
54
+ }
55
+
56
+ return out;
57
+ }
58
+
59
+ /* -------------------------------------------- */
60
+
40
61
  static setEq (a, b) {
41
62
  if (a.size !== b.size) return false;
42
63
  for (const it of a) if (!b.has(it)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.13.5",
3
+ "version": "0.13.7",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "util-foundry.json",
4
4
  "title": "Util: Foundry",
5
- "version": "1.0.8",
5
+ "version": "1.0.9",
6
6
  "$defs": {
7
7
  "entryDataObject": {
8
8
  "description": "Additional \"5etools-type\" data to be stored on the entry.",
@@ -113,11 +113,285 @@
113
113
  },
114
114
  "minProperties": 1
115
115
  },
116
- "_foundryActivityObject_utility": {
116
+ "_foundryActivityObject_base": {
117
+ "type": "object",
118
+ "properties": {
119
+ "consumption": {
120
+ "type": "object",
121
+ "properties": {
122
+ "targets": {
123
+ "type": "array",
124
+ "items": {
125
+ "type": "object",
126
+ "properties": {
127
+ "target": {
128
+ "oneOf": [
129
+ {
130
+ "type": "string"
131
+ },
132
+ {
133
+ "type": "object",
134
+ "properties": {
135
+ "prop": {
136
+ "type": "string"
137
+ },
138
+ "uid": {
139
+ "type": "string"
140
+ }
141
+ },
142
+ "required": [
143
+ "prop",
144
+ "uid"
145
+ ],
146
+ "additionalProperties": false
147
+ }
148
+ ]
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ },
155
+ "effects": {
156
+ "type": "array",
157
+ "items": {
158
+ "type": "object",
159
+ "properties": {
160
+ "foundryId": {
161
+ "$ref": "#/$defs/foundryIdShort"
162
+ }
163
+ },
164
+ "required": [
165
+ "foundryId"
166
+ ]
167
+ }
168
+ }
169
+ },
170
+ "required": [
171
+ "type"
172
+ ]
173
+ },
174
+ "_foundryActivityObject_damage": {
117
175
  "type": "object",
118
176
  "properties": {
177
+ "consumption": {
178
+ "type": "object",
179
+ "properties": {
180
+ "targets": {
181
+ "type": "array",
182
+ "items": {
183
+ "type": "object",
184
+ "properties": {
185
+ "target": {
186
+ "oneOf": [
187
+ {
188
+ "type": "string"
189
+ },
190
+ {
191
+ "type": "object",
192
+ "properties": {
193
+ "prop": {
194
+ "type": "string"
195
+ },
196
+ "uid": {
197
+ "type": "string"
198
+ }
199
+ },
200
+ "required": [
201
+ "prop",
202
+ "uid"
203
+ ],
204
+ "additionalProperties": false
205
+ }
206
+ ]
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ },
213
+ "effects": {
214
+ "type": "array",
215
+ "items": {
216
+ "type": "object",
217
+ "properties": {
218
+ "foundryId": {
219
+ "$ref": "#/$defs/foundryIdShort"
220
+ }
221
+ },
222
+ "required": [
223
+ "foundryId"
224
+ ]
225
+ }
226
+ },
119
227
  "type": {
120
- "const": "utility"
228
+ "const": "damage"
229
+ }
230
+ },
231
+ "required": [
232
+ "type"
233
+ ]
234
+ },
235
+ "_foundryActivityObject_save": {
236
+ "type": "object",
237
+ "properties": {
238
+ "consumption": {
239
+ "type": "object",
240
+ "properties": {
241
+ "targets": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "object",
245
+ "properties": {
246
+ "target": {
247
+ "oneOf": [
248
+ {
249
+ "type": "string"
250
+ },
251
+ {
252
+ "type": "object",
253
+ "properties": {
254
+ "prop": {
255
+ "type": "string"
256
+ },
257
+ "uid": {
258
+ "type": "string"
259
+ }
260
+ },
261
+ "required": [
262
+ "prop",
263
+ "uid"
264
+ ],
265
+ "additionalProperties": false
266
+ }
267
+ ]
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ },
274
+ "effects": {
275
+ "type": "array",
276
+ "items": {
277
+ "type": "object",
278
+ "properties": {
279
+ "foundryId": {
280
+ "$ref": "#/$defs/foundryIdShort"
281
+ }
282
+ },
283
+ "required": [
284
+ "foundryId"
285
+ ]
286
+ }
287
+ },
288
+ "type": {
289
+ "const": "save"
290
+ }
291
+ },
292
+ "required": [
293
+ "type"
294
+ ]
295
+ },
296
+ "_foundryActivityObject_heal": {
297
+ "type": "object",
298
+ "properties": {
299
+ "consumption": {
300
+ "type": "object",
301
+ "properties": {
302
+ "targets": {
303
+ "type": "array",
304
+ "items": {
305
+ "type": "object",
306
+ "properties": {
307
+ "target": {
308
+ "oneOf": [
309
+ {
310
+ "type": "string"
311
+ },
312
+ {
313
+ "type": "object",
314
+ "properties": {
315
+ "prop": {
316
+ "type": "string"
317
+ },
318
+ "uid": {
319
+ "type": "string"
320
+ }
321
+ },
322
+ "required": [
323
+ "prop",
324
+ "uid"
325
+ ],
326
+ "additionalProperties": false
327
+ }
328
+ ]
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ },
335
+ "effects": {
336
+ "type": "array",
337
+ "items": {
338
+ "type": "object",
339
+ "properties": {
340
+ "foundryId": {
341
+ "$ref": "#/$defs/foundryIdShort"
342
+ }
343
+ },
344
+ "required": [
345
+ "foundryId"
346
+ ]
347
+ }
348
+ },
349
+ "type": {
350
+ "const": "heal"
351
+ }
352
+ },
353
+ "required": [
354
+ "type"
355
+ ]
356
+ },
357
+ "_foundryActivityObject_utility": {
358
+ "type": "object",
359
+ "properties": {
360
+ "consumption": {
361
+ "type": "object",
362
+ "properties": {
363
+ "targets": {
364
+ "type": "array",
365
+ "items": {
366
+ "type": "object",
367
+ "properties": {
368
+ "target": {
369
+ "oneOf": [
370
+ {
371
+ "type": "string"
372
+ },
373
+ {
374
+ "type": "object",
375
+ "properties": {
376
+ "prop": {
377
+ "type": "string"
378
+ },
379
+ "uid": {
380
+ "type": "string"
381
+ }
382
+ },
383
+ "required": [
384
+ "prop",
385
+ "uid"
386
+ ],
387
+ "additionalProperties": false
388
+ }
389
+ ]
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
121
395
  },
122
396
  "effects": {
123
397
  "type": "array",
@@ -132,6 +406,9 @@
132
406
  "foundryId"
133
407
  ]
134
408
  }
409
+ },
410
+ "type": {
411
+ "const": "utility"
135
412
  }
136
413
  },
137
414
  "required": [
@@ -140,6 +417,15 @@
140
417
  },
141
418
  "foundryActivityObject": {
142
419
  "anyOf": [
420
+ {
421
+ "$ref": "#/$defs/_foundryActivityObject_damage"
422
+ },
423
+ {
424
+ "$ref": "#/$defs/_foundryActivityObject_save"
425
+ },
426
+ {
427
+ "$ref": "#/$defs/_foundryActivityObject_heal"
428
+ },
143
429
  {
144
430
  "$ref": "#/$defs/_foundryActivityObject_utility"
145
431
  }
@@ -158,6 +444,9 @@
158
444
  "img": {
159
445
  "type": "string"
160
446
  },
447
+ "description": {
448
+ "type": "string"
449
+ },
161
450
  "changes": {
162
451
  "type": "array",
163
452
  "items": {
@@ -279,6 +568,20 @@
279
568
  ]
280
569
  }
281
570
  ]
571
+ },
572
+ {
573
+ "description": "An effect with no functional changes, but descriptive text. Should only be used for effects which cannot be otherwise automated.",
574
+ "allOf": [
575
+ {
576
+ "$ref": "#/$defs/_foundryEffectObject"
577
+ },
578
+ {
579
+ "type": "object",
580
+ "required": [
581
+ "description"
582
+ ]
583
+ }
584
+ ]
282
585
  }
283
586
  ]
284
587
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }