@archivist-gg/dnd5e 0.3.1 → 0.3.4
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/LICENSES/SRD.md +25 -6
- package/dist/armor/armor.codec.js +4 -3
- package/dist/armor/armor.parser.js +3 -2
- package/dist/armor/armor.schema.d.ts +4 -0
- package/dist/armor/armor.schema.js +2 -1
- package/dist/armor/armor.types.d.ts +8 -0
- package/dist/background/background.codec.js +7 -6
- package/dist/background/background.parser.js +6 -5
- package/dist/background/background.schema.d.ts +26 -0
- package/dist/background/background.schema.js +5 -4
- package/dist/background/background.types.d.ts +22 -0
- package/dist/{chunk-4TIJKN6O.js → chunk-23LZLBJK.js} +1 -1
- package/dist/{chunk-AFKTJXRA.js → chunk-2DFENQIJ.js} +18 -0
- package/dist/chunk-2FRUSVZS.js +489 -0
- package/dist/chunk-4FWNK4FD.js +159 -0
- package/dist/chunk-4U55VNC7.js +22 -0
- package/dist/{chunk-4JHOHWBI.js → chunk-4XTNPNQB.js} +1 -1
- package/dist/{chunk-HCP3GMHS.js → chunk-5N2GW72F.js} +15 -2
- package/dist/{chunk-42Y5IJKT.js → chunk-5U5FFFA3.js} +5 -1
- package/dist/{chunk-4F6AIZ36.js → chunk-5XMQPTHD.js} +1 -1
- package/dist/{chunk-GJOI2GHP.js → chunk-6GNXYAYP.js} +1 -1
- package/dist/chunk-6PKV5V2H.js +178 -0
- package/dist/{chunk-66XXW2Z2.js → chunk-6PXTNCBP.js} +2 -2
- package/dist/chunk-6X2NV665.js +33 -0
- package/dist/{chunk-LV4SNWZQ.js → chunk-6X4KUDMU.js} +8 -1
- package/dist/{chunk-ZMR77DDL.js → chunk-AW3EHF3L.js} +1 -1
- package/dist/chunk-CJYCVNW2.js +7 -0
- package/dist/chunk-COEOOQX2.js +133 -0
- package/dist/{chunk-XTIQWSFM.js → chunk-D5U7GMPX.js} +1 -1
- package/dist/{chunk-RAWJTA45.js → chunk-DEEHHLAP.js} +1 -1
- package/dist/{chunk-6IRYTM5V.js → chunk-DPUJDOKV.js} +119 -28
- package/dist/{chunk-73HOFQQ5.js → chunk-ESS46GR4.js} +1 -1
- package/dist/chunk-EVMUJYUD.js +195 -0
- package/dist/{chunk-2BWAID3Y.js → chunk-FDBWYMZK.js} +29 -3
- package/dist/{chunk-K6Q5OUGK.js → chunk-GFZ7PITJ.js} +86 -10
- package/dist/chunk-H7KBLR4X.js +81 -0
- package/dist/{chunk-L7E2UT5A.js → chunk-HB7XZXDK.js} +5 -1
- package/dist/{chunk-BIK4DFWK.js → chunk-HJ5EEZ47.js} +1 -1
- package/dist/{chunk-6NK2MUD3.js → chunk-HZA7OE7N.js} +9 -2
- package/dist/{chunk-TN6ZLTNU.js → chunk-I2NDWFDD.js} +51 -4
- package/dist/{chunk-RSDRMH54.js → chunk-IMZFOOVL.js} +1 -1
- package/dist/{chunk-3DZ74AKK.js → chunk-IN4M4X7P.js} +8 -2
- package/dist/chunk-IUAAXXNO.js +58 -0
- package/dist/{chunk-XJNECUPT.js → chunk-JC5UNIVM.js} +19 -0
- package/dist/chunk-JJ46T5XX.js +297 -0
- package/dist/{chunk-SE7AZDR3.js → chunk-JRDPUDT5.js} +29 -3
- package/dist/{chunk-24GFQU7T.js → chunk-JSZ4H6AQ.js} +1 -1
- package/dist/chunk-KU3YLF6D.js +106 -0
- package/dist/{chunk-5INR4NSL.js → chunk-LDDCNPHD.js} +1 -1
- package/dist/{chunk-5ZBE4CWV.js → chunk-LMBAEIP6.js} +1 -1
- package/dist/chunk-LVQLWRCU.js +15 -0
- package/dist/chunk-MI7P3NX3.js +161 -0
- package/dist/chunk-O4SRD3J5.js +165 -0
- package/dist/{chunk-D3CLOBE3.js → chunk-OSQFPGLM.js} +44 -8
- package/dist/chunk-OZP6JFGT.js +162 -0
- package/dist/{chunk-NAEPSZAM.js → chunk-PDJSUH24.js} +24 -2
- package/dist/chunk-PP2UHLBA.js +50 -0
- package/dist/chunk-PVCEA4HZ.js +6 -0
- package/dist/{chunk-XLSVNUTK.js → chunk-R3VAKWKW.js} +1 -1
- package/dist/chunk-RIXI5D3R.js +89 -0
- package/dist/chunk-RLGQ5PZZ.js +16 -0
- package/dist/chunk-S7REMWW4.js +21 -0
- package/dist/{chunk-7VJ6BOA5.js → chunk-SMLXZUBH.js} +9 -1
- package/dist/{chunk-NXSWH3AE.js → chunk-T26ZVCL5.js} +1 -1
- package/dist/chunk-TOM66P2P.js +38 -0
- package/dist/chunk-UA5KS2PL.js +26 -0
- package/dist/{chunk-N6N74K6X.js → chunk-UBBKSYBY.js} +1 -1
- package/dist/{chunk-353WXS6S.js → chunk-UIRMA5KM.js} +1 -1
- package/dist/{chunk-GE4TLPWM.js → chunk-US5IKYCW.js} +1 -1
- package/dist/chunk-UXPGW4TI.js +101 -0
- package/dist/chunk-VQAXTIBW.js +100 -0
- package/dist/{chunk-WP2CX2JO.js → chunk-WELIKLZF.js} +22 -1
- package/dist/chunk-WPWOHGPI.js +172 -0
- package/dist/{chunk-GZ46OVGZ.js → chunk-WSVMLNTO.js} +1 -1
- package/dist/{chunk-4LZJXJJS.js → chunk-WXWPK3LI.js} +6 -2
- package/dist/{chunk-ZZGEVJKX.js → chunk-XBQMCEI2.js} +1 -1
- package/dist/{chunk-PHQRGDRQ.js → chunk-XGOFP7AQ.js} +5 -1
- package/dist/chunk-XJ2F2WO6.js +8 -0
- package/dist/chunk-XQCSGNXE.js +1580 -0
- package/dist/chunk-YBLDE5CG.js +42 -0
- package/dist/{chunk-JEYQU3JT.js → chunk-YHYTW5QA.js} +2 -18
- package/dist/{chunk-TLYDBT5F.js → chunk-YJJTISBN.js} +64 -7
- package/dist/{chunk-PZOWBI3B.js → chunk-YLL2QXY2.js} +7 -2
- package/dist/{chunk-MDEJHMKK.js → chunk-ZONJ66NE.js} +26 -5
- package/dist/class/class.codec.js +12 -9
- package/dist/class/class.parser.js +11 -8
- package/dist/class/class.schema.d.ts +55 -3
- package/dist/class/class.schema.js +9 -7
- package/dist/class/class.types.d.ts +48 -3
- package/dist/condition/condition.codec.d.ts +9 -0
- package/dist/condition/condition.entity-type.d.ts +2 -0
- package/dist/condition/condition.parser.d.ts +13 -0
- package/dist/condition/condition.parser.js +7 -0
- package/dist/condition/condition.schema.d.ts +29 -0
- package/dist/condition/condition.types.d.ts +15 -0
- package/dist/condition/condition.types.js +0 -0
- package/dist/dnd/constants.d.ts +22 -0
- package/dist/dnd/constants.js +9 -3
- package/dist/dnd/formula-tags.js +2 -2
- package/dist/dnd/math.d.ts +26 -0
- package/dist/dnd/math.js +12 -2
- package/dist/dnd/prose-tags.js +1 -1
- package/dist/dnd/resource-formula.d.ts +36 -10
- package/dist/dnd/resource-formula.js +10 -155
- package/dist/dnd/srd-tag-converter.js +3 -3
- package/dist/dnd/tag-grammar.js +1 -1
- package/dist/dnd/warn-once.d.ts +2 -0
- package/dist/dnd/warn-once.js +8 -0
- package/dist/entities/base-item-resolver.js +2 -2
- package/dist/entities/slug.d.ts +13 -0
- package/dist/entities/slug.js +5 -3
- package/dist/entities/wikilink-display.d.ts +3 -0
- package/dist/entities/wikilink-display.js +10 -0
- package/dist/feat/feat.category-codes.d.ts +32 -0
- package/dist/feat/feat.category-codes.js +14 -0
- package/dist/feat/feat.codec.js +7 -5
- package/dist/feat/feat.parser.js +6 -4
- package/dist/feat/feat.schema.d.ts +230 -0
- package/dist/feat/feat.schema.js +5 -3
- package/dist/feat/feat.types.d.ts +37 -1
- package/dist/index.js +2033 -6907
- package/dist/item/item.codec.js +4 -3
- package/dist/item/item.enrichment.js +4 -4
- package/dist/item/item.parser.js +3 -2
- package/dist/item/item.schema.d.ts +69 -3
- package/dist/item/item.schema.js +2 -1
- package/dist/item/item.types.d.ts +69 -3
- package/dist/monster/monster.codec.d.ts +7 -6
- package/dist/monster/monster.enrichment.js +4 -4
- package/dist/monster/monster.format.d.ts +135 -0
- package/dist/monster/monster.format.js +78 -0
- package/dist/monster/monster.parser.d.ts +6 -1
- package/dist/monster/monster.parser.js +10 -1
- package/dist/monster/monster.schema.d.ts +369 -0
- package/dist/monster/monster.schema.js +34 -0
- package/dist/monster/monster.types.d.ts +200 -14
- package/dist/optional-feature/optional-feature.codec.js +6 -5
- package/dist/optional-feature/optional-feature.parser.js +5 -4
- package/dist/optional-feature/optional-feature.schema.d.ts +176 -0
- package/dist/optional-feature/optional-feature.schema.js +4 -3
- package/dist/pack.d.ts +1 -1
- package/dist/pc/conditions.constants.d.ts +0 -1
- package/dist/pc/conditions.constants.js +1 -3
- package/dist/pc/decision-recognizer.js +1 -1
- package/dist/pc/pc.additional-spells.d.ts +47 -0
- package/dist/pc/pc.additional-spells.js +23 -0
- package/dist/pc/pc.asi-flatten.d.ts +18 -0
- package/dist/pc/pc.decision-engine.d.ts +105 -17
- package/dist/pc/pc.decision-engine.js +28 -12
- package/dist/pc/pc.defense-normalize.d.ts +11 -0
- package/dist/pc/pc.defense-normalize.js +6 -0
- package/dist/pc/pc.equipment.d.ts +30 -1
- package/dist/pc/pc.equipment.js +12 -8
- package/dist/pc/pc.feature-effects.d.ts +225 -11
- package/dist/pc/pc.feature-effects.js +21 -5
- package/dist/pc/pc.parser.js +2 -2
- package/dist/pc/pc.pools.d.ts +11 -3
- package/dist/pc/pc.pools.js +9 -13
- package/dist/pc/pc.proficiencies.d.ts +54 -29
- package/dist/pc/pc.proficiencies.js +74 -95
- package/dist/pc/pc.proficiency-grants.d.ts +58 -0
- package/dist/pc/pc.proficiency-normalize.d.ts +24 -0
- package/dist/pc/pc.proficiency-normalize.js +12 -0
- package/dist/pc/pc.proficiency-query.d.ts +13 -0
- package/dist/pc/pc.proficiency-query.js +1 -1
- package/dist/pc/pc.recalc.d.ts +69 -14
- package/dist/pc/pc.recalc.js +261 -122
- package/dist/pc/pc.resolver.d.ts +34 -8
- package/dist/pc/pc.resolver.js +27 -12
- package/dist/pc/pc.resource-seed.d.ts +3 -2
- package/dist/pc/pc.resource-seed.js +19 -17
- package/dist/pc/pc.resources.d.ts +87 -0
- package/dist/pc/pc.resources.js +21 -0
- package/dist/pc/pc.rest.d.ts +10 -1
- package/dist/pc/pc.rest.js +66 -12
- package/dist/pc/pc.schema.d.ts +139 -3
- package/dist/pc/pc.schema.js +4 -2
- package/dist/pc/pc.slotting.js +3 -3
- package/dist/pc/pc.spellcasting.d.ts +75 -6
- package/dist/pc/pc.spellcasting.js +16 -6
- package/dist/pc/pc.table-column.d.ts +23 -0
- package/dist/pc/pc.table-column.js +13 -3
- package/dist/pc/pc.types.d.ts +251 -12
- package/dist/pc/pool-layout.d.ts +47 -0
- package/dist/pc/pool-layout.js +16 -0
- package/dist/pc/roll-scope.d.ts +2 -0
- package/dist/pc/roll-scope.js +8 -0
- package/dist/pc/roll-tag-labels.d.ts +40 -0
- package/dist/pc/roll-tag-labels.js +17 -0
- package/dist/pc/spell-source.d.ts +21 -0
- package/dist/pc/spell-source.js +13 -0
- package/dist/race/race.codec.js +9 -7
- package/dist/race/race.parser.js +8 -6
- package/dist/race/race.schema.d.ts +51 -1
- package/dist/race/race.schema.js +8 -5
- package/dist/race/race.structural.d.ts +7 -0
- package/dist/race/race.structural.js +6 -0
- package/dist/race/race.types.d.ts +20 -0
- package/dist/schemas/attack-schema.d.ts +5 -0
- package/dist/schemas/caster-type-schema.d.ts +14 -0
- package/dist/schemas/caster-type-schema.js +6 -0
- package/dist/schemas/choice-schema.js +2 -2
- package/dist/schemas/entity-extras-schema.d.ts +53 -0
- package/dist/schemas/entity-extras-schema.js +10 -0
- package/dist/schemas/equipment-grant-schema.d.ts +2 -0
- package/dist/schemas/equipment-grant-schema.js +1 -1
- package/dist/schemas/feature-alias.d.ts +34 -0
- package/dist/schemas/feature-effect-schema.d.ts +124 -0
- package/dist/schemas/feature-effect-schema.js +1 -1
- package/dist/schemas/feature-schema.d.ts +8 -0
- package/dist/schemas/feature-schema.js +6 -4
- package/dist/schemas/resource-schema.d.ts +43 -0
- package/dist/schemas/resource-schema.js +1 -1
- package/dist/schemas/selection-pool-schema.d.ts +2 -0
- package/dist/schemas/selection-pool-schema.js +1 -1
- package/dist/spell/spell.access.js +23 -3
- package/dist/spell/spell.codec.js +4 -3
- package/dist/spell/spell.enrichment.js +4 -4
- package/dist/spell/spell.parser.d.ts +30 -0
- package/dist/spell/spell.parser.js +9 -2
- package/dist/spell/spell.scaling.d.ts +27 -6
- package/dist/spell/spell.scaling.js +25 -6
- package/dist/spell/spell.schema.d.ts +44 -2
- package/dist/spell/spell.schema.js +2 -1
- package/dist/spell/spell.types.d.ts +14 -0
- package/dist/subclass/subclass.codec.d.ts +1 -1
- package/dist/subclass/subclass.codec.js +11 -8
- package/dist/subclass/subclass.parser.js +10 -7
- package/dist/subclass/subclass.schema.d.ts +54 -7
- package/dist/subclass/subclass.schema.js +8 -6
- package/dist/subclass/subclass.types.d.ts +20 -2
- package/dist/types/choice.d.ts +53 -2
- package/dist/types/choice.js +13 -1
- package/dist/types/equipment-grant.d.ts +8 -1
- package/dist/types/feature-effect.d.ts +78 -23
- package/dist/types/feature.d.ts +70 -1
- package/dist/types/optional-feature.types.d.ts +28 -0
- package/dist/types/resource.d.ts +21 -1
- package/dist/types/selection-pool.d.ts +17 -2
- package/dist/weapon/weapon.classify.js +2 -2
- package/dist/weapon/weapon.codec.js +4 -3
- package/dist/weapon/weapon.parser.js +3 -2
- package/dist/weapon/weapon.schema.d.ts +4 -0
- package/dist/weapon/weapon.schema.js +2 -1
- package/dist/weapon/weapon.types.d.ts +8 -0
- package/package.json +2 -2
- package/dist/chunk-5XUXXAQJ.js +0 -30
- package/dist/chunk-7P65Q426.js +0 -158
- package/dist/chunk-7TEK5KK7.js +0 -49
- package/dist/chunk-AIRFC5NQ.js +0 -143
- package/dist/chunk-CZPMTQOY.js +0 -68
- package/dist/chunk-N2JE7BWL.js +0 -81
- package/dist/chunk-NXR3BD2V.js +0 -90
- package/dist/chunk-O5EYMKFH.js +0 -6
- package/dist/chunk-Q5K6LWBZ.js +0 -45
- package/dist/chunk-TNUFPIXI.js +0 -1110
- package/dist/chunk-TZK36BU7.js +0 -38
- package/dist/chunk-W7HWMMBF.js +0 -46
- package/dist/chunk-Y4I74YEG.js +0 -33
package/dist/chunk-TNUFPIXI.js
DELETED
|
@@ -1,1110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ALL_LANGUAGES,
|
|
3
|
-
ALL_SKILL_SLUGS
|
|
4
|
-
} from "./chunk-7TEK5KK7.js";
|
|
5
|
-
import {
|
|
6
|
-
effectiveSpellcastingAbility,
|
|
7
|
-
normalizeKnownSpell,
|
|
8
|
-
resolveSpellcasting
|
|
9
|
-
} from "./chunk-6IRYTM5V.js";
|
|
10
|
-
import {
|
|
11
|
-
readTableColumn
|
|
12
|
-
} from "./chunk-5XUXXAQJ.js";
|
|
13
|
-
import {
|
|
14
|
-
recognizeDecision
|
|
15
|
-
} from "./chunk-JEYQU3JT.js";
|
|
16
|
-
import {
|
|
17
|
-
isItemEntity,
|
|
18
|
-
resolveEntityForEntry
|
|
19
|
-
} from "./chunk-N6N74K6X.js";
|
|
20
|
-
import {
|
|
21
|
-
bareEntitySlug
|
|
22
|
-
} from "./chunk-LV4SNWZQ.js";
|
|
23
|
-
import {
|
|
24
|
-
ABILITY_KEYS
|
|
25
|
-
} from "./chunk-WP2CX2JO.js";
|
|
26
|
-
|
|
27
|
-
// src/pc/pc.resolver.ts
|
|
28
|
-
var SLUG_RE = /^\[\[(.+?)\]\]$/;
|
|
29
|
-
function stripSlug(ref) {
|
|
30
|
-
if (!ref) return null;
|
|
31
|
-
const m = ref.match(SLUG_RE);
|
|
32
|
-
return m ? m[1] : ref;
|
|
33
|
-
}
|
|
34
|
-
function resolveOriginFeat(entities, originFeatRef) {
|
|
35
|
-
var _a, _b, _c;
|
|
36
|
-
if (!originFeatRef) return null;
|
|
37
|
-
const slug = wikilinkTailSlug(originFeatRef);
|
|
38
|
-
const feats = entities.search("", "feat", Number.POSITIVE_INFINITY);
|
|
39
|
-
const lookup = (s) => {
|
|
40
|
-
var _a2;
|
|
41
|
-
return (_a2 = feats.find((f) => f.slug === s)) != null ? _a2 : feats.find((f) => f.slug.endsWith(`_${s}`));
|
|
42
|
-
};
|
|
43
|
-
let reg = lookup(slug);
|
|
44
|
-
let variantName;
|
|
45
|
-
if (!reg) {
|
|
46
|
-
const rawTail = (_b = (_a = originFeatRef.replace(/^\[\[/, "").replace(/\]\]$/, "").split("/").pop()) == null ? void 0 : _a.trim()) != null ? _b : "";
|
|
47
|
-
const base = rawTail.replace(/\s*\([^()]*\)\s*$/, "").trim();
|
|
48
|
-
if (base && base !== rawTail) {
|
|
49
|
-
const baseReg = lookup(wikilinkTailSlug(`[[${base}]]`));
|
|
50
|
-
if (baseReg) {
|
|
51
|
-
reg = baseReg;
|
|
52
|
-
variantName = rawTail;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!reg) return null;
|
|
57
|
-
const data = reg.data;
|
|
58
|
-
const feat = data.slug == null ? { ...data, slug: reg.slug } : data;
|
|
59
|
-
return { feat, display: (_c = variantName != null ? variantName : feat.name) != null ? _c : slug };
|
|
60
|
-
}
|
|
61
|
-
var PCResolver = class {
|
|
62
|
-
constructor(entities) {
|
|
63
|
-
this.entities = entities;
|
|
64
|
-
}
|
|
65
|
-
/** Exposed so recalc() can apply equipment bonuses (Pass A / Pass B). */
|
|
66
|
-
get registry() {
|
|
67
|
-
return this.entities;
|
|
68
|
-
}
|
|
69
|
-
resolve(character) {
|
|
70
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
|
-
const warnings = [];
|
|
72
|
-
const lookup = (rawRef, type) => {
|
|
73
|
-
const slug = stripSlug(rawRef);
|
|
74
|
-
if (!slug) return null;
|
|
75
|
-
const reg = this.entities.getByTypeAndSlug(type, slug);
|
|
76
|
-
if (!reg) {
|
|
77
|
-
warnings.push(`Slug [[${slug}]] not found in compendium as ${type}.`);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const data = reg.data;
|
|
81
|
-
return data.slug == null ? { ...data, slug: reg.slug } : data;
|
|
82
|
-
};
|
|
83
|
-
const race = lookup(character.race, "race");
|
|
84
|
-
const background = lookup(character.background, "background");
|
|
85
|
-
const classes = character.class.map((c) => ({
|
|
86
|
-
entity: lookup(c.name, "class"),
|
|
87
|
-
level: c.level,
|
|
88
|
-
subclass: lookup(c.subclass, "subclass"),
|
|
89
|
-
choices: c.choices
|
|
90
|
-
}));
|
|
91
|
-
const featSlugs = collectFeatSlugs(character);
|
|
92
|
-
const feats = [];
|
|
93
|
-
for (const slug of featSlugs) {
|
|
94
|
-
const f = lookup(`[[${slug}]]`, "feat");
|
|
95
|
-
if (f) feats.push(f);
|
|
96
|
-
}
|
|
97
|
-
const originFeat = (background == null ? void 0 : background.origin_feat) ? resolveOriginFeat(this.entities, background.origin_feat) : null;
|
|
98
|
-
if (originFeat && !feats.some((f) => f.slug === originFeat.feat.slug)) {
|
|
99
|
-
feats.push(originFeat.feat);
|
|
100
|
-
}
|
|
101
|
-
const totalLevel = classes.reduce((sum, c) => sum + c.level, 0);
|
|
102
|
-
const features = collectResolvedFeatures(race, classes, background, feats);
|
|
103
|
-
const extraFeatures = collectChosenGrantedFeatures(character, classes, this.entities, race, background);
|
|
104
|
-
features.push(...extraFeatures);
|
|
105
|
-
const primaryCasterSlug = (_a = classes.map((c, i) => c.entity && resolveSpellcasting(c) ? stripSlug(character.class[i].name) : null).find((slug) => slug != null)) != null ? _a : null;
|
|
106
|
-
const spells = [];
|
|
107
|
-
for (const raw of (_b = character.spells.known) != null ? _b : []) {
|
|
108
|
-
const n = normalizeKnownSpell(raw);
|
|
109
|
-
const reg = this.entities.getByTypeAndSlug("spell", n.slug);
|
|
110
|
-
if (!reg) {
|
|
111
|
-
warnings.push(`Spell [[${n.slug}]] not found in compendium.`);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const entity = reg.data;
|
|
115
|
-
const isCantrip = ((_c = entity.level) != null ? _c : 0) === 0;
|
|
116
|
-
const classSlug = (_d = n.classSlug) != null ? _d : primaryCasterSlug;
|
|
117
|
-
const prep = isCantrip || n.alwaysPrepared ? true : (_e = n.preparedFlag) != null ? _e : false;
|
|
118
|
-
spells.push({ entity, slug: n.slug, classSlug, source: n.source, prepared: prep, alwaysPrepared: n.alwaysPrepared });
|
|
119
|
-
}
|
|
120
|
-
const oc = (_f = character.origin_choices) != null ? _f : {};
|
|
121
|
-
if (originFeat) {
|
|
122
|
-
const read = (childId) => oc[`background:feat:${childId}`];
|
|
123
|
-
spells.push(...collectFeatGrantedSpells(originFeat.feat, read, this.entities, warnings));
|
|
124
|
-
}
|
|
125
|
-
for (const entry of character.class) {
|
|
126
|
-
for (const atLevel of Object.values((_g = entry.choices) != null ? _g : {})) {
|
|
127
|
-
const featRef = atLevel.feat;
|
|
128
|
-
if (typeof featRef !== "string") continue;
|
|
129
|
-
const slug = stripSlug(featRef);
|
|
130
|
-
if (!slug) continue;
|
|
131
|
-
const reg = this.entities.getByTypeAndSlug("feat", slug);
|
|
132
|
-
if (!reg) continue;
|
|
133
|
-
const feat = reg.data;
|
|
134
|
-
const read = (childId) => atLevel[`feat:${childId}`];
|
|
135
|
-
spells.push(...collectFeatGrantedSpells(feat, read, this.entities, warnings));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const ownSpellcastingAbility = (_h = classes.map((c) => {
|
|
139
|
-
if (!c.entity) return null;
|
|
140
|
-
const p = resolveSpellcasting(c);
|
|
141
|
-
return p ? effectiveSpellcastingAbility(c.entity.slug, p.ability, character.overrides) : null;
|
|
142
|
-
}).find((a) => a != null)) != null ? _h : null;
|
|
143
|
-
spells.push(...collectItemGrantedSpells(character, ownSpellcastingAbility, this.entities, warnings));
|
|
144
|
-
const chosenMasteries = collectChosenWeaponMasteries(character);
|
|
145
|
-
if (chosenMasteries.full.length > 0) {
|
|
146
|
-
const target = features.find(
|
|
147
|
-
(rf) => {
|
|
148
|
-
var _a2;
|
|
149
|
-
return rf.feature.id === "weapon-mastery" || ((_a2 = rf.feature.choices) == null ? void 0 : _a2.some(
|
|
150
|
-
(ch) => ch.kind === "select-entity" && ch.id === "weapon-mastery" && ch.entity_type === "weapon"
|
|
151
|
-
));
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
if (target) {
|
|
155
|
-
const names = chosenMasteries.full.map(
|
|
156
|
-
(fullSlug) => {
|
|
157
|
-
var _a2, _b2;
|
|
158
|
-
return (_b2 = (_a2 = this.entities.getByTypeAndSlug("weapon", fullSlug)) == null ? void 0 : _a2.name) != null ? _b2 : fullSlug;
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
const entry = { label: "Mastered weapons", description: names.join(", ") };
|
|
162
|
-
target.chosenInline = target.chosenInline ? [...target.chosenInline, entry] : [entry];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const resolvedCharacter = {
|
|
166
|
-
definition: character,
|
|
167
|
-
race,
|
|
168
|
-
classes,
|
|
169
|
-
background,
|
|
170
|
-
feats,
|
|
171
|
-
totalLevel,
|
|
172
|
-
features,
|
|
173
|
-
spells: dedupeResolvedSpells(spells),
|
|
174
|
-
pools: [],
|
|
175
|
-
weaponMasteries: chosenMasteries.bare,
|
|
176
|
-
state: character.state
|
|
177
|
-
};
|
|
178
|
-
resolvedCharacter.pools = resolveAllPools(resolvedCharacter, this.entities);
|
|
179
|
-
return { character: resolvedCharacter, warnings };
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
function collectChosenWeaponMasteries(character) {
|
|
183
|
-
var _a, _b;
|
|
184
|
-
const full = /* @__PURE__ */ new Set();
|
|
185
|
-
for (const cls of (_a = character.class) != null ? _a : []) {
|
|
186
|
-
for (const lvl of Object.values((_b = cls.choices) != null ? _b : {})) {
|
|
187
|
-
const pick = lvl["weapon-mastery"];
|
|
188
|
-
if (Array.isArray(pick)) {
|
|
189
|
-
for (const s of pick) if (typeof s === "string") full.add(s);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return { full: [...full], bare: [...new Set([...full].map(bareEntitySlug))] };
|
|
194
|
-
}
|
|
195
|
-
function collectFeatSlugs(character) {
|
|
196
|
-
const slugs = /* @__PURE__ */ new Set();
|
|
197
|
-
for (const c of character.class) {
|
|
198
|
-
for (const [, choiceBlock] of Object.entries(c.choices)) {
|
|
199
|
-
const feat = choiceBlock == null ? void 0 : choiceBlock.feat;
|
|
200
|
-
if (typeof feat === "string") {
|
|
201
|
-
const s = stripSlug(feat);
|
|
202
|
-
if (s) slugs.add(s);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return [...slugs];
|
|
207
|
-
}
|
|
208
|
-
function collectFeatGrantedSpells(feat, read, entities, warnings) {
|
|
209
|
-
var _a;
|
|
210
|
-
const ability = readChosenSpellAbility(read);
|
|
211
|
-
const slugs = [];
|
|
212
|
-
collectSpellPickSlugs(feat.choices, read, slugs);
|
|
213
|
-
const out = [];
|
|
214
|
-
for (const rawSlug of slugs) {
|
|
215
|
-
const slug = (_a = stripSlug(rawSlug)) != null ? _a : rawSlug;
|
|
216
|
-
const reg = entities.getByTypeAndSlug("spell", slug);
|
|
217
|
-
if (!reg) {
|
|
218
|
-
warnings.push(`Feat spell [[${slug}]] not found in compendium.`);
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
const entity = reg.data;
|
|
222
|
-
out.push({ entity, slug, classSlug: null, source: "feat", prepared: true, alwaysPrepared: true, ability });
|
|
223
|
-
}
|
|
224
|
-
return out;
|
|
225
|
-
}
|
|
226
|
-
function collectItemGrantedSpells(character, ownAbility, entities, warnings) {
|
|
227
|
-
var _a;
|
|
228
|
-
const out = [];
|
|
229
|
-
((_a = character.equipment) != null ? _a : []).forEach((entry, entryIndex) => {
|
|
230
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
231
|
-
const spellRef = (_a2 = entry.overrides) == null ? void 0 : _a2.spell;
|
|
232
|
-
if (!spellRef) return;
|
|
233
|
-
const { entity: itemEntity } = resolveEntityForEntry(entry.item, entities);
|
|
234
|
-
const scrollLevel = isItemEntity(itemEntity) ? itemEntity.scroll_level : void 0;
|
|
235
|
-
if (scrollLevel == null) return;
|
|
236
|
-
const slug = (_b = stripSlug(spellRef)) != null ? _b : spellRef;
|
|
237
|
-
const reg = entities.getByTypeAndSlug("spell", slug);
|
|
238
|
-
if (!reg) {
|
|
239
|
-
warnings.push(`Scroll spell [[${slug}]] not found in compendium.`);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
const entity = reg.data;
|
|
243
|
-
const ability = (_f = (_d = (_c = entry.overrides) == null ? void 0 : _c.spell_ability) != null ? _d : ownAbility) != null ? _f : (_e = character.overrides) == null ? void 0 : _e.spellcasting_ability;
|
|
244
|
-
out.push({ entity, slug, classSlug: null, source: "item", prepared: true, alwaysPrepared: true, ability, entryIndex });
|
|
245
|
-
});
|
|
246
|
-
return out;
|
|
247
|
-
}
|
|
248
|
-
function dedupeResolvedSpells(spells) {
|
|
249
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
250
|
-
for (const s of spells) {
|
|
251
|
-
const key = s.source === "item" ? `${s.slug}#${s.entryIndex}` : s.slug;
|
|
252
|
-
const existing = byKey.get(key);
|
|
253
|
-
if (!existing) {
|
|
254
|
-
byKey.set(key, s);
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
if (existing.source === "feat" && s.source !== "feat") byKey.set(key, s);
|
|
258
|
-
}
|
|
259
|
-
return [...byKey.values()];
|
|
260
|
-
}
|
|
261
|
-
function readChosenSpellAbility(read) {
|
|
262
|
-
const pick = read("spellcasting-ability");
|
|
263
|
-
return typeof pick === "string" && ABILITY_KEYS.includes(pick) ? pick : null;
|
|
264
|
-
}
|
|
265
|
-
function collectSpellPickSlugs(choices, read, out) {
|
|
266
|
-
for (const ch of choices != null ? choices : []) {
|
|
267
|
-
if (ch.kind === "select-entity" && ch.entity_type === "spell") {
|
|
268
|
-
const sel = read(ch.id);
|
|
269
|
-
const picks = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
|
|
270
|
-
for (const p of picks) if (typeof p === "string" && p.length > 0) out.push(p);
|
|
271
|
-
} else if (ch.kind === "select-inline") {
|
|
272
|
-
const sel = read(ch.id);
|
|
273
|
-
const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
|
|
274
|
-
if (branch == null ? void 0 : branch.choices) collectSpellPickSlugs(branch.choices, read, out);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function collectChosenGrantedFeatures(character, classes, registry, race = null, background = null) {
|
|
279
|
-
var _a, _b;
|
|
280
|
-
const out = [];
|
|
281
|
-
classes.forEach((c, i) => {
|
|
282
|
-
var _a2, _b2, _c, _d;
|
|
283
|
-
if (!c.entity) return;
|
|
284
|
-
const entity = c.entity;
|
|
285
|
-
const entry = character.class[i];
|
|
286
|
-
if (!entry) return;
|
|
287
|
-
for (const [lvlStr, atLevel] of Object.entries(entry.choices)) {
|
|
288
|
-
const lvl = Number(lvlStr);
|
|
289
|
-
if (!Number.isFinite(lvl) || lvl > entry.level) continue;
|
|
290
|
-
const features = (_b2 = ((_a2 = entity.features_by_level) != null ? _a2 : {})[lvl]) != null ? _b2 : [];
|
|
291
|
-
const subFeatures = c.subclass ? (_d = ((_c = c.subclass.features_by_level) != null ? _c : {})[lvl]) != null ? _d : [] : [];
|
|
292
|
-
for (const feature of [...features, ...subFeatures]) {
|
|
293
|
-
walkChoiceGrants(feature.choices, atLevel, (granted, suppress) => {
|
|
294
|
-
out.push({
|
|
295
|
-
feature: granted,
|
|
296
|
-
source: { kind: "class", slug: entity.slug, level: lvl },
|
|
297
|
-
...suppress ? { renderSuppressed: true } : {}
|
|
298
|
-
});
|
|
299
|
-
}, registry);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
const oc = (_a = character.origin_choices) != null ? _a : {};
|
|
304
|
-
const originAt = (ns) => {
|
|
305
|
-
const at = {};
|
|
306
|
-
for (const [key, val] of Object.entries(oc)) {
|
|
307
|
-
if (key.startsWith(`${ns}:`)) at[key.slice(ns.length + 1)] = val;
|
|
308
|
-
}
|
|
309
|
-
return at;
|
|
310
|
-
};
|
|
311
|
-
if (race) {
|
|
312
|
-
const atRace = originAt("race");
|
|
313
|
-
const emitRace = (granted, suppress) => {
|
|
314
|
-
out.push({
|
|
315
|
-
feature: granted,
|
|
316
|
-
source: { kind: "race", slug: race.slug },
|
|
317
|
-
...suppress ? { renderSuppressed: true } : {}
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
walkChoiceGrants(race.choices, atRace, emitRace, registry);
|
|
321
|
-
for (const trait of (_b = race.traits) != null ? _b : []) {
|
|
322
|
-
walkChoiceGrants(trait.choices, atRace, emitRace, registry);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
if (background) {
|
|
326
|
-
const atBg = originAt("background");
|
|
327
|
-
const emitBg = (granted, suppress) => {
|
|
328
|
-
out.push({
|
|
329
|
-
feature: granted,
|
|
330
|
-
source: { kind: "background", slug: background.slug },
|
|
331
|
-
...suppress ? { renderSuppressed: true } : {}
|
|
332
|
-
});
|
|
333
|
-
};
|
|
334
|
-
walkChoiceGrants(background.choices, atBg, emitBg, registry);
|
|
335
|
-
if (background.feature) {
|
|
336
|
-
walkChoiceGrants(background.feature.choices, atBg, emitBg, registry);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return out;
|
|
340
|
-
}
|
|
341
|
-
function walkChoiceGrants(choices, atLevel, emit, registry) {
|
|
342
|
-
var _a, _b, _c, _d, _e;
|
|
343
|
-
for (const ch of choices != null ? choices : []) {
|
|
344
|
-
const sel = atLevel[ch.id];
|
|
345
|
-
if (ch.kind === "select-entity" && ch.entity_type === "optional-feature") {
|
|
346
|
-
const slugs = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
|
|
347
|
-
for (const slug of slugs) {
|
|
348
|
-
const reg = registry.getByTypeAndSlug("optional-feature", (_a = stripSlug(String(slug))) != null ? _a : String(slug));
|
|
349
|
-
if (!reg) continue;
|
|
350
|
-
const d = reg.data;
|
|
351
|
-
emit({
|
|
352
|
-
id: (_b = d.slug) != null ? _b : String(slug),
|
|
353
|
-
name: (_c = d.name) != null ? _c : String(slug),
|
|
354
|
-
description: d.description,
|
|
355
|
-
effects: d.effects,
|
|
356
|
-
...d.action_cost ? { action: d.action_cost } : {}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (ch.kind === "select-inline") {
|
|
361
|
-
const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
|
|
362
|
-
if ((_d = branch == null ? void 0 : branch.effects) == null ? void 0 : _d.length) {
|
|
363
|
-
const wc = (_e = branch.choices) == null ? void 0 : _e.find(
|
|
364
|
-
(c) => c.kind === "select-entity" && c.entity_type === "weapon"
|
|
365
|
-
);
|
|
366
|
-
const picked = wc ? atLevel == null ? void 0 : atLevel[wc.id] : void 0;
|
|
367
|
-
const effects = branch.effects.map(
|
|
368
|
-
(e) => e.kind === "weapon-ability" && e.weapons === "chosen" && typeof picked === "string" ? { ...e, weapons: [bareEntitySlug(picked)] } : e
|
|
369
|
-
);
|
|
370
|
-
emit({ id: `${ch.id}-${branch.value}`, name: branch.label, description: branch.description, effects }, true);
|
|
371
|
-
}
|
|
372
|
-
if (branch == null ? void 0 : branch.choices) walkChoiceGrants(branch.choices, atLevel, emit, registry);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
function resolveChosenInline(feature, atLevel) {
|
|
377
|
-
var _a;
|
|
378
|
-
if (!atLevel) return void 0;
|
|
379
|
-
const picks = [];
|
|
380
|
-
for (const ch of (_a = feature.choices) != null ? _a : []) {
|
|
381
|
-
if (ch.kind !== "select-inline") continue;
|
|
382
|
-
const sel = atLevel[ch.id];
|
|
383
|
-
if (typeof sel !== "string") continue;
|
|
384
|
-
const opt = ch.options.find((o) => o.value === sel);
|
|
385
|
-
if (!opt) continue;
|
|
386
|
-
picks.push({ label: opt.label, description: opt.description });
|
|
387
|
-
}
|
|
388
|
-
return picks.length ? picks : void 0;
|
|
389
|
-
}
|
|
390
|
-
function isAsiSlotFeature(feature) {
|
|
391
|
-
var _a, _b, _c, _d;
|
|
392
|
-
return feature.id === "ability-score-improvement" && !((_a = feature.effects) == null ? void 0 : _a.length) && !((_b = feature.resources) == null ? void 0 : _b.length) && !feature.action && !((_c = feature.sub_features) == null ? void 0 : _c.length) && !((_d = feature.attacks) == null ? void 0 : _d.length);
|
|
393
|
-
}
|
|
394
|
-
function collectResolvedFeatures(race, classes, background, feats) {
|
|
395
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
396
|
-
const out = [];
|
|
397
|
-
for (const c of classes) {
|
|
398
|
-
if (!c.entity) continue;
|
|
399
|
-
const slug = c.entity.slug;
|
|
400
|
-
const byLevel = (_a = c.entity.features_by_level) != null ? _a : {};
|
|
401
|
-
for (const [lvlStr, feats0] of Object.entries(byLevel)) {
|
|
402
|
-
const lvl = parseInt(lvlStr, 10);
|
|
403
|
-
if (Number.isNaN(lvl) || lvl > c.level) continue;
|
|
404
|
-
for (const feat of feats0) {
|
|
405
|
-
const chosenInline = resolveChosenInline(feat, (_b = c.choices) == null ? void 0 : _b[lvl]);
|
|
406
|
-
out.push({
|
|
407
|
-
feature: feat,
|
|
408
|
-
source: { kind: "class", slug, level: lvl },
|
|
409
|
-
...chosenInline ? { chosenInline } : {},
|
|
410
|
-
...isAsiSlotFeature(feat) ? { buildOnly: true } : {}
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
if ((_c = c.entity.resources) == null ? void 0 : _c.length) {
|
|
415
|
-
out.push({
|
|
416
|
-
feature: { name: c.entity.name, resources: c.entity.resources },
|
|
417
|
-
source: { kind: "class", slug, level: 1 }
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
if (c.subclass) {
|
|
421
|
-
const sSlug = c.subclass.slug;
|
|
422
|
-
const sByLevel = (_d = c.subclass.features_by_level) != null ? _d : {};
|
|
423
|
-
for (const [lvlStr, feats0] of Object.entries(sByLevel)) {
|
|
424
|
-
const lvl = parseInt(lvlStr, 10);
|
|
425
|
-
if (Number.isNaN(lvl) || lvl > c.level) continue;
|
|
426
|
-
for (const feat of feats0) {
|
|
427
|
-
const chosenInline = resolveChosenInline(feat, (_e = c.choices) == null ? void 0 : _e[lvl]);
|
|
428
|
-
out.push({
|
|
429
|
-
feature: feat,
|
|
430
|
-
source: { kind: "subclass", slug: sSlug, level: lvl },
|
|
431
|
-
...chosenInline ? { chosenInline } : {},
|
|
432
|
-
...isAsiSlotFeature(feat) ? { buildOnly: true } : {}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if ((_f = c.subclass.resources) == null ? void 0 : _f.length) {
|
|
437
|
-
out.push({
|
|
438
|
-
feature: { name: c.subclass.name, resources: c.subclass.resources },
|
|
439
|
-
source: { kind: "subclass", slug: sSlug, level: 1 }
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
if (race) {
|
|
445
|
-
const traits = (_g = race.traits) != null ? _g : [];
|
|
446
|
-
for (const feat of traits) {
|
|
447
|
-
out.push({ feature: feat, source: { kind: "race", slug: race.slug } });
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (background) {
|
|
451
|
-
const bgFeature = background.feature;
|
|
452
|
-
if (bgFeature) {
|
|
453
|
-
out.push({ feature: bgFeature, source: { kind: "background", slug: background.slug } });
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
for (const feat of feats) {
|
|
457
|
-
const bundled = (_h = feat.features) != null ? _h : [];
|
|
458
|
-
const entityEffects = (_i = feat.effects) != null ? _i : [];
|
|
459
|
-
if (bundled.length > 0) {
|
|
460
|
-
bundled.forEach((f, i) => {
|
|
461
|
-
var _a2;
|
|
462
|
-
const feature = i === 0 && entityEffects.length > 0 ? { ...f, effects: [...(_a2 = f.effects) != null ? _a2 : [], ...entityEffects] } : f;
|
|
463
|
-
out.push({ feature, source: { kind: "feat", slug: feat.slug } });
|
|
464
|
-
});
|
|
465
|
-
} else {
|
|
466
|
-
const name = (_j = feat.name) != null ? _j : feat.slug;
|
|
467
|
-
const foldedDesc = [feat.description, ...(_k = feat.benefits) != null ? _k : []].filter(Boolean).join("\n\n") || void 0;
|
|
468
|
-
const buildOnly = ((_l = feat.choices) != null ? _l : []).some((c) => c.kind === "ability-points" && c.points >= 2) && !((_m = feat.effects) == null ? void 0 : _m.length) && !((_n = feat.resources) == null ? void 0 : _n.length) && bundled.length === 0;
|
|
469
|
-
out.push({
|
|
470
|
-
feature: {
|
|
471
|
-
name,
|
|
472
|
-
...foldedDesc ? { description: foldedDesc } : {},
|
|
473
|
-
...feat.resources ? { resources: feat.resources } : {},
|
|
474
|
-
...entityEffects.length > 0 ? { effects: entityEffects } : {}
|
|
475
|
-
},
|
|
476
|
-
source: { kind: "feat", slug: feat.slug },
|
|
477
|
-
...buildOnly ? { buildOnly: true } : {}
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return out;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// src/pc/pc.decision-engine.ts
|
|
485
|
-
var warnedDegradedEquipment = /* @__PURE__ */ new Set();
|
|
486
|
-
function wikilinkTailSlug(link) {
|
|
487
|
-
var _a;
|
|
488
|
-
const inner = link.replace(/^\[\[/, "").replace(/\]\]$/, "");
|
|
489
|
-
const tail = (_a = inner.split("/").pop()) != null ? _a : inner;
|
|
490
|
-
return tail.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
491
|
-
}
|
|
492
|
-
function matchesFilter(e, where, ownerBare) {
|
|
493
|
-
var _a, _b, _c, _d, _e;
|
|
494
|
-
const d = e.data;
|
|
495
|
-
if (where.feature_type && d.feature_type !== where.feature_type) return false;
|
|
496
|
-
if (where.category && d.category !== where.category) return false;
|
|
497
|
-
if (where.list && !((_a = d.classes) != null ? _a : []).includes(where.list)) return false;
|
|
498
|
-
if (where.level !== void 0 && ((_b = d.level) != null ? _b : 0) !== where.level) return false;
|
|
499
|
-
if (where.edition && d.edition !== where.edition) return false;
|
|
500
|
-
if (where.weapon_category) {
|
|
501
|
-
const cat = ((_c = d.category) != null ? _c : "").toLowerCase();
|
|
502
|
-
if (!cat.startsWith(`${where.weapon_category}-`) && cat !== where.weapon_category) return false;
|
|
503
|
-
}
|
|
504
|
-
if (where.armor_category) {
|
|
505
|
-
if (((_d = d.category) != null ? _d : "").toLowerCase() !== where.armor_category) return false;
|
|
506
|
-
}
|
|
507
|
-
if (where.parent_class === "self") {
|
|
508
|
-
if (!d.parent_class || wikilinkTailSlug(d.parent_class) !== ownerBare) return false;
|
|
509
|
-
}
|
|
510
|
-
if (where.available_to === "self") {
|
|
511
|
-
const list = (_e = d.available_to) != null ? _e : [];
|
|
512
|
-
if (!list.some((l) => wikilinkTailSlug(l) === ownerBare)) return false;
|
|
513
|
-
}
|
|
514
|
-
return true;
|
|
515
|
-
}
|
|
516
|
-
var __matchesFilterForTest = matchesFilter;
|
|
517
|
-
function categoryToEntitySelect(category, id) {
|
|
518
|
-
const c = category.toLowerCase();
|
|
519
|
-
if (c === "shield") {
|
|
520
|
-
return { kind: "select-entity", id, label: "Choose a shield", count: 1, entity_type: "armor", where: { armor_category: "shield" } };
|
|
521
|
-
}
|
|
522
|
-
if (c.includes("armor")) {
|
|
523
|
-
const klass = c.includes("light") ? "light" : c.includes("medium") ? "medium" : c.includes("heavy") ? "heavy" : null;
|
|
524
|
-
return klass ? { kind: "select-entity", id, label: `Choose ${klass} armor`, count: 1, entity_type: "armor", where: { armor_category: klass } } : { kind: "select-entity", id, label: "Choose armor", count: 1, entity_type: "armor" };
|
|
525
|
-
}
|
|
526
|
-
const wc = c.includes("martial") ? "martial" : "simple";
|
|
527
|
-
return { kind: "select-entity", id, label: `Choose a ${c.replace(/-/g, " ")}`, count: 1, entity_type: "weapon", where: { weapon_category: wc } };
|
|
528
|
-
}
|
|
529
|
-
function enumerateOptions(choice, ctx, ownerBare) {
|
|
530
|
-
var _a, _b;
|
|
531
|
-
switch (choice.kind) {
|
|
532
|
-
case "select-inline":
|
|
533
|
-
return choice.options.map((o) => ({ value: o.value, label: o.label, description: o.description }));
|
|
534
|
-
case "select-entity": {
|
|
535
|
-
if (choice.from) {
|
|
536
|
-
const byBare = /* @__PURE__ */ new Map();
|
|
537
|
-
for (const e of ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY)) {
|
|
538
|
-
byBare.set(bareEntitySlug(e.slug), e);
|
|
539
|
-
}
|
|
540
|
-
return choice.from.map((slug) => {
|
|
541
|
-
var _a2;
|
|
542
|
-
const e = (_a2 = ctx.registry.getByTypeAndSlug(choice.entity_type, slug)) != null ? _a2 : byBare.get(slug);
|
|
543
|
-
return e ? { value: e.slug, label: e.name, entity: e } : { value: slug, label: slug, missing: true };
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
const all = ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY);
|
|
547
|
-
const filtered = choice.where ? all.filter((e) => matchesFilter(e, choice.where, ownerBare)) : all;
|
|
548
|
-
return filtered.map((e) => ({ value: e.slug, label: e.name, entity: e }));
|
|
549
|
-
}
|
|
550
|
-
case "select-proficiency": {
|
|
551
|
-
const pool = (_a = choice.from) != null ? _a : choice.domain === "skill" ? [...ALL_SKILL_SLUGS] : choice.domain === "language" ? [...ALL_LANGUAGES] : [];
|
|
552
|
-
return pool.map((v) => ({ value: v, label: v.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) }));
|
|
553
|
-
}
|
|
554
|
-
case "ability-points": {
|
|
555
|
-
const pool = (_b = choice.pool) != null ? _b : ["str", "dex", "con", "int", "wis", "cha"];
|
|
556
|
-
return pool.map((a) => ({ value: a, label: a.toUpperCase() }));
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function selectionCount(choice, selected) {
|
|
561
|
-
if (selected === void 0) return 0;
|
|
562
|
-
if (choice.kind === "ability-points") {
|
|
563
|
-
if (typeof selected !== "object" || Array.isArray(selected)) return 0;
|
|
564
|
-
return Object.values(selected).reduce((s, v) => s + (typeof v === "number" ? v : 0), 0);
|
|
565
|
-
}
|
|
566
|
-
if (Array.isArray(selected)) return selected.length;
|
|
567
|
-
return typeof selected === "string" && selected.length > 0 ? 1 : 0;
|
|
568
|
-
}
|
|
569
|
-
function requiredCount(choice) {
|
|
570
|
-
var _a;
|
|
571
|
-
if (choice.kind === "ability-points") return choice.points;
|
|
572
|
-
if (choice.kind === "select-proficiency") return choice.count;
|
|
573
|
-
return (_a = choice.count) != null ? _a : 1;
|
|
574
|
-
}
|
|
575
|
-
function statusOf(choice, selected) {
|
|
576
|
-
const n = selectionCount(choice, selected);
|
|
577
|
-
const need = requiredCount(choice);
|
|
578
|
-
if (n === 0) return "unresolved";
|
|
579
|
-
return n >= need ? "resolved" : "partial";
|
|
580
|
-
}
|
|
581
|
-
function resolveEntityRef(ctx, entityType, value) {
|
|
582
|
-
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
583
|
-
const raw = value.replace(/^\[\[/, "").replace(/\]\]$/, "");
|
|
584
|
-
const direct = ctx.registry.getByTypeAndSlug(entityType, raw);
|
|
585
|
-
if (direct) return direct;
|
|
586
|
-
for (const e of ctx.registry.search("", entityType, Number.POSITIVE_INFINITY)) {
|
|
587
|
-
if (e.slug === raw || bareEntitySlug(e.slug) === raw) return e;
|
|
588
|
-
}
|
|
589
|
-
return void 0;
|
|
590
|
-
}
|
|
591
|
-
function buildItem(choice, source, level, featureName, readValue, ctx, ownerBare, opts) {
|
|
592
|
-
var _a, _b, _c, _d;
|
|
593
|
-
const keyPrefix = (_a = opts == null ? void 0 : opts.keyPrefix) != null ? _a : "";
|
|
594
|
-
const expandFeatChildren = (_b = opts == null ? void 0 : opts.expandFeatChildren) != null ? _b : true;
|
|
595
|
-
const key = keyPrefix + choice.id;
|
|
596
|
-
const selected = readValue(key);
|
|
597
|
-
const item = {
|
|
598
|
-
key,
|
|
599
|
-
source,
|
|
600
|
-
level,
|
|
601
|
-
featureName,
|
|
602
|
-
choice,
|
|
603
|
-
description: opts == null ? void 0 : opts.description,
|
|
604
|
-
options: enumerateOptions(choice, ctx, ownerBare),
|
|
605
|
-
selected,
|
|
606
|
-
status: statusOf(choice, selected)
|
|
607
|
-
};
|
|
608
|
-
if (choice.kind === "select-inline" && typeof selected === "string") {
|
|
609
|
-
const branch = choice.options.find((o) => o.value === selected);
|
|
610
|
-
if ((_c = branch == null ? void 0 : branch.choices) == null ? void 0 : _c.length) {
|
|
611
|
-
item.children = branch.choices.map((c) => buildItem(c, source, level, featureName, readValue, ctx, ownerBare, { keyPrefix, expandFeatChildren }));
|
|
612
|
-
if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
|
|
613
|
-
item.status = "partial";
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (choice.kind === "select-entity" && choice.entity_type === "feat" && expandFeatChildren && typeof selected === "string") {
|
|
618
|
-
const entity = resolveEntityRef(ctx, "feat", selected);
|
|
619
|
-
const rawChoices = (_d = entity == null ? void 0 : entity.data) == null ? void 0 : _d.choices;
|
|
620
|
-
const featChoices = Array.isArray(rawChoices) ? rawChoices : [];
|
|
621
|
-
if (featChoices.length) {
|
|
622
|
-
const childPrefix = `${keyPrefix}feat:`;
|
|
623
|
-
item.children = featChoices.map((c) => buildItem(
|
|
624
|
-
c,
|
|
625
|
-
source,
|
|
626
|
-
level,
|
|
627
|
-
featureName,
|
|
628
|
-
readValue,
|
|
629
|
-
ctx,
|
|
630
|
-
ownerBare,
|
|
631
|
-
{ keyPrefix: childPrefix, expandFeatChildren: false }
|
|
632
|
-
));
|
|
633
|
-
if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
|
|
634
|
-
item.status = "partial";
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
return item;
|
|
639
|
-
}
|
|
640
|
-
function buildSubclassItem(choice, source, level, featureName, c, ctx, ownerBare, description) {
|
|
641
|
-
const selected = c.subclass ? c.subclass.slug : void 0;
|
|
642
|
-
return {
|
|
643
|
-
key: "subclass",
|
|
644
|
-
source,
|
|
645
|
-
level,
|
|
646
|
-
featureName,
|
|
647
|
-
description,
|
|
648
|
-
choice,
|
|
649
|
-
options: enumerateOptions(choice, ctx, ownerBare),
|
|
650
|
-
selected,
|
|
651
|
-
status: selected ? "resolved" : "unresolved"
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
function visitProficiencyChoices(resolved, visit) {
|
|
655
|
-
var _a, _b;
|
|
656
|
-
const walk = (choices, read) => {
|
|
657
|
-
for (const ch of choices != null ? choices : []) {
|
|
658
|
-
visit(ch, read(ch.id));
|
|
659
|
-
if (ch.kind === "select-inline") {
|
|
660
|
-
const sel = read(ch.id);
|
|
661
|
-
const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
|
|
662
|
-
if (branch == null ? void 0 : branch.choices) walk(branch.choices, read);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
resolved.classes.forEach((c, i) => {
|
|
667
|
-
var _a2, _b2;
|
|
668
|
-
if (!c.entity) return;
|
|
669
|
-
const entity = c.entity;
|
|
670
|
-
const readAt = (lvl) => (id) => {
|
|
671
|
-
var _a3;
|
|
672
|
-
return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
|
|
673
|
-
};
|
|
674
|
-
if (i === 0 && ((_b2 = (_a2 = entity.skill_choices) == null ? void 0 : _a2.from) == null ? void 0 : _b2.length)) {
|
|
675
|
-
visit({
|
|
676
|
-
kind: "select-proficiency",
|
|
677
|
-
id: "skills",
|
|
678
|
-
count: entity.skill_choices.count,
|
|
679
|
-
domain: "skill",
|
|
680
|
-
from: entity.skill_choices.from
|
|
681
|
-
}, readAt(1)("skills"));
|
|
682
|
-
}
|
|
683
|
-
for (const rf of resolved.features) {
|
|
684
|
-
if (rf.source.kind !== "class" && rf.source.kind !== "subclass") continue;
|
|
685
|
-
const belongs = rf.source.kind === "class" ? rf.source.slug === entity.slug : c.subclass != null && rf.source.slug === c.subclass.slug;
|
|
686
|
-
if (!belongs) continue;
|
|
687
|
-
walk(rf.feature.choices, readAt(rf.source.level));
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
|
|
691
|
-
const originRead = (ns) => (id) => oc[`${ns}:${id}`];
|
|
692
|
-
if (resolved.race) {
|
|
693
|
-
walk(resolved.race.choices, originRead("race"));
|
|
694
|
-
for (const t of (_b = resolved.race.traits) != null ? _b : []) walk(t.choices, originRead("race"));
|
|
695
|
-
}
|
|
696
|
-
if (resolved.background) {
|
|
697
|
-
walk(resolved.background.choices, originRead("background"));
|
|
698
|
-
if (resolved.background.feature) {
|
|
699
|
-
const feature = resolved.background.feature;
|
|
700
|
-
walk(feature.choices, originRead("background"));
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
function collectChosenProficiencies(resolved) {
|
|
705
|
-
const out = { skills: [], expertise: [], languages: [], tools: [] };
|
|
706
|
-
visitProficiencyChoices(resolved, (choice, selected) => {
|
|
707
|
-
if (choice.kind !== "select-proficiency") return;
|
|
708
|
-
const vals = Array.isArray(selected) ? selected : typeof selected === "string" ? [selected] : [];
|
|
709
|
-
const pool = choice.from;
|
|
710
|
-
const valid = pool ? vals.filter((v) => pool.includes(v)) : vals;
|
|
711
|
-
const bucket = choice.domain === "skill" ? choice.expertise ? out.expertise : out.skills : choice.domain === "language" ? out.languages : choice.domain === "tool" ? out.tools : null;
|
|
712
|
-
if (bucket) {
|
|
713
|
-
for (const v of valid) if (!bucket.includes(v)) bucket.push(v);
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
return out;
|
|
717
|
-
}
|
|
718
|
-
function collectLanguageToolChoiceStatus(resolved) {
|
|
719
|
-
const languages = [];
|
|
720
|
-
const tools = [];
|
|
721
|
-
visitProficiencyChoices(resolved, (choice, selected) => {
|
|
722
|
-
if (choice.kind !== "select-proficiency") return;
|
|
723
|
-
if (choice.domain !== "language" && choice.domain !== "tool") return;
|
|
724
|
-
const vals = Array.isArray(selected) ? selected : typeof selected === "string" ? [selected] : [];
|
|
725
|
-
const pool = choice.from;
|
|
726
|
-
const valid = pool ? vals.filter((v) => pool.includes(v)) : vals;
|
|
727
|
-
const status = { id: choice.id, count: choice.count, selected: valid.length };
|
|
728
|
-
(choice.domain === "language" ? languages : tools).push(status);
|
|
729
|
-
});
|
|
730
|
-
return { languages, tools };
|
|
731
|
-
}
|
|
732
|
-
function collectChosenAbilityPoints(resolved) {
|
|
733
|
-
var _a, _b, _c;
|
|
734
|
-
const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
|
|
735
|
-
const out = { race: {}, background: {} };
|
|
736
|
-
const fold = (ns, choices) => {
|
|
737
|
-
var _a2;
|
|
738
|
-
for (const ch of choices != null ? choices : []) {
|
|
739
|
-
if (ch.kind !== "ability-points") continue;
|
|
740
|
-
const raw = oc[`${ns}:${ch.id}`];
|
|
741
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
742
|
-
let left = ch.points;
|
|
743
|
-
for (const ab of ABILITY_KEYS) {
|
|
744
|
-
if (ch.pool && !ch.pool.includes(ab)) continue;
|
|
745
|
-
const v = raw[ab];
|
|
746
|
-
if (typeof v !== "number" || v <= 0 || left <= 0) continue;
|
|
747
|
-
const take = Math.min(v, ch.max_per, left);
|
|
748
|
-
out[ns][ab] = ((_a2 = out[ns][ab]) != null ? _a2 : 0) + take;
|
|
749
|
-
left -= take;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
const race = resolved.race;
|
|
754
|
-
if (race) {
|
|
755
|
-
fold("race", race.choices);
|
|
756
|
-
for (const t of (_b = race.traits) != null ? _b : []) fold("race", t.choices);
|
|
757
|
-
}
|
|
758
|
-
const bg = resolved.background;
|
|
759
|
-
if (bg) {
|
|
760
|
-
fold("background", bg.choices);
|
|
761
|
-
fold("background", (_c = bg.feature) == null ? void 0 : _c.choices);
|
|
762
|
-
}
|
|
763
|
-
return out;
|
|
764
|
-
}
|
|
765
|
-
function buildDecisionLedger(resolved, ctx) {
|
|
766
|
-
var _a, _b, _c, _d, _e;
|
|
767
|
-
const classes = [];
|
|
768
|
-
resolved.classes.forEach((c, classIndex) => {
|
|
769
|
-
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
770
|
-
if (!c.entity) return;
|
|
771
|
-
const entity = c.entity;
|
|
772
|
-
const ownerBare = bareEntitySlug(entity.slug);
|
|
773
|
-
const byLevel = /* @__PURE__ */ new Map();
|
|
774
|
-
const push = (lvl, item) => {
|
|
775
|
-
var _a3;
|
|
776
|
-
const arr = (_a3 = byLevel.get(lvl)) != null ? _a3 : [];
|
|
777
|
-
arr.push(item);
|
|
778
|
-
byLevel.set(lvl, arr);
|
|
779
|
-
};
|
|
780
|
-
const readAt = (lvl) => (id) => {
|
|
781
|
-
var _a3;
|
|
782
|
-
return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
|
|
783
|
-
};
|
|
784
|
-
if (classIndex === 0 && ((_b2 = (_a2 = entity.skill_choices) == null ? void 0 : _a2.from) == null ? void 0 : _b2.length)) {
|
|
785
|
-
const skillChoice = {
|
|
786
|
-
kind: "select-proficiency",
|
|
787
|
-
id: "skills",
|
|
788
|
-
label: "Skill Proficiencies",
|
|
789
|
-
count: entity.skill_choices.count,
|
|
790
|
-
domain: "skill",
|
|
791
|
-
from: entity.skill_choices.from
|
|
792
|
-
};
|
|
793
|
-
push(1, buildItem(
|
|
794
|
-
skillChoice,
|
|
795
|
-
{ kind: "class", slug: entity.slug, level: 1 },
|
|
796
|
-
1,
|
|
797
|
-
"Proficiencies",
|
|
798
|
-
readAt(1),
|
|
799
|
-
ctx,
|
|
800
|
-
ownerBare
|
|
801
|
-
));
|
|
802
|
-
}
|
|
803
|
-
if (classIndex === 0) {
|
|
804
|
-
((_c2 = entity.starting_equipment) != null ? _c2 : []).forEach((eq, i) => {
|
|
805
|
-
var _a3;
|
|
806
|
-
if (eq.kind !== "choice") return;
|
|
807
|
-
const options = (_a3 = eq.options) != null ? _a3 : [];
|
|
808
|
-
let degraded = false;
|
|
809
|
-
const ch = {
|
|
810
|
-
kind: "select-inline",
|
|
811
|
-
id: `equipment-${i}`,
|
|
812
|
-
label: "Starting Equipment",
|
|
813
|
-
count: 1,
|
|
814
|
-
options: options.map((opt, j) => {
|
|
815
|
-
var _a4;
|
|
816
|
-
const label = typeof opt === "string" ? opt : (_a4 = opt == null ? void 0 : opt.label) != null ? _a4 : "";
|
|
817
|
-
const grants = opt && typeof opt === "object" && Array.isArray(opt.grants) ? opt.grants : [];
|
|
818
|
-
if (typeof opt === "string" || !(opt && typeof opt === "object" && Array.isArray(opt.grants))) {
|
|
819
|
-
degraded = true;
|
|
820
|
-
}
|
|
821
|
-
return {
|
|
822
|
-
value: `option-${j}`,
|
|
823
|
-
label,
|
|
824
|
-
choices: grants.flatMap((g, k) => g && typeof g === "object" && "category" in g && g.category ? [categoryToEntitySelect(g.category, `equipment-${i}-opt-${j}-cat-${k}`)] : [])
|
|
825
|
-
};
|
|
826
|
-
})
|
|
827
|
-
};
|
|
828
|
-
if (degraded && !warnedDegradedEquipment.has(entity.slug)) {
|
|
829
|
-
warnedDegradedEquipment.add(entity.slug);
|
|
830
|
-
console.warn(
|
|
831
|
-
`[archivist] Starting equipment for "${entity.slug}" is in an outdated/unstructured format; its nested picks and seeding are skipped. Re-sync the compendium (delete _compendium.md and reload) to fix.`
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
push(1, buildItem(
|
|
835
|
-
ch,
|
|
836
|
-
{ kind: "class", slug: entity.slug, level: 1 },
|
|
837
|
-
1,
|
|
838
|
-
"Starting Equipment",
|
|
839
|
-
readAt(1),
|
|
840
|
-
ctx,
|
|
841
|
-
ownerBare
|
|
842
|
-
));
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
let sawAuthoredSubclass = false;
|
|
846
|
-
for (const rf of resolved.features) {
|
|
847
|
-
const src = rf.source;
|
|
848
|
-
if (src.kind !== "class" && src.kind !== "subclass") continue;
|
|
849
|
-
const belongs = src.kind === "class" ? src.slug === entity.slug : c.subclass != null && src.slug === c.subclass.slug;
|
|
850
|
-
if (!belongs) continue;
|
|
851
|
-
const lvl = src.level;
|
|
852
|
-
let choices = rf.feature.choices;
|
|
853
|
-
if (!(choices == null ? void 0 : choices.length)) {
|
|
854
|
-
const recognized = recognizeDecision(rf.feature);
|
|
855
|
-
if (recognized === "informational") {
|
|
856
|
-
push(lvl, {
|
|
857
|
-
key: (_d2 = rf.feature.id) != null ? _d2 : rf.feature.name,
|
|
858
|
-
source: src,
|
|
859
|
-
level: lvl,
|
|
860
|
-
featureName: rf.feature.name,
|
|
861
|
-
description: (_f = rf.feature.description) != null ? _f : (_e2 = rf.feature.entries) == null ? void 0 : _e2.join("\n\n"),
|
|
862
|
-
choice: { kind: "select-inline", id: (_g = rf.feature.id) != null ? _g : rf.feature.name, options: [{ value: "_", label: "_" }] },
|
|
863
|
-
options: [],
|
|
864
|
-
selected: void 0,
|
|
865
|
-
status: "informational"
|
|
866
|
-
});
|
|
867
|
-
continue;
|
|
868
|
-
}
|
|
869
|
-
choices = recognized != null ? recognized : void 0;
|
|
870
|
-
}
|
|
871
|
-
if (!(choices == null ? void 0 : choices.length)) {
|
|
872
|
-
if (rf.feature.description || ((_h = rf.feature.entries) == null ? void 0 : _h.length)) {
|
|
873
|
-
push(lvl, {
|
|
874
|
-
key: (_i = rf.feature.id) != null ? _i : rf.feature.name,
|
|
875
|
-
source: src,
|
|
876
|
-
level: lvl,
|
|
877
|
-
featureName: rf.feature.name,
|
|
878
|
-
description: (_k = rf.feature.description) != null ? _k : (_j = rf.feature.entries) == null ? void 0 : _j.join("\n\n"),
|
|
879
|
-
choice: { kind: "select-inline", id: (_l = rf.feature.id) != null ? _l : rf.feature.name, options: [{ value: "_", label: "_" }] },
|
|
880
|
-
options: [],
|
|
881
|
-
selected: void 0,
|
|
882
|
-
status: "informational"
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
continue;
|
|
886
|
-
}
|
|
887
|
-
for (const ch of choices) {
|
|
888
|
-
if (ch.kind === "select-entity" && ch.entity_type === "subclass") {
|
|
889
|
-
sawAuthoredSubclass = true;
|
|
890
|
-
push(lvl, buildSubclassItem(ch, src, lvl, rf.feature.name, c, ctx, ownerBare, rf.feature.description));
|
|
891
|
-
continue;
|
|
892
|
-
}
|
|
893
|
-
push(lvl, buildItem(
|
|
894
|
-
ch,
|
|
895
|
-
src,
|
|
896
|
-
lvl,
|
|
897
|
-
rf.feature.name,
|
|
898
|
-
readAt(lvl),
|
|
899
|
-
ctx,
|
|
900
|
-
ownerBare,
|
|
901
|
-
{ description: rf.feature.description }
|
|
902
|
-
));
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
const subclassLevel = (_m = entity.subclass_level) != null ? _m : null;
|
|
906
|
-
if (subclassLevel != null && subclassLevel <= c.level && !sawAuthoredSubclass) {
|
|
907
|
-
const featureName = (_n = entity.subclass_feature_name) != null ? _n : "Subclass";
|
|
908
|
-
const synthChoice = {
|
|
909
|
-
kind: "select-entity",
|
|
910
|
-
id: "subclass",
|
|
911
|
-
label: featureName,
|
|
912
|
-
count: 1,
|
|
913
|
-
entity_type: "subclass",
|
|
914
|
-
where: { parent_class: "self" }
|
|
915
|
-
};
|
|
916
|
-
push(subclassLevel, buildSubclassItem(
|
|
917
|
-
synthChoice,
|
|
918
|
-
{ kind: "class", slug: entity.slug, level: subclassLevel },
|
|
919
|
-
subclassLevel,
|
|
920
|
-
featureName,
|
|
921
|
-
c,
|
|
922
|
-
ctx,
|
|
923
|
-
ownerBare
|
|
924
|
-
));
|
|
925
|
-
}
|
|
926
|
-
for (const pool of resolved.pools) {
|
|
927
|
-
if (pool.classIndex !== classIndex || pool.count < 1) continue;
|
|
928
|
-
const synth = {
|
|
929
|
-
kind: "select-entity",
|
|
930
|
-
id: pool.id,
|
|
931
|
-
label: pool.label,
|
|
932
|
-
count: pool.count,
|
|
933
|
-
entity_type: "optional-feature",
|
|
934
|
-
from: pool.available.map((e) => e.slug)
|
|
935
|
-
};
|
|
936
|
-
push(pool.anchorLevel, buildItem(
|
|
937
|
-
synth,
|
|
938
|
-
{ kind: "class", slug: entity.slug, level: pool.anchorLevel },
|
|
939
|
-
pool.anchorLevel,
|
|
940
|
-
pool.label,
|
|
941
|
-
readAt(pool.anchorLevel),
|
|
942
|
-
ctx,
|
|
943
|
-
ownerBare
|
|
944
|
-
));
|
|
945
|
-
}
|
|
946
|
-
const levels = [...byLevel.entries()].sort(([a], [b]) => a - b).map(([level, items]) => ({ level, items }));
|
|
947
|
-
classes.push({ classIndex, levels });
|
|
948
|
-
});
|
|
949
|
-
const origin = [];
|
|
950
|
-
const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
|
|
951
|
-
const originRead = (ns) => (id) => oc[`${ns}:${id}`];
|
|
952
|
-
const pushOrigin = (choices, ns, source, featureName, ownerBare, description) => {
|
|
953
|
-
for (const ch of choices != null ? choices : []) {
|
|
954
|
-
origin.push(buildItem(ch, source, 0, featureName, originRead(ns), ctx, ownerBare, { description }));
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
if (resolved.race) {
|
|
958
|
-
const bare = bareEntitySlug(resolved.race.slug);
|
|
959
|
-
pushOrigin(
|
|
960
|
-
resolved.race.choices,
|
|
961
|
-
"race",
|
|
962
|
-
{ kind: "race", slug: resolved.race.slug },
|
|
963
|
-
(_b = resolved.race.name) != null ? _b : "Race",
|
|
964
|
-
bare,
|
|
965
|
-
resolved.race.description
|
|
966
|
-
);
|
|
967
|
-
for (const t of (_c = resolved.race.traits) != null ? _c : []) {
|
|
968
|
-
pushOrigin(
|
|
969
|
-
t.choices,
|
|
970
|
-
"race",
|
|
971
|
-
{ kind: "race", slug: resolved.race.slug },
|
|
972
|
-
t.name,
|
|
973
|
-
bare,
|
|
974
|
-
t.description
|
|
975
|
-
);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
if (resolved.background) {
|
|
979
|
-
const bare = bareEntitySlug(resolved.background.slug);
|
|
980
|
-
pushOrigin(
|
|
981
|
-
resolved.background.choices,
|
|
982
|
-
"background",
|
|
983
|
-
{ kind: "background", slug: resolved.background.slug },
|
|
984
|
-
(_d = resolved.background.name) != null ? _d : "Background",
|
|
985
|
-
bare,
|
|
986
|
-
resolved.background.description
|
|
987
|
-
);
|
|
988
|
-
if (resolved.background.feature) {
|
|
989
|
-
pushOrigin(
|
|
990
|
-
resolved.background.feature.choices,
|
|
991
|
-
"background",
|
|
992
|
-
{ kind: "background", slug: resolved.background.slug },
|
|
993
|
-
resolved.background.feature.name,
|
|
994
|
-
bare,
|
|
995
|
-
resolved.background.feature.description
|
|
996
|
-
);
|
|
997
|
-
}
|
|
998
|
-
if (resolved.background.origin_feat) {
|
|
999
|
-
const originFeat = resolveOriginFeat(
|
|
1000
|
-
ctx.registry,
|
|
1001
|
-
resolved.background.origin_feat
|
|
1002
|
-
);
|
|
1003
|
-
if (originFeat) {
|
|
1004
|
-
const featSource = { kind: "feat", slug: originFeat.feat.slug };
|
|
1005
|
-
const featBare = bareEntitySlug(originFeat.feat.slug);
|
|
1006
|
-
for (const ch of (_e = originFeat.feat.choices) != null ? _e : []) {
|
|
1007
|
-
origin.push(buildItem(
|
|
1008
|
-
ch,
|
|
1009
|
-
featSource,
|
|
1010
|
-
0,
|
|
1011
|
-
originFeat.display,
|
|
1012
|
-
originRead("background"),
|
|
1013
|
-
ctx,
|
|
1014
|
-
featBare,
|
|
1015
|
-
{ keyPrefix: "feat:" }
|
|
1016
|
-
));
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
return { classes, origin };
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
// src/pc/pc.pools.ts
|
|
1025
|
-
function levelPrereqMax(d) {
|
|
1026
|
-
var _a;
|
|
1027
|
-
return ((_a = d.prerequisites) != null ? _a : []).filter((p) => p.kind === "level").reduce((m, p) => Math.max(m, p.min), 0);
|
|
1028
|
-
}
|
|
1029
|
-
function resolvePool(rc, classIndex, pool, registry) {
|
|
1030
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1031
|
-
const entity = rc.entity;
|
|
1032
|
-
const level = rc.level;
|
|
1033
|
-
const ownerBare = bareEntitySlug(entity.slug);
|
|
1034
|
-
const col = pool.count.column;
|
|
1035
|
-
const count = (_a = readTableColumn(entity.table, level, [col])) != null ? _a : 0;
|
|
1036
|
-
let anchorLevel = 1;
|
|
1037
|
-
for (let l = 1; l <= 20; l++) {
|
|
1038
|
-
const c = readTableColumn(entity.table, l, [col]);
|
|
1039
|
-
if (c != null && c >= 1) {
|
|
1040
|
-
anchorLevel = l;
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
const ft = pool.source.where.feature_type;
|
|
1045
|
-
const all = registry.search("", "optional-feature", Number.POSITIVE_INFINITY);
|
|
1046
|
-
const byBare = /* @__PURE__ */ new Map();
|
|
1047
|
-
const available = [];
|
|
1048
|
-
for (const e of all) {
|
|
1049
|
-
const d = e.data;
|
|
1050
|
-
const entry = { slug: e.slug, entity: d };
|
|
1051
|
-
byBare.set(bareEntitySlug(e.slug), entry);
|
|
1052
|
-
if (d.feature_type !== ft) continue;
|
|
1053
|
-
if (!((_b = d.available_to) != null ? _b : []).some((l) => wikilinkTailSlug(l) === ownerBare)) continue;
|
|
1054
|
-
if (levelPrereqMax(d) > level) continue;
|
|
1055
|
-
available.push(entry);
|
|
1056
|
-
}
|
|
1057
|
-
const grantDecls = [
|
|
1058
|
-
...(_d = (_c = rc.entity) == null ? void 0 : _c.pool_grants) != null ? _d : [],
|
|
1059
|
-
...(_f = (_e = rc.subclass) == null ? void 0 : _e.pool_grants) != null ? _f : []
|
|
1060
|
-
];
|
|
1061
|
-
const grantsRaw = grantDecls.filter((g) => g.pool === pool.id).flatMap((g) => g.grants).filter((g) => g.at_level <= level).map((g) => byBare.get(wikilinkTailSlug(g.feature))).filter((e) => e != null);
|
|
1062
|
-
const grantedBare = /* @__PURE__ */ new Set();
|
|
1063
|
-
const grants = grantsRaw.filter((e) => {
|
|
1064
|
-
const key = bareEntitySlug(e.slug);
|
|
1065
|
-
if (grantedBare.has(key)) return false;
|
|
1066
|
-
grantedBare.add(key);
|
|
1067
|
-
return true;
|
|
1068
|
-
});
|
|
1069
|
-
const raw = (_g = rc.choices[anchorLevel]) == null ? void 0 : _g[pool.id];
|
|
1070
|
-
const selectedSlugs = Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : [];
|
|
1071
|
-
const selected = selectedSlugs.map((s) => byBare.get(bareEntitySlug(s))).filter((e) => e != null).filter((e) => !grantedBare.has(bareEntitySlug(e.slug)));
|
|
1072
|
-
return { id: pool.id, label: pool.label, classIndex, count, anchorLevel, selected, available, grants };
|
|
1073
|
-
}
|
|
1074
|
-
function resolveAllPools(resolved, registry) {
|
|
1075
|
-
const out = [];
|
|
1076
|
-
resolved.classes.forEach((rc, classIndex) => {
|
|
1077
|
-
var _a, _b, _c;
|
|
1078
|
-
if (!rc.entity) return;
|
|
1079
|
-
const decls = [...(_a = rc.entity.selection_pools) != null ? _a : [], ...(_c = (_b = rc.subclass) == null ? void 0 : _b.selection_pools) != null ? _c : []];
|
|
1080
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1081
|
-
for (const pool of decls) {
|
|
1082
|
-
if (seen.has(pool.id)) continue;
|
|
1083
|
-
seen.add(pool.id);
|
|
1084
|
-
out.push(resolvePool(rc, classIndex, pool, registry));
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
return out;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
export {
|
|
1091
|
-
levelPrereqMax,
|
|
1092
|
-
resolvePool,
|
|
1093
|
-
resolveAllPools,
|
|
1094
|
-
stripSlug,
|
|
1095
|
-
resolveOriginFeat,
|
|
1096
|
-
PCResolver,
|
|
1097
|
-
collectChosenWeaponMasteries,
|
|
1098
|
-
collectFeatSlugs,
|
|
1099
|
-
collectFeatGrantedSpells,
|
|
1100
|
-
collectItemGrantedSpells,
|
|
1101
|
-
dedupeResolvedSpells,
|
|
1102
|
-
collectChosenGrantedFeatures,
|
|
1103
|
-
collectResolvedFeatures,
|
|
1104
|
-
wikilinkTailSlug,
|
|
1105
|
-
__matchesFilterForTest,
|
|
1106
|
-
collectChosenProficiencies,
|
|
1107
|
-
collectLanguageToolChoiceStatus,
|
|
1108
|
-
collectChosenAbilityPoints,
|
|
1109
|
-
buildDecisionLedger
|
|
1110
|
-
};
|