@archivist-gg/dnd5e 0.1.0
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/LICENSE +21 -0
- package/LICENSES/SRD.md +37 -0
- package/README.md +65 -0
- package/dist/armor/armor.codec.d.ts +10 -0
- package/dist/armor/armor.codec.js +8 -0
- package/dist/armor/armor.entity-type.d.ts +2 -0
- package/dist/armor/armor.parser.d.ts +3 -0
- package/dist/armor/armor.parser.js +7 -0
- package/dist/armor/armor.schema.d.ts +25 -0
- package/dist/armor/armor.schema.js +6 -0
- package/dist/armor/armor.types.d.ts +26 -0
- package/dist/armor/armor.types.js +0 -0
- package/dist/background/background.codec.d.ts +9 -0
- package/dist/background/background.codec.js +11 -0
- package/dist/background/background.entity-type.d.ts +2 -0
- package/dist/background/background.parser.d.ts +3 -0
- package/dist/background/background.parser.js +10 -0
- package/dist/background/background.schema.d.ts +74 -0
- package/dist/background/background.schema.js +9 -0
- package/dist/background/background.types.d.ts +52 -0
- package/dist/background/background.types.js +0 -0
- package/dist/chunk-24GFQU7T.js +18 -0
- package/dist/chunk-3DZ74AKK.js +28 -0
- package/dist/chunk-3TM34RSJ.js +23 -0
- package/dist/chunk-3TRGRSCH.js +8 -0
- package/dist/chunk-4C2KOKLF.js +185 -0
- package/dist/chunk-4F6AIZ36.js +19 -0
- package/dist/chunk-4SSDYJS2.js +86 -0
- package/dist/chunk-4TIJKN6O.js +37 -0
- package/dist/chunk-537BHVSH.js +18 -0
- package/dist/chunk-5INR4NSL.js +18 -0
- package/dist/chunk-5XUXXAQJ.js +30 -0
- package/dist/chunk-656QCX4U.js +22 -0
- package/dist/chunk-66XXW2Z2.js +133 -0
- package/dist/chunk-6NK2MUD3.js +114 -0
- package/dist/chunk-6PXE7T7C.js +79 -0
- package/dist/chunk-7P65Q426.js +158 -0
- package/dist/chunk-A7T5L7SS.js +83 -0
- package/dist/chunk-AFKTJXRA.js +39 -0
- package/dist/chunk-B7UXKNLD.js +46 -0
- package/dist/chunk-BAXWWGFJ.js +45 -0
- package/dist/chunk-BH6AMZVY.js +25 -0
- package/dist/chunk-CDW7R2QT.js +62 -0
- package/dist/chunk-DABBCYTT.js +68 -0
- package/dist/chunk-DC74TZNA.js +46 -0
- package/dist/chunk-DNAJRMNN.js +68 -0
- package/dist/chunk-DRNZJNJP.js +19 -0
- package/dist/chunk-FEOB24KP.js +18 -0
- package/dist/chunk-FFULAF2P.js +63 -0
- package/dist/chunk-FUK7QSN5.js +19 -0
- package/dist/chunk-GIOH5JB5.js +19 -0
- package/dist/chunk-GJOI2GHP.js +25 -0
- package/dist/chunk-GZ46OVGZ.js +31 -0
- package/dist/chunk-HCP3GMHS.js +44 -0
- package/dist/chunk-IDTDACM6.js +19 -0
- package/dist/chunk-IKSMX4TN.js +0 -0
- package/dist/chunk-IXZXFFFW.js +269 -0
- package/dist/chunk-J2RYSZMQ.js +16 -0
- package/dist/chunk-JEYQU3JT.js +36 -0
- package/dist/chunk-LSLSG67V.js +31 -0
- package/dist/chunk-LWFTHJIE.js +24 -0
- package/dist/chunk-MDEJHMKK.js +52 -0
- package/dist/chunk-N2JE7BWL.js +81 -0
- package/dist/chunk-NAEPSZAM.js +88 -0
- package/dist/chunk-NXR3BD2V.js +90 -0
- package/dist/chunk-PKC77VZP.js +18 -0
- package/dist/chunk-PMADYMUI.js +19 -0
- package/dist/chunk-PTXBIDG7.js +63 -0
- package/dist/chunk-PZOWBI3B.js +49 -0
- package/dist/chunk-QQ5W2AZP.js +515 -0
- package/dist/chunk-QS5L5YTJ.js +24 -0
- package/dist/chunk-QYZV2MQA.js +97 -0
- package/dist/chunk-R2ZV233X.js +233 -0
- package/dist/chunk-RAWJTA45.js +271 -0
- package/dist/chunk-RSDRMH54.js +18 -0
- package/dist/chunk-RVYYKYFL.js +18 -0
- package/dist/chunk-SSXBYF3P.js +18 -0
- package/dist/chunk-TJCNX6UZ.js +521 -0
- package/dist/chunk-TZK36BU7.js +38 -0
- package/dist/chunk-UC4FE5X3.js +65 -0
- package/dist/chunk-WP2CX2JO.js +235 -0
- package/dist/chunk-WYGD2UGN.js +14 -0
- package/dist/chunk-XJNECUPT.js +31 -0
- package/dist/chunk-XURS6Q6Q.js +127 -0
- package/dist/chunk-Y4I74YEG.js +33 -0
- package/dist/chunk-Z4TL2V7S.js +18 -0
- package/dist/chunk-Z6GXV2GO.js +121 -0
- package/dist/chunk-ZLG6FQFB.js +237 -0
- package/dist/chunk-ZMR77DDL.js +18 -0
- package/dist/class/class.codec.d.ts +10 -0
- package/dist/class/class.codec.js +15 -0
- package/dist/class/class.entity-type.d.ts +2 -0
- package/dist/class/class.parser.d.ts +3 -0
- package/dist/class/class.parser.js +14 -0
- package/dist/class/class.schema.d.ts +202 -0
- package/dist/class/class.schema.js +13 -0
- package/dist/class/class.slug.d.ts +11 -0
- package/dist/class/class.slug.js +8 -0
- package/dist/class/class.types.d.ts +74 -0
- package/dist/class/class.types.js +0 -0
- package/dist/data-srd/index.generated.d.ts +7 -0
- package/dist/data-srd/index.generated.js +146 -0
- package/dist/dnd/constants.d.ts +16 -0
- package/dist/dnd/constants.js +36 -0
- package/dist/dnd/formula-tags.d.ts +16 -0
- package/dist/dnd/formula-tags.js +119 -0
- package/dist/dnd/math.d.ts +24 -0
- package/dist/dnd/math.js +35 -0
- package/dist/dnd/prose-tags.d.ts +16 -0
- package/dist/dnd/prose-tags.js +18 -0
- package/dist/dnd/resource-die.d.ts +6 -0
- package/dist/dnd/resource-die.js +17 -0
- package/dist/dnd/resource-formula.d.ts +41 -0
- package/dist/dnd/resource-formula.js +159 -0
- package/dist/dnd/srd-tag-converter.d.ts +44 -0
- package/dist/dnd/srd-tag-converter.js +12 -0
- package/dist/dnd/tag-grammar.d.ts +19 -0
- package/dist/dnd/tag-grammar.js +12 -0
- package/dist/encounter/encounter.ai-schema.d.ts +29 -0
- package/dist/encounter/encounter.ai-schema.js +8 -0
- package/dist/encounter/encounter.entity-type.d.ts +2 -0
- package/dist/encounter/encounter.generatable.d.ts +2 -0
- package/dist/entities/base-item-resolver.d.ts +21 -0
- package/dist/entities/base-item-resolver.js +9 -0
- package/dist/entities/slug.d.ts +5 -0
- package/dist/entities/slug.js +6 -0
- package/dist/feat/feat.codec.d.ts +9 -0
- package/dist/feat/feat.codec.js +10 -0
- package/dist/feat/feat.entity-type.d.ts +2 -0
- package/dist/feat/feat.parser.d.ts +3 -0
- package/dist/feat/feat.parser.js +9 -0
- package/dist/feat/feat.schema.d.ts +194 -0
- package/dist/feat/feat.schema.js +8 -0
- package/dist/feat/feat.types.d.ts +42 -0
- package/dist/feat/feat.types.js +0 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +139149 -0
- package/dist/inline-tag-parser.d.ts +11 -0
- package/dist/inline-tag-parser.js +6 -0
- package/dist/item/item.actions-map.d.ts +41 -0
- package/dist/item/item.actions-map.js +85 -0
- package/dist/item/item.ai-schema.d.ts +35 -0
- package/dist/item/item.ai-schema.js +6 -0
- package/dist/item/item.attunement.d.ts +18 -0
- package/dist/item/item.attunement.js +12 -0
- package/dist/item/item.bonuses.d.ts +2 -0
- package/dist/item/item.bonuses.js +7 -0
- package/dist/item/item.codec.d.ts +3 -0
- package/dist/item/item.codec.js +8 -0
- package/dist/item/item.conditions.d.ts +10 -0
- package/dist/item/item.conditions.js +8 -0
- package/dist/item/item.conditions.types.d.ts +28 -0
- package/dist/item/item.conditions.types.js +0 -0
- package/dist/item/item.enrichment.d.ts +4 -0
- package/dist/item/item.enrichment.js +9 -0
- package/dist/item/item.entity-type.d.ts +2 -0
- package/dist/item/item.generatable.d.ts +2 -0
- package/dist/item/item.parser.d.ts +3 -0
- package/dist/item/item.parser.js +7 -0
- package/dist/item/item.schema.d.ts +174 -0
- package/dist/item/item.schema.js +8 -0
- package/dist/item/item.types.d.ts +108 -0
- package/dist/item/item.types.js +0 -0
- package/dist/monster/monster.ai-schema.d.ts +67 -0
- package/dist/monster/monster.ai-schema.js +6 -0
- package/dist/monster/monster.codec.d.ts +13 -0
- package/dist/monster/monster.enrichment.d.ts +10 -0
- package/dist/monster/monster.enrichment.js +19 -0
- package/dist/monster/monster.entity-type.d.ts +2 -0
- package/dist/monster/monster.generatable.d.ts +2 -0
- package/dist/monster/monster.parser.d.ts +3 -0
- package/dist/monster/monster.parser.js +6 -0
- package/dist/monster/monster.resolve.d.ts +10 -0
- package/dist/monster/monster.types.d.ts +29 -0
- package/dist/monster/monster.types.js +1 -0
- package/dist/npc/npc.ai-schema.d.ts +6 -0
- package/dist/npc/npc.entity-type.d.ts +2 -0
- package/dist/npc/npc.generatable.d.ts +2 -0
- package/dist/optional-feature/optional-feature.codec.d.ts +14 -0
- package/dist/optional-feature/optional-feature.codec.js +11 -0
- package/dist/optional-feature/optional-feature.entity-type.d.ts +2 -0
- package/dist/optional-feature/optional-feature.parser.d.ts +3 -0
- package/dist/optional-feature/optional-feature.parser.js +10 -0
- package/dist/optional-feature/optional-feature.schema.d.ts +236 -0
- package/dist/optional-feature/optional-feature.schema.js +9 -0
- package/dist/pack.d.ts +11 -0
- package/dist/pc/conditions.constants.d.ts +3 -0
- package/dist/pc/conditions.constants.js +8 -0
- package/dist/pc/decision-recognizer.d.ts +4 -0
- package/dist/pc/decision-recognizer.js +8 -0
- package/dist/pc/pc.conditions.d.ts +3 -0
- package/dist/pc/pc.conditions.js +6 -0
- package/dist/pc/pc.decision-engine.d.ts +97 -0
- package/dist/pc/pc.decision-engine.js +19 -0
- package/dist/pc/pc.equipment.d.ts +12 -0
- package/dist/pc/pc.equipment.js +15 -0
- package/dist/pc/pc.feature-effects.d.ts +95 -0
- package/dist/pc/pc.feature-effects.js +9 -0
- package/dist/pc/pc.formula-context.d.ts +4 -0
- package/dist/pc/pc.formula-context.js +11 -0
- package/dist/pc/pc.parser.d.ts +3 -0
- package/dist/pc/pc.parser.js +41 -0
- package/dist/pc/pc.pools.d.ts +12 -0
- package/dist/pc/pc.pools.js +15 -0
- package/dist/pc/pc.proficiencies.d.ts +8 -0
- package/dist/pc/pc.proficiencies.js +47 -0
- package/dist/pc/pc.proficiency-query.d.ts +11 -0
- package/dist/pc/pc.proficiency-query.js +17 -0
- package/dist/pc/pc.recalc.d.ts +105 -0
- package/dist/pc/pc.recalc.js +662 -0
- package/dist/pc/pc.resolver.d.ts +34 -0
- package/dist/pc/pc.resolver.js +267 -0
- package/dist/pc/pc.resource-seed.d.ts +10 -0
- package/dist/pc/pc.resource-seed.js +40 -0
- package/dist/pc/pc.rest.d.ts +23 -0
- package/dist/pc/pc.rest.js +128 -0
- package/dist/pc/pc.schema.d.ts +294 -0
- package/dist/pc/pc.schema.js +7 -0
- package/dist/pc/pc.slotting.d.ts +22 -0
- package/dist/pc/pc.slotting.js +20 -0
- package/dist/pc/pc.spellcasting.d.ts +56 -0
- package/dist/pc/pc.spellcasting.js +16 -0
- package/dist/pc/pc.table-column.d.ts +12 -0
- package/dist/pc/pc.table-column.js +8 -0
- package/dist/pc/pc.types.d.ts +514 -0
- package/dist/pc/pc.types.js +0 -0
- package/dist/race/race.codec.d.ts +9 -0
- package/dist/race/race.codec.js +13 -0
- package/dist/race/race.entity-type.d.ts +2 -0
- package/dist/race/race.parser.d.ts +3 -0
- package/dist/race/race.parser.js +12 -0
- package/dist/race/race.schema.d.ts +67 -0
- package/dist/race/race.schema.js +11 -0
- package/dist/race/race.types.d.ts +44 -0
- package/dist/race/race.types.js +0 -0
- package/dist/schemas/attack-schema.d.ts +38 -0
- package/dist/schemas/choice-schema.d.ts +5 -0
- package/dist/schemas/choice-schema.js +7 -0
- package/dist/schemas/duration-schema.d.ts +13 -0
- package/dist/schemas/duration-schema.js +6 -0
- package/dist/schemas/equipment-grant-schema.d.ts +6 -0
- package/dist/schemas/equipment-grant-schema.js +12 -0
- package/dist/schemas/feature-effect-schema.d.ts +131 -0
- package/dist/schemas/feature-effect-schema.js +6 -0
- package/dist/schemas/feature-schema.d.ts +2 -0
- package/dist/schemas/feature-schema.js +10 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/resource-schema.d.ts +95 -0
- package/dist/schemas/resource-schema.js +12 -0
- package/dist/schemas/selection-pool-schema.d.ts +34 -0
- package/dist/schemas/selection-pool-schema.js +10 -0
- package/dist/spell/spell.access.d.ts +15 -0
- package/dist/spell/spell.access.js +25 -0
- package/dist/spell/spell.ai-schema.d.ts +24 -0
- package/dist/spell/spell.ai-schema.js +6 -0
- package/dist/spell/spell.codec.d.ts +3 -0
- package/dist/spell/spell.codec.js +8 -0
- package/dist/spell/spell.enrichment.d.ts +2 -0
- package/dist/spell/spell.enrichment.js +9 -0
- package/dist/spell/spell.entity-type.d.ts +2 -0
- package/dist/spell/spell.filter.d.ts +15 -0
- package/dist/spell/spell.filter.js +87 -0
- package/dist/spell/spell.generatable.d.ts +2 -0
- package/dist/spell/spell.parser.d.ts +3 -0
- package/dist/spell/spell.parser.js +7 -0
- package/dist/spell/spell.scaling.d.ts +14 -0
- package/dist/spell/spell.scaling.js +28 -0
- package/dist/spell/spell.schema.d.ts +31 -0
- package/dist/spell/spell.schema.js +6 -0
- package/dist/spell/spell.types.d.ts +25 -0
- package/dist/spell/spell.types.js +0 -0
- package/dist/srd-store.d.ts +53 -0
- package/dist/subclass/subclass.codec.d.ts +11 -0
- package/dist/subclass/subclass.codec.js +14 -0
- package/dist/subclass/subclass.entity-type.d.ts +2 -0
- package/dist/subclass/subclass.parser.d.ts +3 -0
- package/dist/subclass/subclass.parser.js +13 -0
- package/dist/subclass/subclass.schema.d.ts +118 -0
- package/dist/subclass/subclass.schema.js +12 -0
- package/dist/subclass/subclass.types.d.ts +20 -0
- package/dist/subclass/subclass.types.js +0 -0
- package/dist/types/abilities.d.ts +8 -0
- package/dist/types/abilities.js +0 -0
- package/dist/types/ac.d.ts +5 -0
- package/dist/types/attack.d.ts +22 -0
- package/dist/types/attack.js +0 -0
- package/dist/types/casting-option.d.ts +14 -0
- package/dist/types/casting-option.js +0 -0
- package/dist/types/choice.d.ts +66 -0
- package/dist/types/choice.js +6 -0
- package/dist/types/edition.d.ts +4 -0
- package/dist/types/edition.js +0 -0
- package/dist/types/equipment-grant.d.ts +41 -0
- package/dist/types/equipment-grant.js +0 -0
- package/dist/types/feature-effect.d.ts +79 -0
- package/dist/types/feature-effect.js +0 -0
- package/dist/types/feature.d.ts +41 -0
- package/dist/types/feature.js +0 -0
- package/dist/types/formula-context.d.ts +7 -0
- package/dist/types/formula-context.js +0 -0
- package/dist/types/hp.d.ts +4 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/item-conditions.types.d.ts +63 -0
- package/dist/types/item-conditions.types.js +0 -0
- package/dist/types/optional-feature.types.d.ts +60 -0
- package/dist/types/optional-feature.types.js +0 -0
- package/dist/types/resource.d.ts +44 -0
- package/dist/types/resource.js +0 -0
- package/dist/types/selection-pool.d.ts +37 -0
- package/dist/types/selection-pool.js +0 -0
- package/dist/types/speed.d.ts +8 -0
- package/dist/weapon/weapon.codec.d.ts +12 -0
- package/dist/weapon/weapon.codec.js +8 -0
- package/dist/weapon/weapon.entity-type.d.ts +2 -0
- package/dist/weapon/weapon.parser.d.ts +3 -0
- package/dist/weapon/weapon.parser.js +7 -0
- package/dist/weapon/weapon.schema.d.ts +34 -0
- package/dist/weapon/weapon.schema.js +6 -0
- package/dist/weapon/weapon.types.d.ts +36 -0
- package/dist/weapon/weapon.types.js +0 -0
- package/package.json +32 -0
- package/src/data-srd/ATTRIBUTION.md +2 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
evaluateConditions
|
|
3
|
+
} from "./chunk-DNAJRMNN.js";
|
|
4
|
+
|
|
5
|
+
// src/item/item.bonuses.ts
|
|
6
|
+
function isConditionalBonus(x) {
|
|
7
|
+
return !!x && typeof x === "object" && typeof x.value === "number" && Array.isArray(x.when);
|
|
8
|
+
}
|
|
9
|
+
function readNumericBonus(raw, ctx) {
|
|
10
|
+
if (raw === void 0 || raw === null) return null;
|
|
11
|
+
if (typeof raw === "number") {
|
|
12
|
+
return raw === 0 ? null : { kind: "applied", value: raw };
|
|
13
|
+
}
|
|
14
|
+
if (!isConditionalBonus(raw)) return null;
|
|
15
|
+
if (raw.value === 0) return null;
|
|
16
|
+
const outcome = evaluateConditions(raw.when, ctx);
|
|
17
|
+
if (outcome === "true") return { kind: "applied", value: raw.value };
|
|
18
|
+
if (outcome === "false") return { kind: "skipped" };
|
|
19
|
+
return { kind: "informational", value: raw.value, conditions: raw.when };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
readNumericBonus
|
|
24
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
durationSchema
|
|
3
|
+
} from "./chunk-WYGD2UGN.js";
|
|
4
|
+
import {
|
|
5
|
+
actionCostEnum,
|
|
6
|
+
resetTriggerEnum,
|
|
7
|
+
resourceConsumptionSchema
|
|
8
|
+
} from "./chunk-PZOWBI3B.js";
|
|
9
|
+
import {
|
|
10
|
+
featureEffectSchema
|
|
11
|
+
} from "./chunk-NXR3BD2V.js";
|
|
12
|
+
|
|
13
|
+
// src/optional-feature/optional-feature.schema.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var editionEnum = z.enum(["2014", "2024"]);
|
|
16
|
+
var abilityEnum = z.enum(["str", "dex", "con", "int", "wis", "cha"]);
|
|
17
|
+
var wikilinkRegex = /^\[\[[^[\]]+\]\]$/;
|
|
18
|
+
var prerequisiteSchema = z.discriminatedUnion("kind", [
|
|
19
|
+
z.object({ kind: z.literal("level"), min: z.number().int().positive() }),
|
|
20
|
+
z.object({ kind: z.literal("spell-known"), spell: z.string().regex(wikilinkRegex) }),
|
|
21
|
+
z.object({ kind: z.literal("pact"), pact: z.enum(["tome", "blade", "chain", "talisman"]) }),
|
|
22
|
+
z.object({ kind: z.literal("class"), class: z.string().regex(wikilinkRegex) }),
|
|
23
|
+
z.object({ kind: z.literal("ability"), ability: abilityEnum, min: z.number().int().positive() }),
|
|
24
|
+
z.object({ kind: z.literal("other"), detail: z.string() })
|
|
25
|
+
]);
|
|
26
|
+
var usesSchema = z.object({
|
|
27
|
+
max: z.union([z.number(), z.string()]),
|
|
28
|
+
recharge: resetTriggerEnum
|
|
29
|
+
});
|
|
30
|
+
var optionalFeatureEntitySchema = z.object({
|
|
31
|
+
slug: z.string().min(1),
|
|
32
|
+
name: z.string().min(1),
|
|
33
|
+
edition: editionEnum,
|
|
34
|
+
source: z.string().min(1),
|
|
35
|
+
feature_type: z.string().min(1),
|
|
36
|
+
description: z.string(),
|
|
37
|
+
prerequisites: z.array(prerequisiteSchema),
|
|
38
|
+
available_to: z.array(z.string().regex(wikilinkRegex)),
|
|
39
|
+
effects: z.array(featureEffectSchema),
|
|
40
|
+
action_cost: actionCostEnum.nullable().optional(),
|
|
41
|
+
uses: usesSchema.nullable().optional(),
|
|
42
|
+
consumes: resourceConsumptionSchema.nullable().optional(),
|
|
43
|
+
duration: durationSchema.nullable().optional(),
|
|
44
|
+
passive: z.boolean().optional(),
|
|
45
|
+
// Phase 3 activatable buffs: an activatable boon folds its effects only while
|
|
46
|
+
// its slug is present in state.active_buffs (toggled in the PoolTab).
|
|
47
|
+
activatable: z.boolean().optional()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
optionalFeatureEntitySchema
|
|
52
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spellEntitySchema
|
|
3
|
+
} from "./chunk-Y4I74YEG.js";
|
|
4
|
+
|
|
5
|
+
// src/spell/spell.parser.ts
|
|
6
|
+
import { parseYaml, toStringSafe } from "@archivist-gg/core";
|
|
7
|
+
var KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
8
|
+
"name",
|
|
9
|
+
"level",
|
|
10
|
+
"school",
|
|
11
|
+
"casting_time",
|
|
12
|
+
"range",
|
|
13
|
+
"components",
|
|
14
|
+
"duration",
|
|
15
|
+
"concentration",
|
|
16
|
+
"ritual",
|
|
17
|
+
"classes",
|
|
18
|
+
"description",
|
|
19
|
+
"at_higher_levels",
|
|
20
|
+
"damage",
|
|
21
|
+
"saving_throw",
|
|
22
|
+
"casting_options",
|
|
23
|
+
// Body-only metadata that's emitted to YAML but ignored at runtime — accept silently.
|
|
24
|
+
"slug",
|
|
25
|
+
"edition",
|
|
26
|
+
"source"
|
|
27
|
+
]);
|
|
28
|
+
function parseSpell(source) {
|
|
29
|
+
const result = parseYaml(source, ["name"]);
|
|
30
|
+
if (!result.success) return result;
|
|
31
|
+
const meta = {};
|
|
32
|
+
if (typeof result.data.source === "string") meta.source = result.data.source;
|
|
33
|
+
if (typeof result.data.edition === "string") meta.edition = result.data.edition;
|
|
34
|
+
const filtered = {};
|
|
35
|
+
for (const [k, v] of Object.entries(result.data)) {
|
|
36
|
+
if (k === "slug" || k === "edition" || k === "source") continue;
|
|
37
|
+
if (!KNOWN_KEYS.has(k)) {
|
|
38
|
+
return { success: false, error: `Unknown spell field: ${k}` };
|
|
39
|
+
}
|
|
40
|
+
filtered[k] = v;
|
|
41
|
+
}
|
|
42
|
+
const parsed = spellEntitySchema.safeParse(filtered);
|
|
43
|
+
if (!parsed.success) {
|
|
44
|
+
return { success: false, error: `spell schema validation failed: ${parsed.error.message}` };
|
|
45
|
+
}
|
|
46
|
+
const raw = parsed.data;
|
|
47
|
+
const spell = { name: raw.name };
|
|
48
|
+
if (raw.level != null) spell.level = raw.level;
|
|
49
|
+
if (raw.school != null) spell.school = toStringSafe(raw.school);
|
|
50
|
+
if (raw.casting_time != null) spell.casting_time = toStringSafe(raw.casting_time);
|
|
51
|
+
if (raw.range != null) spell.range = toStringSafe(raw.range);
|
|
52
|
+
if (raw.components != null) spell.components = toStringSafe(raw.components);
|
|
53
|
+
if (raw.duration != null) spell.duration = toStringSafe(raw.duration);
|
|
54
|
+
if (raw.concentration != null) spell.concentration = Boolean(raw.concentration);
|
|
55
|
+
if (raw.ritual != null) spell.ritual = Boolean(raw.ritual);
|
|
56
|
+
if (raw.classes) spell.classes = raw.classes.map(String);
|
|
57
|
+
if (raw.description) spell.description = raw.description;
|
|
58
|
+
if (raw.at_higher_levels) spell.at_higher_levels = raw.at_higher_levels.map(String);
|
|
59
|
+
if (raw.damage) spell.damage = { types: raw.damage.types.map(String) };
|
|
60
|
+
if (raw.saving_throw) spell.saving_throw = { ability: raw.saving_throw.ability };
|
|
61
|
+
if (raw.casting_options) {
|
|
62
|
+
spell.casting_options = raw.casting_options.map((opt) => {
|
|
63
|
+
const co = { type: opt.type };
|
|
64
|
+
if (opt.damage_roll !== void 0) co.damage_roll = opt.damage_roll;
|
|
65
|
+
if (opt.target_count !== void 0) co.target_count = opt.target_count;
|
|
66
|
+
if (opt.duration !== void 0) co.duration = opt.duration;
|
|
67
|
+
if (opt.range !== void 0) co.range = opt.range;
|
|
68
|
+
if (opt.concentration !== void 0) co.concentration = opt.concentration;
|
|
69
|
+
if (opt.shape_size !== void 0) co.shape_size = opt.shape_size;
|
|
70
|
+
if (opt.desc !== void 0) co.desc = opt.desc;
|
|
71
|
+
return co;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (meta.source) spell.source = meta.source;
|
|
75
|
+
if (meta.edition) spell.edition = meta.edition;
|
|
76
|
+
return { success: true, data: spell };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
parseSpell
|
|
81
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ABILITY_KEYS,
|
|
3
|
+
CR_PROFICIENCY,
|
|
4
|
+
CR_XP,
|
|
5
|
+
SIZE_HIT_DICE
|
|
6
|
+
} from "./chunk-WP2CX2JO.js";
|
|
7
|
+
|
|
8
|
+
// src/dnd/math.ts
|
|
9
|
+
function abilityModifier(score) {
|
|
10
|
+
return Math.floor((score - 10) / 2);
|
|
11
|
+
}
|
|
12
|
+
function formatModifier(mod) {
|
|
13
|
+
return mod >= 0 ? `+${mod}` : `${mod}`;
|
|
14
|
+
}
|
|
15
|
+
function proficiencyBonusFromCR(cr) {
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = CR_PROFICIENCY[cr]) != null ? _a : 2;
|
|
18
|
+
}
|
|
19
|
+
function proficiencyFromLevel(level) {
|
|
20
|
+
if (level < 5) return 2;
|
|
21
|
+
if (level < 9) return 3;
|
|
22
|
+
if (level < 13) return 4;
|
|
23
|
+
if (level < 17) return 5;
|
|
24
|
+
return 6;
|
|
25
|
+
}
|
|
26
|
+
function crToXP(cr) {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = CR_XP[cr]) != null ? _a : 0;
|
|
29
|
+
}
|
|
30
|
+
function hitDiceSizeFromCreatureSize(size) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = SIZE_HIT_DICE[size.toLowerCase()]) != null ? _a : 8;
|
|
33
|
+
}
|
|
34
|
+
function hpFromHitDice(hitDiceCount, hitDiceSize, conMod) {
|
|
35
|
+
const avg = Math.floor(hitDiceCount * (hitDiceSize + 1) / 2 + hitDiceCount * conMod);
|
|
36
|
+
return Math.max(1, avg);
|
|
37
|
+
}
|
|
38
|
+
function parseHitDiceFormula(formula) {
|
|
39
|
+
const match = formula.match(/^(\d+)d(\d+)/i);
|
|
40
|
+
if (!match) return null;
|
|
41
|
+
return { count: parseInt(match[1], 10), size: parseInt(match[2], 10) };
|
|
42
|
+
}
|
|
43
|
+
function savingThrow(abilityScore, isProficient, profBonus) {
|
|
44
|
+
return abilityModifier(abilityScore) + (isProficient ? profBonus : 0);
|
|
45
|
+
}
|
|
46
|
+
function skillBonus(abilityScore, proficiency, profBonus) {
|
|
47
|
+
const mod = abilityModifier(abilityScore);
|
|
48
|
+
if (proficiency === "expertise") return mod + profBonus * 2;
|
|
49
|
+
if (proficiency === "proficient") return mod + profBonus;
|
|
50
|
+
return mod;
|
|
51
|
+
}
|
|
52
|
+
function passive(abilityScore, proficiency, profBonus) {
|
|
53
|
+
return 10 + skillBonus(abilityScore, proficiency, profBonus);
|
|
54
|
+
}
|
|
55
|
+
function passivePerception(wisScore, perceptionProf, profBonus) {
|
|
56
|
+
return passive(wisScore, perceptionProf, profBonus);
|
|
57
|
+
}
|
|
58
|
+
function attackBonus(abilityScore, profBonus) {
|
|
59
|
+
return abilityModifier(abilityScore) + profBonus;
|
|
60
|
+
}
|
|
61
|
+
function saveDC(abilityScore, profBonus) {
|
|
62
|
+
return 8 + profBonus + abilityModifier(abilityScore);
|
|
63
|
+
}
|
|
64
|
+
function abilityNameToKey(name) {
|
|
65
|
+
const lower = name.toLowerCase();
|
|
66
|
+
if (ABILITY_KEYS.includes(lower)) {
|
|
67
|
+
return lower;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
abilityModifier,
|
|
74
|
+
formatModifier,
|
|
75
|
+
proficiencyBonusFromCR,
|
|
76
|
+
proficiencyFromLevel,
|
|
77
|
+
crToXP,
|
|
78
|
+
hitDiceSizeFromCreatureSize,
|
|
79
|
+
hpFromHitDice,
|
|
80
|
+
parseHitDiceFormula,
|
|
81
|
+
savingThrow,
|
|
82
|
+
skillBonus,
|
|
83
|
+
passive,
|
|
84
|
+
passivePerception,
|
|
85
|
+
attackBonus,
|
|
86
|
+
saveDC,
|
|
87
|
+
abilityNameToKey
|
|
88
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/schemas/feature-effect-schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var featureEffectSchema = z.discriminatedUnion("kind", [
|
|
4
|
+
z.object({ kind: z.literal("initiative-bonus"), value: z.number().int() }),
|
|
5
|
+
z.object({ kind: z.literal("immune-condition"), condition: z.string().min(1), while: z.string().optional() }),
|
|
6
|
+
z.object({ kind: z.literal("resistance"), damage_type: z.string().min(1) }),
|
|
7
|
+
z.object({ kind: z.literal("hp-per-level-bonus"), value: z.number().int() }),
|
|
8
|
+
z.object({
|
|
9
|
+
kind: z.literal("speed-bonus"),
|
|
10
|
+
mode: z.enum(["walk", "fly", "swim", "climb", "burrow"]),
|
|
11
|
+
value: z.number().int(),
|
|
12
|
+
// when true, value is an absolute floor (Math.max), not additive; currently
|
|
13
|
+
// only surfaced for mode:"walk" — other modes have no derived speed yet.
|
|
14
|
+
set: z.boolean().optional()
|
|
15
|
+
}),
|
|
16
|
+
z.object({
|
|
17
|
+
kind: z.literal("sense"),
|
|
18
|
+
type: z.enum(["darkvision", "blindsight", "tremorsense", "truesight"]),
|
|
19
|
+
range: z.number().int().nonnegative()
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
kind: z.literal("apply-condition"),
|
|
23
|
+
condition: z.string().min(1),
|
|
24
|
+
duration: z.string().optional(),
|
|
25
|
+
ends_on: z.array(z.string()).optional(),
|
|
26
|
+
save_repeat: z.object({
|
|
27
|
+
ability: z.string().min(1),
|
|
28
|
+
timing: z.string().min(1)
|
|
29
|
+
}).optional()
|
|
30
|
+
}),
|
|
31
|
+
z.object({
|
|
32
|
+
kind: z.literal("damage-bonus"),
|
|
33
|
+
// intentionally an open string, NOT a damage-type enum: must accept the
|
|
34
|
+
// literal "chosen" (player-selected damage type at action time) alongside
|
|
35
|
+
// canonical damage types. Do not tighten to an enum.
|
|
36
|
+
damage_type: z.string().min(1),
|
|
37
|
+
amount: z.string().min(1),
|
|
38
|
+
applies_to: z.enum(["weapon", "spell", "all"]).optional(),
|
|
39
|
+
condition: z.string().optional()
|
|
40
|
+
}),
|
|
41
|
+
z.object({
|
|
42
|
+
kind: z.literal("proficiency"),
|
|
43
|
+
proficiency_type: z.enum(["skill", "tool", "language", "saving-throw", "armor", "weapon"]),
|
|
44
|
+
value: z.string().min(1)
|
|
45
|
+
}),
|
|
46
|
+
z.object({
|
|
47
|
+
kind: z.literal("ac-bonus"),
|
|
48
|
+
value: z.number().int(),
|
|
49
|
+
requires_armor: z.boolean().optional()
|
|
50
|
+
}),
|
|
51
|
+
z.object({
|
|
52
|
+
kind: z.literal("unarmored-ac"),
|
|
53
|
+
abilities: z.array(z.enum(["str", "dex", "con", "int", "wis", "cha"])),
|
|
54
|
+
base: z.number().int().optional(),
|
|
55
|
+
allow_shield: z.boolean().optional()
|
|
56
|
+
}),
|
|
57
|
+
z.object({
|
|
58
|
+
kind: z.literal("weapon-ability"),
|
|
59
|
+
ability: z.union([z.enum(["str", "dex", "con", "int", "wis", "cha"]), z.literal("spellcasting")]),
|
|
60
|
+
weapons: z.union([z.literal("chosen"), z.string(), z.array(z.string())]).optional()
|
|
61
|
+
}),
|
|
62
|
+
z.object({
|
|
63
|
+
kind: z.literal("roll-modifier"),
|
|
64
|
+
mode: z.enum(["advantage", "disadvantage"]),
|
|
65
|
+
roll: z.enum(["ability-check", "saving-throw", "attack"]),
|
|
66
|
+
scope: z.string().optional(),
|
|
67
|
+
condition: z.string().optional()
|
|
68
|
+
}),
|
|
69
|
+
z.object({ kind: z.literal("extra-attack"), count: z.number().int().positive() }),
|
|
70
|
+
z.object({
|
|
71
|
+
kind: z.literal("crit-range"),
|
|
72
|
+
min_roll: z.number().int().min(2).max(20),
|
|
73
|
+
applies_to: z.enum(["weapon", "spell", "all"]).optional(),
|
|
74
|
+
condition: z.string().optional()
|
|
75
|
+
}),
|
|
76
|
+
z.object({
|
|
77
|
+
kind: z.literal("reroll-damage"),
|
|
78
|
+
max_reroll: z.number().int().positive(),
|
|
79
|
+
applies_to: z.enum(["weapon", "spell", "all"]).optional(),
|
|
80
|
+
once_per_die: z.boolean().optional()
|
|
81
|
+
}),
|
|
82
|
+
z.object({
|
|
83
|
+
kind: z.literal("attack-rule"),
|
|
84
|
+
flag: z.enum(["no-ranged-in-melee-disadvantage"])
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
featureEffectSchema
|
|
90
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseRace
|
|
3
|
+
} from "./chunk-IDTDACM6.js";
|
|
4
|
+
|
|
5
|
+
// src/race/race.codec.ts
|
|
6
|
+
import yaml from "js-yaml";
|
|
7
|
+
var raceCodec = {
|
|
8
|
+
parse(doc) {
|
|
9
|
+
return parseRace(doc.body);
|
|
10
|
+
},
|
|
11
|
+
serialize(entity) {
|
|
12
|
+
return yaml.dump(entity, { lineWidth: -1, sortKeys: false });
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
raceCodec
|
|
18
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
subclassEntitySchema
|
|
3
|
+
} from "./chunk-B7UXKNLD.js";
|
|
4
|
+
|
|
5
|
+
// src/subclass/subclass.parser.ts
|
|
6
|
+
import { parseYaml } from "@archivist-gg/core";
|
|
7
|
+
function parseSubclass(source) {
|
|
8
|
+
const raw = parseYaml(source, ["name", "slug", "parent_class"]);
|
|
9
|
+
if (!raw.success) return raw;
|
|
10
|
+
const result = subclassEntitySchema.safeParse({ edition: "2014", ...raw.data });
|
|
11
|
+
if (!result.success) {
|
|
12
|
+
return { success: false, error: `subclass schema validation failed: ${result.error.message}` };
|
|
13
|
+
}
|
|
14
|
+
return { success: true, data: result.data };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
parseSubclass
|
|
19
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/monster/monster.ai-schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var abilitiesSchema = z.object({
|
|
4
|
+
str: z.number().min(1).max(30),
|
|
5
|
+
dex: z.number().min(1).max(30),
|
|
6
|
+
con: z.number().min(1).max(30),
|
|
7
|
+
int: z.number().min(1).max(30),
|
|
8
|
+
wis: z.number().min(1).max(30),
|
|
9
|
+
cha: z.number().min(1).max(30)
|
|
10
|
+
});
|
|
11
|
+
var acSchema = z.object({
|
|
12
|
+
ac: z.number(),
|
|
13
|
+
from: z.array(z.string()).optional(),
|
|
14
|
+
condition: z.string().optional()
|
|
15
|
+
});
|
|
16
|
+
var hpSchema = z.object({
|
|
17
|
+
average: z.number(),
|
|
18
|
+
formula: z.string()
|
|
19
|
+
});
|
|
20
|
+
var speedSchema = z.object({
|
|
21
|
+
walk: z.number().optional(),
|
|
22
|
+
fly: z.number().optional(),
|
|
23
|
+
swim: z.number().optional(),
|
|
24
|
+
climb: z.number().optional(),
|
|
25
|
+
burrow: z.number().optional()
|
|
26
|
+
});
|
|
27
|
+
var featureSchema = z.object({
|
|
28
|
+
name: z.string(),
|
|
29
|
+
entries: z.array(z.string().describe(
|
|
30
|
+
"Inline tag forms: `atk:ABILITY` for non-proficient attacks (ability mod alone), `atk:ABILITY+PB` for proficient attacks (ability mod + proficiency), `atk:+N` for literal attack bonuses, `dmg:DICE+ABILITY` for damage rolls (PB never added to damage), `dc:ABILITY` for save DCs (proficiency always included implicitly)."
|
|
31
|
+
))
|
|
32
|
+
});
|
|
33
|
+
var monsterInputSchema = z.object({
|
|
34
|
+
name: z.string().describe("Monster name"),
|
|
35
|
+
size: z.enum(["Tiny", "Small", "Medium", "Large", "Huge", "Gargantuan"]),
|
|
36
|
+
type: z.string().describe("Creature type (e.g., aberration, beast, dragon)"),
|
|
37
|
+
subtype: z.string().optional(),
|
|
38
|
+
alignment: z.string(),
|
|
39
|
+
cr: z.string().describe('Challenge rating (e.g., "0", "1/8", "1/4", "1/2", "1" through "30")'),
|
|
40
|
+
abilities: abilitiesSchema,
|
|
41
|
+
ac: z.array(acSchema),
|
|
42
|
+
hp: hpSchema,
|
|
43
|
+
speed: speedSchema,
|
|
44
|
+
saves: z.record(z.string(), z.number()).optional(),
|
|
45
|
+
skills: z.record(z.string(), z.number()).optional(),
|
|
46
|
+
damage_vulnerabilities: z.array(z.string()).optional(),
|
|
47
|
+
damage_resistances: z.array(z.string()).optional(),
|
|
48
|
+
damage_immunities: z.array(z.string()).optional(),
|
|
49
|
+
condition_immunities: z.array(z.string()).optional(),
|
|
50
|
+
senses: z.array(z.string()).optional(),
|
|
51
|
+
passive_perception: z.number().optional(),
|
|
52
|
+
languages: z.array(z.string()).optional(),
|
|
53
|
+
traits: z.array(featureSchema).optional(),
|
|
54
|
+
actions: z.array(featureSchema).optional(),
|
|
55
|
+
reactions: z.array(featureSchema).optional(),
|
|
56
|
+
legendary_actions: z.array(featureSchema).optional(),
|
|
57
|
+
legendary_action_uses: z.number().optional(),
|
|
58
|
+
legendary_resistance: z.number().optional()
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
monsterInputSchema
|
|
63
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/schemas/resource-schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var resetTriggerEnum = z.enum(["short-rest", "long-rest", "dawn", "dusk", "turn", "round", "custom"]);
|
|
4
|
+
var actionCostEnum = z.enum(["action", "bonus-action", "reaction", "free", "special"]);
|
|
5
|
+
var resourceSchema = z.object({
|
|
6
|
+
id: z.string().min(1),
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
max_formula: z.string().min(1),
|
|
9
|
+
scales_at: z.array(z.object({
|
|
10
|
+
level: z.number().int().positive(),
|
|
11
|
+
max: z.string().min(1)
|
|
12
|
+
}).strict()).optional(),
|
|
13
|
+
die: z.object({
|
|
14
|
+
base: z.string().min(1),
|
|
15
|
+
scaling: z.record(z.string(), z.string()).optional()
|
|
16
|
+
}).optional(),
|
|
17
|
+
reset: resetTriggerEnum,
|
|
18
|
+
consumes: z.object({
|
|
19
|
+
resource: z.string().min(1),
|
|
20
|
+
amount: z.number().int().positive()
|
|
21
|
+
}).optional(),
|
|
22
|
+
recovery: z.array(z.object({
|
|
23
|
+
id: z.string().min(1),
|
|
24
|
+
name: z.string().min(1),
|
|
25
|
+
amount: z.union([z.number(), z.string()]),
|
|
26
|
+
action: actionCostEnum.optional(),
|
|
27
|
+
uses: z.number().int().nonnegative().optional(),
|
|
28
|
+
reset: resetTriggerEnum
|
|
29
|
+
})).optional()
|
|
30
|
+
});
|
|
31
|
+
var resourceConsumptionSchema = z.object({
|
|
32
|
+
source: z.enum(["resource", "class-column", "attack-dice"]).optional(),
|
|
33
|
+
resource: z.string().optional(),
|
|
34
|
+
column: z.string().optional(),
|
|
35
|
+
amount: z.number().int().positive(),
|
|
36
|
+
expend_condition: z.enum(["roll_succeeds", "roll_fails", "target_takes_damage", "always"]).optional(),
|
|
37
|
+
free_uses: z.object({
|
|
38
|
+
amount: z.number().int().positive(),
|
|
39
|
+
reset: resetTriggerEnum,
|
|
40
|
+
state_key: z.string().optional()
|
|
41
|
+
}).optional()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
resetTriggerEnum,
|
|
46
|
+
actionCostEnum,
|
|
47
|
+
resourceSchema,
|
|
48
|
+
resourceConsumptionSchema
|
|
49
|
+
};
|