@heroiclands/package-build 22.4.1 → 22.4.2
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/CHANGELOG.md +14 -0
- package/engine/actor-compiler.mjs +26 -1
- package/engine/document-subtypes.mjs +24 -7
- package/hm3/actors.mjs +42 -0
- package/package.json +1 -1
- package/types/engine/actor-compiler.d.mts +20 -0
- package/types/engine/document-subtypes.d.mts +14 -7
- package/types/hm3/actors.d.mts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @heroiclands/package-build
|
|
2
2
|
|
|
3
|
+
## 22.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8dedb23: **A module embedding HM3 spells, invocations or psionics compiles.** A being's
|
|
8
|
+
embedded `spell`, `invocation` or `psionic` reference that names no shortcode
|
|
9
|
+
template and no `data.icon` of its own now takes that subtype's own default
|
|
10
|
+
art — the icon HM3 itself assigns a freshly created item of that kind —
|
|
11
|
+
instead of the build refusing the actor outright.
|
|
12
|
+
- 54109cf: **A module embedding HârnMaster 3 weapons compiles.** A being's `(type,
|
|
13
|
+
shortcode)` reference into HM3's one-to-many `weapongear` row resolves when
|
|
14
|
+
its `type` names one of the row's own subtypes — `weapongear` or
|
|
15
|
+
`missilegear` — instead of being refused as ambiguous.
|
|
16
|
+
|
|
3
17
|
## 22.4.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -646,6 +646,29 @@ export class SystemActorCompiler extends BasePackCompiler {
|
|
|
646
646
|
return referencedSubtype(this.documentSubtypes, type, "Item");
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
/**
|
|
650
|
+
* The default art for an embedded item's type, when the entry names none
|
|
651
|
+
* of its own and copies no template that carries one.
|
|
652
|
+
*
|
|
653
|
+
* **The base case is {@link itemArt}**, keyed by the note vocabulary — the
|
|
654
|
+
* same table an item note's own compile defaults from, because most
|
|
655
|
+
* references are written in that vocabulary too (`weapongear`, `skill`,
|
|
656
|
+
* `armorgear`). It is not the whole answer: a reference into a one-to-many
|
|
657
|
+
* row may instead name one of the row's own **subtypes** directly — HM3's
|
|
658
|
+
* `spell`, `invocation` and `psionic` are never a note's own `type`, only
|
|
659
|
+
* `mysticalability`'s `hm3.type` discriminator ever writes them, so no
|
|
660
|
+
* note-type table has a row for them. A system whose one-to-many rows are
|
|
661
|
+
* addressed that way overrides this to answer for those subtypes too; see
|
|
662
|
+
* `hm3/actors.mjs`.
|
|
663
|
+
*
|
|
664
|
+
* @param {string} type - The **note** type the reference names.
|
|
665
|
+
* @param {string} subType - The document subtype it resolved to.
|
|
666
|
+
* @returns {string} The default image path.
|
|
667
|
+
*/
|
|
668
|
+
embeddedItemArt(type, subType) {
|
|
669
|
+
return itemArt(type, this.system);
|
|
670
|
+
}
|
|
671
|
+
|
|
649
672
|
/**
|
|
650
673
|
* Read an entry's `model:` — the address of the item it is a copy of.
|
|
651
674
|
*
|
|
@@ -825,7 +848,9 @@ export class SystemActorCompiler extends BasePackCompiler {
|
|
|
825
848
|
// default answers last. Nullish coalescing throughout, so `icon: ""`
|
|
826
849
|
// ships blank on purpose rather than collecting a default.
|
|
827
850
|
merged.img =
|
|
828
|
-
this.artPath(overlay ?? {}, "icon") ??
|
|
851
|
+
this.artPath(overlay ?? {}, "icon") ??
|
|
852
|
+
merged.img ??
|
|
853
|
+
this.embeddedItemArt(type, /** @type {string} */ (subType));
|
|
829
854
|
const identity = embeddedIdentity(merged, this.system);
|
|
830
855
|
const claim = `${actorId}\u0000${itemAddress(/** @type {string} */ (subType), identity)}`;
|
|
831
856
|
const first = this.#embeddedClaims.get(claim);
|
|
@@ -329,7 +329,7 @@ export function documentSubtype(map, noteType, fm, { file, absPath } = {}) {
|
|
|
329
329
|
* dependency catalogue actually carry, and a reference is translated forward
|
|
330
330
|
* here before it is looked up.
|
|
331
331
|
*
|
|
332
|
-
*
|
|
332
|
+
* Five answers, and only the last refuses:
|
|
333
333
|
*
|
|
334
334
|
* - _A one-to-one row_ → the subtype it declares. `armor` addresses an
|
|
335
335
|
* `armorgear`.
|
|
@@ -340,12 +340,19 @@ export function documentSubtype(map, noteType, fm, { file, absPath } = {}) {
|
|
|
340
340
|
* existed.
|
|
341
341
|
* - _A row for another document class_ → a problem. A being is not an item,
|
|
342
342
|
* however the address is spelled.
|
|
343
|
-
* - _A one-to-many
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
343
|
+
* - _A one-to-many row, named by one of its own permitted subtypes_ → that
|
|
344
|
+
* subtype. HM3's `weapongear` row is keyed by the note type `weapongear` but
|
|
345
|
+
* permits `["weapongear", "missilegear"]`; a reference spelled `weapongear`
|
|
346
|
+
* is not ambiguous — it already names the subtype it wants, the same as a
|
|
347
|
+
* reference spelled `missilegear` does by matching no row at all and taking
|
|
348
|
+
* the unmapped fallback above. Only the row's own key can coincide with one
|
|
349
|
+
* of its subtypes, so this is never a second guess at the note's
|
|
350
|
+
* frontmatter — the row was looked up by this exact spelling.
|
|
351
|
+
* - _A one-to-many row, named by neither the row's other permitted subtypes
|
|
352
|
+
* nor resolved above_ → a problem naming the candidates. The note that owns
|
|
353
|
+
* such a row resolves it from its own frontmatter block; a reference naming
|
|
354
|
+
* only the row has no block to read a discriminator from, so nothing here
|
|
355
|
+
* can choose, and choosing anyway would be right about half the time.
|
|
349
356
|
*
|
|
350
357
|
* A **retired** spelling is refused by name before any of that. Without it a
|
|
351
358
|
* reference left behind by a merge would take the unmapped fallback and address
|
|
@@ -392,6 +399,16 @@ export function referencedSubtype(map, noteType, document) {
|
|
|
392
399
|
}
|
|
393
400
|
if (!row.subType) {
|
|
394
401
|
const permitted = /** @type {readonly string[]} */ (row.subTypes);
|
|
402
|
+
// The reference is not ambiguous when its own spelling names one of the
|
|
403
|
+
// row's permitted subtypes rather than merely the row itself: a
|
|
404
|
+
// `weapongear` reference into HM3's one-to-many `weapongear` row already
|
|
405
|
+
// says which subtype it wants, in the same way a `missilegear`
|
|
406
|
+
// reference does by never matching this row's key at all. Only a
|
|
407
|
+
// reference that names the row without naming a subtype is genuinely
|
|
408
|
+
// undecidable.
|
|
409
|
+
if (permitted.includes(currentType(noteType))) {
|
|
410
|
+
return { subType: currentType(noteType) };
|
|
411
|
+
}
|
|
395
412
|
return {
|
|
396
413
|
problem:
|
|
397
414
|
`a "${noteType}" note compiles into more than one ${map.system} ` +
|
package/hm3/actors.mjs
CHANGED
|
@@ -162,6 +162,35 @@ function defaultActorImg(subType) {
|
|
|
162
162
|
return img;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Default art for the three subtypes HM3's one-to-many `mysticalability` row
|
|
167
|
+
* permits — `spell`, `invocation` and `psionic` — keyed by the **document**
|
|
168
|
+
* subtype rather than the note type.
|
|
169
|
+
*
|
|
170
|
+
* `hm3/default-item-art.mjs` is keyed the other way on purpose: a registry
|
|
171
|
+
* entry is addressed by what a note calls itself, and no note ever authors
|
|
172
|
+
* `type: spell` — only `mysticalability`, discriminated by its own
|
|
173
|
+
* `hm3.type`. But a being's `(type, shortcode)` reference has no note to
|
|
174
|
+
* discriminate, so it names the subtype it wants directly, and an embedded
|
|
175
|
+
* entry that supplies neither a template's own `img` nor a `data.icon` of its
|
|
176
|
+
* own reaches {@link Hm3Actors#embeddedItemArt} in exactly that vocabulary.
|
|
177
|
+
*
|
|
178
|
+
* Each path is the icon HM3's own item sheet assigns a freshly created item
|
|
179
|
+
* of that subtype — `HM3.defaultMagicIconName`, `HM3.defaultRitualIconName`
|
|
180
|
+
* and `HM3.defaultPsionicsIconName` in the system's own `config.js` — so a
|
|
181
|
+
* compiled item looks like one created in the client. `weapongear` and
|
|
182
|
+
* `missilegear` need no row here: a reference spelled either resolves through
|
|
183
|
+
* `HM3_DEFAULT_ITEM_ART`'s own `weapongear` key (see #582), and every
|
|
184
|
+
* predefined weapon and missile in HM3's catalogue carries its own `img`.
|
|
185
|
+
*
|
|
186
|
+
* @type {Readonly<Record<string, string>>}
|
|
187
|
+
*/
|
|
188
|
+
const EMBEDDED_ITEM_ART = Object.freeze({
|
|
189
|
+
invocation: "systems/hm3/images/icons/svg/circle.svg",
|
|
190
|
+
psionic: "systems/hm3/images/icons/svg/psionics.svg",
|
|
191
|
+
spell: "systems/hm3/images/icons/svg/pentacle.svg",
|
|
192
|
+
});
|
|
193
|
+
|
|
165
194
|
/**
|
|
166
195
|
* HM3's Actor compile pass.
|
|
167
196
|
*
|
|
@@ -192,6 +221,19 @@ export class Hm3Actors extends SystemActorCompiler {
|
|
|
192
221
|
return this.buildActor(this.itemsMap, fm, markdown);
|
|
193
222
|
}
|
|
194
223
|
|
|
224
|
+
/**
|
|
225
|
+
* @inheritdoc
|
|
226
|
+
*
|
|
227
|
+
* Answers for `spell`, `invocation` and `psionic` too — see
|
|
228
|
+
* {@link EMBEDDED_ITEM_ART} — falling back to the engine's note-type
|
|
229
|
+
* table for every other reference, `weapongear` and `missilegear`
|
|
230
|
+
* included.
|
|
231
|
+
*/
|
|
232
|
+
embeddedItemArt(type, subType) {
|
|
233
|
+
const art = /** @type {Record<string, string|undefined>} */ (EMBEDDED_ITEM_ART)[subType];
|
|
234
|
+
return art ?? super.embeddedItemArt(type, subType);
|
|
235
|
+
}
|
|
236
|
+
|
|
195
237
|
/**
|
|
196
238
|
* Build every embedded item an HM3 actor carries, from `hm3.items`.
|
|
197
239
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroiclands/package-build",
|
|
3
|
-
"version": "22.4.
|
|
3
|
+
"version": "22.4.2",
|
|
4
4
|
"description": "Shared toolchain for building and shipping a HeroicLands Foundry VTT package — content compilation, manifest, localization, staging, bundle, release and deployment.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -280,6 +280,26 @@ export class SystemActorCompiler extends BasePackCompiler {
|
|
|
280
280
|
* subtype, or why the reference names none.
|
|
281
281
|
*/
|
|
282
282
|
embeddedSubtype(type: string): import("./document-subtypes.mjs").ReferencedSubtype;
|
|
283
|
+
/**
|
|
284
|
+
* The default art for an embedded item's type, when the entry names none
|
|
285
|
+
* of its own and copies no template that carries one.
|
|
286
|
+
*
|
|
287
|
+
* **The base case is {@link itemArt}**, keyed by the note vocabulary — the
|
|
288
|
+
* same table an item note's own compile defaults from, because most
|
|
289
|
+
* references are written in that vocabulary too (`weapongear`, `skill`,
|
|
290
|
+
* `armorgear`). It is not the whole answer: a reference into a one-to-many
|
|
291
|
+
* row may instead name one of the row's own **subtypes** directly — HM3's
|
|
292
|
+
* `spell`, `invocation` and `psionic` are never a note's own `type`, only
|
|
293
|
+
* `mysticalability`'s `hm3.type` discriminator ever writes them, so no
|
|
294
|
+
* note-type table has a row for them. A system whose one-to-many rows are
|
|
295
|
+
* addressed that way overrides this to answer for those subtypes too; see
|
|
296
|
+
* `hm3/actors.mjs`.
|
|
297
|
+
*
|
|
298
|
+
* @param {string} type - The **note** type the reference names.
|
|
299
|
+
* @param {string} subType - The document subtype it resolved to.
|
|
300
|
+
* @returns {string} The default image path.
|
|
301
|
+
*/
|
|
302
|
+
embeddedItemArt(type: string, subType: string): string;
|
|
283
303
|
/**
|
|
284
304
|
* Read an entry's `model:` — the address of the item it is a copy of.
|
|
285
305
|
*
|
|
@@ -140,7 +140,7 @@ export function documentSubtype(map: DocumentSubtypeMap, noteType: string | unde
|
|
|
140
140
|
* dependency catalogue actually carry, and a reference is translated forward
|
|
141
141
|
* here before it is looked up.
|
|
142
142
|
*
|
|
143
|
-
*
|
|
143
|
+
* Five answers, and only the last refuses:
|
|
144
144
|
*
|
|
145
145
|
* - _A one-to-one row_ → the subtype it declares. `armor` addresses an
|
|
146
146
|
* `armorgear`.
|
|
@@ -151,12 +151,19 @@ export function documentSubtype(map: DocumentSubtypeMap, noteType: string | unde
|
|
|
151
151
|
* existed.
|
|
152
152
|
* - _A row for another document class_ → a problem. A being is not an item,
|
|
153
153
|
* however the address is spelled.
|
|
154
|
-
* - _A one-to-many
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
154
|
+
* - _A one-to-many row, named by one of its own permitted subtypes_ → that
|
|
155
|
+
* subtype. HM3's `weapongear` row is keyed by the note type `weapongear` but
|
|
156
|
+
* permits `["weapongear", "missilegear"]`; a reference spelled `weapongear`
|
|
157
|
+
* is not ambiguous — it already names the subtype it wants, the same as a
|
|
158
|
+
* reference spelled `missilegear` does by matching no row at all and taking
|
|
159
|
+
* the unmapped fallback above. Only the row's own key can coincide with one
|
|
160
|
+
* of its subtypes, so this is never a second guess at the note's
|
|
161
|
+
* frontmatter — the row was looked up by this exact spelling.
|
|
162
|
+
* - _A one-to-many row, named by neither the row's other permitted subtypes
|
|
163
|
+
* nor resolved above_ → a problem naming the candidates. The note that owns
|
|
164
|
+
* such a row resolves it from its own frontmatter block; a reference naming
|
|
165
|
+
* only the row has no block to read a discriminator from, so nothing here
|
|
166
|
+
* can choose, and choosing anyway would be right about half the time.
|
|
160
167
|
*
|
|
161
168
|
* A **retired** spelling is refused by name before any of that. Without it a
|
|
162
169
|
* reference left behind by a merge would take the unmapped fallback and address
|
package/types/hm3/actors.d.mts
CHANGED
|
@@ -15,6 +15,15 @@ export class Hm3Actors extends SystemActorCompiler {
|
|
|
15
15
|
* @type {import("../engine/document-subtypes.mjs").DocumentSubtypeMap}
|
|
16
16
|
*/
|
|
17
17
|
static documentSubtypes: import("../engine/document-subtypes.mjs").DocumentSubtypeMap;
|
|
18
|
+
/**
|
|
19
|
+
* @inheritdoc
|
|
20
|
+
*
|
|
21
|
+
* Answers for `spell`, `invocation` and `psionic` too — see
|
|
22
|
+
* {@link EMBEDDED_ITEM_ART} — falling back to the engine's note-type
|
|
23
|
+
* table for every other reference, `weapongear` and `missilegear`
|
|
24
|
+
* included.
|
|
25
|
+
*/
|
|
26
|
+
embeddedItemArt(type: any, subType: any): string;
|
|
18
27
|
/**
|
|
19
28
|
* Build every embedded item an HM3 actor carries, from `hm3.items`.
|
|
20
29
|
*
|