@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,16 @@
|
|
|
1
|
+
export declare const CR_PROFICIENCY: Record<string, number>;
|
|
2
|
+
export declare const CR_XP: Record<string, number>;
|
|
3
|
+
export declare const ALL_CR_VALUES: string[];
|
|
4
|
+
export declare const SIZE_HIT_DICE: Record<string, number>;
|
|
5
|
+
export declare const ALL_SIZES: string[];
|
|
6
|
+
export declare const SKILL_ABILITY: Record<string, string>;
|
|
7
|
+
export declare const ALL_SKILLS: string[];
|
|
8
|
+
export declare const ABILITY_KEYS: readonly ["str", "dex", "con", "int", "wis", "cha"];
|
|
9
|
+
export declare const ABILITY_NAMES: Record<string, string>;
|
|
10
|
+
export declare const DAMAGE_TYPES: string[];
|
|
11
|
+
export declare const DAMAGE_NONMAGICAL_VARIANTS: string[];
|
|
12
|
+
export declare const CONDITIONS: string[];
|
|
13
|
+
export declare const STANDARD_SENSES: string[];
|
|
14
|
+
export declare const ALIGNMENT_ETHICAL: string[];
|
|
15
|
+
export declare const ALIGNMENT_MORAL: string[];
|
|
16
|
+
export declare const ALL_SECTIONS: string[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ABILITY_KEYS,
|
|
3
|
+
ABILITY_NAMES,
|
|
4
|
+
ALIGNMENT_ETHICAL,
|
|
5
|
+
ALIGNMENT_MORAL,
|
|
6
|
+
ALL_CR_VALUES,
|
|
7
|
+
ALL_SECTIONS,
|
|
8
|
+
ALL_SIZES,
|
|
9
|
+
ALL_SKILLS,
|
|
10
|
+
CONDITIONS,
|
|
11
|
+
CR_PROFICIENCY,
|
|
12
|
+
CR_XP,
|
|
13
|
+
DAMAGE_NONMAGICAL_VARIANTS,
|
|
14
|
+
DAMAGE_TYPES,
|
|
15
|
+
SIZE_HIT_DICE,
|
|
16
|
+
SKILL_ABILITY,
|
|
17
|
+
STANDARD_SENSES
|
|
18
|
+
} from "../chunk-WP2CX2JO.js";
|
|
19
|
+
export {
|
|
20
|
+
ABILITY_KEYS,
|
|
21
|
+
ABILITY_NAMES,
|
|
22
|
+
ALIGNMENT_ETHICAL,
|
|
23
|
+
ALIGNMENT_MORAL,
|
|
24
|
+
ALL_CR_VALUES,
|
|
25
|
+
ALL_SECTIONS,
|
|
26
|
+
ALL_SIZES,
|
|
27
|
+
ALL_SKILLS,
|
|
28
|
+
CONDITIONS,
|
|
29
|
+
CR_PROFICIENCY,
|
|
30
|
+
CR_XP,
|
|
31
|
+
DAMAGE_NONMAGICAL_VARIANTS,
|
|
32
|
+
DAMAGE_TYPES,
|
|
33
|
+
SIZE_HIT_DICE,
|
|
34
|
+
SKILL_ABILITY,
|
|
35
|
+
STANDARD_SENSES
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormulaRef } from "../inline-tag-parser.js";
|
|
2
|
+
import type { Abilities } from "../types/abilities.js";
|
|
3
|
+
import type { FormulaContext } from "../types/formula-context.js";
|
|
4
|
+
import { CanonicalTagType, normalizeTagType, parseTagTerms } from "./tag-grammar.js";
|
|
5
|
+
export type { CanonicalTagType, FormulaContext };
|
|
6
|
+
export { normalizeTagType, parseTagTerms };
|
|
7
|
+
export interface ResolvedTag {
|
|
8
|
+
display: string;
|
|
9
|
+
value?: number;
|
|
10
|
+
rollable: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveTag(tagType: string, content: string, ctx: FormulaContext): ResolvedTag;
|
|
13
|
+
/** @deprecated use parseTagTerms directly */
|
|
14
|
+
export declare function detectFormula(tagType: string, content: string): FormulaRef | null;
|
|
15
|
+
/** @deprecated use resolveTag */
|
|
16
|
+
export declare function resolveFormulaTag(tagType: string, content: string, abilities: Abilities, profBonus: number): string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTagType,
|
|
3
|
+
parseTagTerms
|
|
4
|
+
} from "../chunk-QYZV2MQA.js";
|
|
5
|
+
import {
|
|
6
|
+
abilityModifier,
|
|
7
|
+
formatModifier
|
|
8
|
+
} from "../chunk-NAEPSZAM.js";
|
|
9
|
+
import {
|
|
10
|
+
ABILITY_KEYS
|
|
11
|
+
} from "../chunk-WP2CX2JO.js";
|
|
12
|
+
|
|
13
|
+
// src/dnd/formula-tags.ts
|
|
14
|
+
function resolveSlugForTag(slug, tagType, registry) {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
if (!registry) return { value: 0, missing: true };
|
|
17
|
+
const found = registry.getBySlug(slug);
|
|
18
|
+
if (!found) return { value: 0, missing: true };
|
|
19
|
+
const data = found.data;
|
|
20
|
+
const b = data.bonuses;
|
|
21
|
+
switch (tagType) {
|
|
22
|
+
case "atk":
|
|
23
|
+
return { value: (_b = (_a = b == null ? void 0 : b.weapon_attack) != null ? _a : b == null ? void 0 : b.spell_attack) != null ? _b : 0, missing: false };
|
|
24
|
+
case "dmg":
|
|
25
|
+
return { value: (_c = b == null ? void 0 : b.weapon_damage) != null ? _c : 0, missing: false };
|
|
26
|
+
case "dc":
|
|
27
|
+
return { value: (_d = b == null ? void 0 : b.spell_save_dc) != null ? _d : 0, missing: false };
|
|
28
|
+
case "dice":
|
|
29
|
+
return { value: 0, missing: false };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function resolveTag(tagType, content, ctx) {
|
|
33
|
+
const canonical = normalizeTagType(tagType);
|
|
34
|
+
if (!canonical) return { display: content, rollable: false };
|
|
35
|
+
const parsed = parseTagTerms(content);
|
|
36
|
+
if ("error" in parsed) {
|
|
37
|
+
if (typeof console !== "undefined") {
|
|
38
|
+
console.warn(`tag parse error for ${canonical}:${content} \u2014 ${parsed.error}`);
|
|
39
|
+
}
|
|
40
|
+
return { display: content, rollable: false };
|
|
41
|
+
}
|
|
42
|
+
if (canonical === "dc" && parsed.pbTerm) {
|
|
43
|
+
if (typeof console !== "undefined") {
|
|
44
|
+
console.warn(`dc:${content} \u2014 explicit +PB is redundant; dc tags always include PB`);
|
|
45
|
+
}
|
|
46
|
+
return { display: content, rollable: false };
|
|
47
|
+
}
|
|
48
|
+
if (canonical === "dmg" && parsed.pbTerm) {
|
|
49
|
+
if (typeof console !== "undefined") {
|
|
50
|
+
console.warn(`dmg:${content} \u2014 PB not applicable to damage`);
|
|
51
|
+
}
|
|
52
|
+
return { display: content, rollable: false };
|
|
53
|
+
}
|
|
54
|
+
if (canonical === "dice" && (parsed.abilityTerm || parsed.pbTerm)) {
|
|
55
|
+
if (typeof console !== "undefined") {
|
|
56
|
+
console.warn(`dice:${content} \u2014 abilities/PB not allowed in dice tags`);
|
|
57
|
+
}
|
|
58
|
+
return { display: content, rollable: false };
|
|
59
|
+
}
|
|
60
|
+
const abilityMod = parsed.abilityTerm ? abilityModifier(ctx.abilities[parsed.abilityTerm]) : 0;
|
|
61
|
+
const literalSum = parsed.literalTerms.reduce((a, b) => a + b, 0);
|
|
62
|
+
let slugSum = 0;
|
|
63
|
+
let anySlugMissing = false;
|
|
64
|
+
for (const slug of parsed.slugTerms) {
|
|
65
|
+
const r = resolveSlugForTag(slug, canonical, ctx.compendium);
|
|
66
|
+
if (r.missing) anySlugMissing = true;
|
|
67
|
+
else slugSum += r.value;
|
|
68
|
+
}
|
|
69
|
+
switch (canonical) {
|
|
70
|
+
case "atk": {
|
|
71
|
+
const value = abilityMod + (parsed.pbTerm ? ctx.proficiencyBonus : 0) + literalSum + slugSum;
|
|
72
|
+
const display = anySlugMissing ? `${formatModifier(value)}?` : formatModifier(value);
|
|
73
|
+
return { display, value, rollable: true };
|
|
74
|
+
}
|
|
75
|
+
case "dc": {
|
|
76
|
+
if (!parsed.abilityTerm && parsed.literalTerms.length === 1 && parsed.literalTerms[0] >= 0 && parsed.slugTerms.length === 0) {
|
|
77
|
+
return { display: `DC ${parsed.literalTerms[0]}`, value: parsed.literalTerms[0], rollable: false };
|
|
78
|
+
}
|
|
79
|
+
const value = 8 + ctx.proficiencyBonus + abilityMod + literalSum + slugSum;
|
|
80
|
+
const display = anySlugMissing ? `DC ${value}?` : `DC ${value}`;
|
|
81
|
+
return { display, value, rollable: false };
|
|
82
|
+
}
|
|
83
|
+
case "dmg": {
|
|
84
|
+
const dicePart = parsed.diceTerms.map((d) => `${d.count}d${d.sides}`).join("+");
|
|
85
|
+
const modPart = abilityMod + literalSum + slugSum;
|
|
86
|
+
let display = dicePart;
|
|
87
|
+
if (modPart !== 0) display += modPart >= 0 ? `+${modPart}` : `${modPart}`;
|
|
88
|
+
if (display === "") display = String(modPart);
|
|
89
|
+
if (anySlugMissing) display += "?";
|
|
90
|
+
return { display, rollable: true };
|
|
91
|
+
}
|
|
92
|
+
case "dice": {
|
|
93
|
+
const dicePart = parsed.diceTerms.map((d) => `${d.count}d${d.sides}`).join("+");
|
|
94
|
+
return { display: dicePart || content, rollable: true };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
var ABILITY_PATTERN = /\b(str|dex|con|int|wis|cha)\b/i;
|
|
99
|
+
function detectFormula(tagType, content) {
|
|
100
|
+
const canonical = normalizeTagType(tagType);
|
|
101
|
+
if (!canonical || canonical === "dice") return null;
|
|
102
|
+
const match = content.match(ABILITY_PATTERN);
|
|
103
|
+
if (!match) return null;
|
|
104
|
+
const ability = match[1].toLowerCase();
|
|
105
|
+
if (!ABILITY_KEYS.includes(ability)) return null;
|
|
106
|
+
const kind = canonical === "atk" ? "attack" : canonical === "dc" ? "dc" : "damage";
|
|
107
|
+
return { ability, kind };
|
|
108
|
+
}
|
|
109
|
+
function resolveFormulaTag(tagType, content, abilities, profBonus) {
|
|
110
|
+
const r = resolveTag(tagType, content, { abilities, proficiencyBonus: profBonus });
|
|
111
|
+
return r.display;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
detectFormula,
|
|
115
|
+
normalizeTagType,
|
|
116
|
+
parseTagTerms,
|
|
117
|
+
resolveFormulaTag,
|
|
118
|
+
resolveTag
|
|
119
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ABILITY_KEYS } from "./constants.js";
|
|
2
|
+
export declare function abilityModifier(score: number): number;
|
|
3
|
+
export declare function formatModifier(mod: number): string;
|
|
4
|
+
export declare function proficiencyBonusFromCR(cr: string): number;
|
|
5
|
+
/** Proficiency bonus by total character level (1-20) */
|
|
6
|
+
export declare function proficiencyFromLevel(level: number): number;
|
|
7
|
+
export declare function crToXP(cr: string): number;
|
|
8
|
+
export declare function hitDiceSizeFromCreatureSize(size: string): number;
|
|
9
|
+
export declare function hpFromHitDice(hitDiceCount: number, hitDiceSize: number, conMod: number): number;
|
|
10
|
+
export declare function parseHitDiceFormula(formula: string): {
|
|
11
|
+
count: number;
|
|
12
|
+
size: number;
|
|
13
|
+
} | null;
|
|
14
|
+
export declare function savingThrow(abilityScore: number, isProficient: boolean, profBonus: number): number;
|
|
15
|
+
export declare function skillBonus(abilityScore: number, proficiency: "none" | "proficient" | "expertise", profBonus: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Passive score for any skill: 10 + skill bonus. Generalizes `passivePerception`.
|
|
18
|
+
* Use this for Passive Investigation (INT) and Passive Insight (WIS).
|
|
19
|
+
*/
|
|
20
|
+
export declare function passive(abilityScore: number, proficiency: "none" | "proficient" | "expertise", profBonus: number): number;
|
|
21
|
+
export declare function passivePerception(wisScore: number, perceptionProf: "none" | "proficient" | "expertise", profBonus: number): number;
|
|
22
|
+
export declare function attackBonus(abilityScore: number, profBonus: number): number;
|
|
23
|
+
export declare function saveDC(abilityScore: number, profBonus: number): number;
|
|
24
|
+
export declare function abilityNameToKey(name: string): (typeof ABILITY_KEYS)[number] | null;
|
package/dist/dnd/math.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
abilityModifier,
|
|
3
|
+
abilityNameToKey,
|
|
4
|
+
attackBonus,
|
|
5
|
+
crToXP,
|
|
6
|
+
formatModifier,
|
|
7
|
+
hitDiceSizeFromCreatureSize,
|
|
8
|
+
hpFromHitDice,
|
|
9
|
+
parseHitDiceFormula,
|
|
10
|
+
passive,
|
|
11
|
+
passivePerception,
|
|
12
|
+
proficiencyBonusFromCR,
|
|
13
|
+
proficiencyFromLevel,
|
|
14
|
+
saveDC,
|
|
15
|
+
savingThrow,
|
|
16
|
+
skillBonus
|
|
17
|
+
} from "../chunk-NAEPSZAM.js";
|
|
18
|
+
import "../chunk-WP2CX2JO.js";
|
|
19
|
+
export {
|
|
20
|
+
abilityModifier,
|
|
21
|
+
abilityNameToKey,
|
|
22
|
+
attackBonus,
|
|
23
|
+
crToXP,
|
|
24
|
+
formatModifier,
|
|
25
|
+
hitDiceSizeFromCreatureSize,
|
|
26
|
+
hpFromHitDice,
|
|
27
|
+
parseHitDiceFormula,
|
|
28
|
+
passive,
|
|
29
|
+
passivePerception,
|
|
30
|
+
proficiencyBonusFromCR,
|
|
31
|
+
proficiencyFromLevel,
|
|
32
|
+
saveDC,
|
|
33
|
+
savingThrow,
|
|
34
|
+
skillBonus
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert 5etools-style {@...} tags to the plugin's backtick inline-tag format.
|
|
3
|
+
* Called before backtick regex processing so AI-generated 5etools markup renders correctly.
|
|
4
|
+
*/
|
|
5
|
+
export declare function convert5eToolsTags(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Wrap bare dice notation (e.g. `1d6`, `2d6+3`, `37d8 + 259`) in synthetic
|
|
8
|
+
* `dice:…` backtick tags so the existing stat-block pill renderer picks them up.
|
|
9
|
+
*
|
|
10
|
+
* Skips dice notation that is already inside a backtick tag (the first
|
|
11
|
+
* alternation branch consumes backtick-delimited spans and returns them
|
|
12
|
+
* untouched) or embedded inside an identifier (word-character boundary).
|
|
13
|
+
*
|
|
14
|
+
* Pure. No state. No side effects.
|
|
15
|
+
*/
|
|
16
|
+
export declare function decorateProseDice(text: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/dnd/prose-tags.ts
|
|
2
|
+
function convert5eToolsTags(text) {
|
|
3
|
+
const rewritten = text.replace(/\{@atk\s+mw,rw\}/gi, "Melee or Ranged Weapon Attack:").replace(/\{@atk\s+mws\}/gi, "Melee or Ranged Weapon Attack:").replace(/\{@atk\s+msw\}/gi, "Melee or Ranged Spell Attack:").replace(/\{@atk\s+mw\}/gi, "Melee Weapon Attack:").replace(/\{@atk\s+rw\}/gi, "Ranged Weapon Attack:").replace(/\{@atk\s+ms\}/gi, "Melee Spell Attack:").replace(/\{@atk\s+rs\}/gi, "Ranged Spell Attack:").replace(/\{@hit\s+(\d+)\}/gi, "`atk:+$1`").replace(/\{@h\}/gi, "Hit:").replace(/\{@damage\s+([^}]+)\}/gi, "`damage:$1`").replace(/\{@dice\s+([^}]+)\}/gi, "`roll:$1`").replace(/\{@d20\s+([^}]+)\}/gi, "`roll:d20$1`").replace(/\{@dc\s+(\d+)\}/gi, "`dc:$1`").replace(/\{@recharge\s+(\d)\}/gi, "(Recharge $1-6)").replace(/\{@recharge\}/gi, "(Recharge)").replace(/\{@chance\s+(\d+)\}/gi, "$1% chance").replace(/\{@b(?:old)?\s+([^}]+)\}/gi, "**$1**").replace(/\{@i(?:talic)?\s+([^}]+)\}/gi, "_$1_").replace(/\{@s(?:trike)?\s+([^}]+)\}/gi, "~~$1~~").replace(/\{@note\s+([^}]+)\}/gi, "($1)").replace(/\{@spell\s+([^|}]+)[^}]*\}/gi, "_$1_").replace(/\{@item\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@creature\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@condition\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@skill\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@sense\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@action\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@status\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@ability\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@class\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@feat\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@background\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@race\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@disease\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@hazard\s+([^|}]+)[^}]*\}/gi, "**$1**").replace(/\{@plane\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@language\s+([^|}]+)[^}]*\}/gi, "$1").replace(/\{@book\s+([^|}]+)[^}]*\}/gi, "_$1_").replace(/\{@adventure\s+([^|}]+)[^}]*\}/gi, "_$1_").replace(/\{@\w+\s+([^}]+)\}/g, "$1");
|
|
4
|
+
return decorateProseDice(rewritten);
|
|
5
|
+
}
|
|
6
|
+
function decorateProseDice(text) {
|
|
7
|
+
return text.replace(
|
|
8
|
+
/`[^`]*`|(?<!\w)(\d+d\d+(?:\s*[+-]\s*\d+)?)(?!\w)/g,
|
|
9
|
+
(match, dice) => {
|
|
10
|
+
if (dice) return `\`dice:${dice.replace(/\s+/g, "")}\``;
|
|
11
|
+
return match;
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
convert5eToolsTags,
|
|
17
|
+
decorateProseDice
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResourceDie } from "../types/resource.js";
|
|
2
|
+
/** The die face in effect at `level`: the value of the highest `scaling` key
|
|
3
|
+
* ≤ level, else `die.base`. Keys are level thresholds as strings (JSON/YAML
|
|
4
|
+
* object keys are strings). Extracted from the resource badge so feature-attack
|
|
5
|
+
* damage can scale identically. Non-numeric scaling keys coerce to NaN and are skipped. */
|
|
6
|
+
export declare function resolveScalingDie(die: ResourceDie, level: number): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/dnd/resource-die.ts
|
|
2
|
+
function resolveScalingDie(die, level) {
|
|
3
|
+
var _a;
|
|
4
|
+
let face = die.base;
|
|
5
|
+
let best = 0;
|
|
6
|
+
for (const [lvl, f] of Object.entries((_a = die.scaling) != null ? _a : {})) {
|
|
7
|
+
const n = Number(lvl);
|
|
8
|
+
if (n <= level && n > best) {
|
|
9
|
+
best = n;
|
|
10
|
+
face = f;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return face;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
resolveScalingDie
|
|
17
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny DSL for Resource.max_formula and Resource.recovery[].amount (SP4d). Grammar:
|
|
3
|
+
* expr := term (('+' | '-') term)*
|
|
4
|
+
* term := factor (('*' | '/') factor)*
|
|
5
|
+
* factor := number | string-arg-only | ident | '{' ident '}' | fn '(' expr ')'
|
|
6
|
+
* | "column" '(' string ')' | '(' expr ')'
|
|
7
|
+
* fn := 'ceil' | 'floor'
|
|
8
|
+
* ident := level | class_level | prof | <abil>_mod
|
|
9
|
+
* The single-quoted string literal (e.g. 'Seals') is valid ONLY as the
|
|
10
|
+
* argument to column(...).
|
|
11
|
+
* '*' and '/' bind tighter than '+'/'-'. '/' is real division; wrap in
|
|
12
|
+
* ceil()/floor() for integer results (e.g. "ceil({class_level}/2)").
|
|
13
|
+
* `999` is the at-will sentinel; it evaluates as the literal 999.
|
|
14
|
+
*/
|
|
15
|
+
export interface FormulaBindings {
|
|
16
|
+
level: number;
|
|
17
|
+
class_level: number;
|
|
18
|
+
prof: number;
|
|
19
|
+
str_mod: number;
|
|
20
|
+
dex_mod: number;
|
|
21
|
+
con_mod: number;
|
|
22
|
+
int_mod: number;
|
|
23
|
+
wis_mod: number;
|
|
24
|
+
cha_mod: number;
|
|
25
|
+
/** Numeric values of the owning (sub)class table row at the current class
|
|
26
|
+
* level, keyed by column name (e.g. "Seals"). Empty when no table/row.
|
|
27
|
+
* Read by the `column('Name')` accessor; missing name → 0. */
|
|
28
|
+
columns: Record<string, number>;
|
|
29
|
+
}
|
|
30
|
+
export declare function isValidMaxFormula(formula: string): boolean;
|
|
31
|
+
export declare function evaluateMaxFormula(formula: string, bindings: FormulaBindings): number;
|
|
32
|
+
export interface ScalableResource {
|
|
33
|
+
max_formula: string;
|
|
34
|
+
scales_at?: {
|
|
35
|
+
level: number;
|
|
36
|
+
max: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
/** The max-formula string in effect at `totalLevel`: the highest `scales_at`
|
|
40
|
+
* step whose level ≤ totalLevel, else the base `max_formula`. */
|
|
41
|
+
export declare function resolveMaxAt(totalLevel: number, resource: ScalableResource): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// src/dnd/resource-formula.ts
|
|
2
|
+
var IDENTS = /* @__PURE__ */ new Set([
|
|
3
|
+
"level",
|
|
4
|
+
"class_level",
|
|
5
|
+
"prof",
|
|
6
|
+
"str_mod",
|
|
7
|
+
"dex_mod",
|
|
8
|
+
"con_mod",
|
|
9
|
+
"int_mod",
|
|
10
|
+
"wis_mod",
|
|
11
|
+
"cha_mod"
|
|
12
|
+
]);
|
|
13
|
+
var FUNCS = /* @__PURE__ */ new Set(["ceil", "floor"]);
|
|
14
|
+
function tokenize(input) {
|
|
15
|
+
input = input.trim();
|
|
16
|
+
const tokens = [];
|
|
17
|
+
const re = /\s*('[^']*'|\{[a-z_]+\}|[a-z_]+|\d+|[+\-*/()])/y;
|
|
18
|
+
let i = 0;
|
|
19
|
+
while (i < input.length) {
|
|
20
|
+
re.lastIndex = i;
|
|
21
|
+
const m = re.exec(input);
|
|
22
|
+
if (!m || m.index !== i) return null;
|
|
23
|
+
const raw = m[1];
|
|
24
|
+
i = re.lastIndex;
|
|
25
|
+
if (/^\d+$/.test(raw)) tokens.push({ kind: "num", value: parseInt(raw, 10) });
|
|
26
|
+
else if (raw.startsWith("'")) tokens.push({ kind: "str", value: raw.slice(1, -1) });
|
|
27
|
+
else if (raw === "(") tokens.push({ kind: "lparen" });
|
|
28
|
+
else if (raw === ")") tokens.push({ kind: "rparen" });
|
|
29
|
+
else if (raw === "+" || raw === "-" || raw === "*" || raw === "/") tokens.push({ kind: "op", op: raw });
|
|
30
|
+
else {
|
|
31
|
+
const braced = raw.startsWith("{");
|
|
32
|
+
const name = braced ? raw.slice(1, -1) : raw;
|
|
33
|
+
if (!braced && FUNCS.has(name)) tokens.push({ kind: "fn", name });
|
|
34
|
+
else if (!braced && name === "column") tokens.push({ kind: "col" });
|
|
35
|
+
else if (IDENTS.has(name)) tokens.push({ kind: "id", name });
|
|
36
|
+
else return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return tokens.length > 0 ? tokens : null;
|
|
40
|
+
}
|
|
41
|
+
function evalTokens(tokens, b) {
|
|
42
|
+
let pos = 0;
|
|
43
|
+
const peek = () => tokens[pos];
|
|
44
|
+
const factor = () => {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
46
|
+
const t = peek();
|
|
47
|
+
if (!t) return null;
|
|
48
|
+
if (t.kind === "num") {
|
|
49
|
+
pos++;
|
|
50
|
+
return t.value;
|
|
51
|
+
}
|
|
52
|
+
if (t.kind === "id") {
|
|
53
|
+
const val = b[t.name];
|
|
54
|
+
if (val === void 0) return null;
|
|
55
|
+
pos++;
|
|
56
|
+
return val;
|
|
57
|
+
}
|
|
58
|
+
if (t.kind === "fn") {
|
|
59
|
+
pos++;
|
|
60
|
+
if (((_a = peek()) == null ? void 0 : _a.kind) !== "lparen") return null;
|
|
61
|
+
pos++;
|
|
62
|
+
const inner = expr();
|
|
63
|
+
if (inner === null) return null;
|
|
64
|
+
if (((_b = peek()) == null ? void 0 : _b.kind) !== "rparen") return null;
|
|
65
|
+
pos++;
|
|
66
|
+
return t.name === "ceil" ? Math.ceil(inner) : Math.floor(inner);
|
|
67
|
+
}
|
|
68
|
+
if (t.kind === "col") {
|
|
69
|
+
pos++;
|
|
70
|
+
if (((_c = peek()) == null ? void 0 : _c.kind) !== "lparen") return null;
|
|
71
|
+
pos++;
|
|
72
|
+
const s = peek();
|
|
73
|
+
if (!s || s.kind !== "str") return null;
|
|
74
|
+
pos++;
|
|
75
|
+
if (((_d = peek()) == null ? void 0 : _d.kind) !== "rparen") return null;
|
|
76
|
+
pos++;
|
|
77
|
+
return (_f = (_e = b.columns) == null ? void 0 : _e[s.value]) != null ? _f : 0;
|
|
78
|
+
}
|
|
79
|
+
if (t.kind === "lparen") {
|
|
80
|
+
pos++;
|
|
81
|
+
const inner = expr();
|
|
82
|
+
if (inner === null) return null;
|
|
83
|
+
if (((_g = peek()) == null ? void 0 : _g.kind) !== "rparen") return null;
|
|
84
|
+
pos++;
|
|
85
|
+
return inner;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
};
|
|
89
|
+
const term = () => {
|
|
90
|
+
var _a;
|
|
91
|
+
let v = factor();
|
|
92
|
+
if (v === null) return null;
|
|
93
|
+
while (((_a = peek()) == null ? void 0 : _a.kind) === "op" && (peek().op === "*" || peek().op === "/")) {
|
|
94
|
+
const op = peek().op;
|
|
95
|
+
pos++;
|
|
96
|
+
const r = factor();
|
|
97
|
+
if (r === null) return null;
|
|
98
|
+
v = op === "*" ? v * r : v / r;
|
|
99
|
+
}
|
|
100
|
+
return v;
|
|
101
|
+
};
|
|
102
|
+
const expr = () => {
|
|
103
|
+
var _a;
|
|
104
|
+
let v = term();
|
|
105
|
+
if (v === null) return null;
|
|
106
|
+
while (((_a = peek()) == null ? void 0 : _a.kind) === "op" && (peek().op === "+" || peek().op === "-")) {
|
|
107
|
+
const op = peek().op;
|
|
108
|
+
pos++;
|
|
109
|
+
const r = term();
|
|
110
|
+
if (r === null) return null;
|
|
111
|
+
v = op === "+" ? v + r : v - r;
|
|
112
|
+
}
|
|
113
|
+
return v;
|
|
114
|
+
};
|
|
115
|
+
const result = expr();
|
|
116
|
+
if (result === null || pos !== tokens.length) return null;
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
var ZERO = {
|
|
120
|
+
level: 1,
|
|
121
|
+
class_level: 1,
|
|
122
|
+
prof: 2,
|
|
123
|
+
str_mod: 0,
|
|
124
|
+
dex_mod: 0,
|
|
125
|
+
con_mod: 0,
|
|
126
|
+
int_mod: 0,
|
|
127
|
+
wis_mod: 0,
|
|
128
|
+
cha_mod: 0,
|
|
129
|
+
columns: {}
|
|
130
|
+
};
|
|
131
|
+
function isValidMaxFormula(formula) {
|
|
132
|
+
const toks = tokenize(formula);
|
|
133
|
+
if (!toks) return false;
|
|
134
|
+
return evalTokens(toks, ZERO) !== null;
|
|
135
|
+
}
|
|
136
|
+
function evaluateMaxFormula(formula, bindings) {
|
|
137
|
+
const toks = tokenize(formula);
|
|
138
|
+
if (!toks) throw new Error(`invalid max_formula: ${JSON.stringify(formula)}`);
|
|
139
|
+
const v = evalTokens(toks, bindings);
|
|
140
|
+
if (v === null) throw new Error(`invalid max_formula: ${JSON.stringify(formula)}`);
|
|
141
|
+
return v;
|
|
142
|
+
}
|
|
143
|
+
function resolveMaxAt(totalLevel, resource) {
|
|
144
|
+
var _a;
|
|
145
|
+
let chosen = resource.max_formula;
|
|
146
|
+
let best = 0;
|
|
147
|
+
for (const step of (_a = resource.scales_at) != null ? _a : []) {
|
|
148
|
+
if (step.level <= totalLevel && step.level > best) {
|
|
149
|
+
best = step.level;
|
|
150
|
+
chosen = step.max;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return chosen;
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
evaluateMaxFormula,
|
|
157
|
+
isValidMaxFormula,
|
|
158
|
+
resolveMaxAt
|
|
159
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type AbilityKey = "str" | "dex" | "con" | "int" | "wis" | "cha";
|
|
2
|
+
export interface ConverterAbilities {
|
|
3
|
+
str: number;
|
|
4
|
+
dex: number;
|
|
5
|
+
con: number;
|
|
6
|
+
int: number;
|
|
7
|
+
wis: number;
|
|
8
|
+
cha: number;
|
|
9
|
+
}
|
|
10
|
+
export type ActionCategory = "action" | "trait" | "reaction" | "legendary" | "bonus" | "special";
|
|
11
|
+
export interface ConversionContext {
|
|
12
|
+
abilities: ConverterAbilities;
|
|
13
|
+
profBonus: number;
|
|
14
|
+
actionName: string;
|
|
15
|
+
actionCategory: ActionCategory;
|
|
16
|
+
spellAbility?: "int" | "wis" | "cha";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Shared static-fallback context for callers that enrich creature-agnostic
|
|
20
|
+
* content (spells, magic items) where no real ability mods / prof bonus exist.
|
|
21
|
+
*
|
|
22
|
+
* All ability mods = 0 and prof = 0, so no computed target matches any
|
|
23
|
+
* reasonable value and every pattern falls to the static fallback path
|
|
24
|
+
* (e.g. `dc:15`, `atk:+7`).
|
|
25
|
+
*/
|
|
26
|
+
export declare const STATIC_FALLBACK_CONTEXT: ConversionContext;
|
|
27
|
+
/**
|
|
28
|
+
* Convert SRD plain-English descriptions (e.g. "Melee Weapon Attack: +14 to hit,
|
|
29
|
+
* Hit: 21 (3d8 + 8) slashing damage") into backtick formula tags
|
|
30
|
+
* (e.g. "Melee Weapon Attack: `atk:STR+PB`, Hit: `dmg:3d8+STR` slashing damage")
|
|
31
|
+
* by reverse-inferring which ability mod + prof produced the static value.
|
|
32
|
+
*
|
|
33
|
+
* Pure. Deterministic. Never throws: wraps everything in try/catch and returns
|
|
34
|
+
* the original desc on any failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare function convertDescToTags(desc: string, ctx: ConversionContext): string;
|
|
37
|
+
/**
|
|
38
|
+
* Scan a monster's trait list for a spellcasting ability declaration like
|
|
39
|
+
* "Its spellcasting ability is Wisdom". Returns undefined for non-casters.
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectSpellcastingAbility(traits: {
|
|
42
|
+
name: string;
|
|
43
|
+
entries: string[];
|
|
44
|
+
}[] | undefined): "int" | "wis" | "cha" | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
STATIC_FALLBACK_CONTEXT,
|
|
3
|
+
convertDescToTags,
|
|
4
|
+
detectSpellcastingAbility
|
|
5
|
+
} from "../chunk-RAWJTA45.js";
|
|
6
|
+
import "../chunk-NAEPSZAM.js";
|
|
7
|
+
import "../chunk-WP2CX2JO.js";
|
|
8
|
+
export {
|
|
9
|
+
STATIC_FALLBACK_CONTEXT,
|
|
10
|
+
convertDescToTags,
|
|
11
|
+
detectSpellcastingAbility
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ability } from "../types/choice.js";
|
|
2
|
+
import { ABILITY_KEYS } from "./constants.js";
|
|
3
|
+
export type { Ability };
|
|
4
|
+
export { ABILITY_KEYS as ABILITIES };
|
|
5
|
+
export type CanonicalTagType = "atk" | "dmg" | "dc" | "dice";
|
|
6
|
+
export interface ParsedTerms {
|
|
7
|
+
abilityTerm?: Ability;
|
|
8
|
+
pbTerm: boolean;
|
|
9
|
+
literalTerms: number[];
|
|
10
|
+
diceTerms: {
|
|
11
|
+
count: number;
|
|
12
|
+
sides: number;
|
|
13
|
+
}[];
|
|
14
|
+
slugTerms: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function normalizeTagType(input: string): CanonicalTagType | null;
|
|
17
|
+
export declare function parseTagTerms(content: string): ParsedTerms | {
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const encounterInputSchema: z.ZodObject<{
|
|
3
|
+
party_size: z.ZodNumber;
|
|
4
|
+
party_level: z.ZodNumber;
|
|
5
|
+
difficulty: z.ZodEnum<{
|
|
6
|
+
medium: "medium";
|
|
7
|
+
easy: "easy";
|
|
8
|
+
hard: "hard";
|
|
9
|
+
deadly: "deadly";
|
|
10
|
+
}>;
|
|
11
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
12
|
+
theme: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const encounterOutputSchema: z.ZodObject<{
|
|
15
|
+
monsters: z.ZodArray<z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
cr: z.ZodString;
|
|
18
|
+
count: z.ZodNumber;
|
|
19
|
+
role: z.ZodString;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
tactics: z.ZodString;
|
|
22
|
+
terrain: z.ZodString;
|
|
23
|
+
notes: z.ZodString;
|
|
24
|
+
xp_budget: z.ZodObject<{
|
|
25
|
+
target: z.ZodNumber;
|
|
26
|
+
actual: z.ZodNumber;
|
|
27
|
+
difficulty_rating: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
}, z.core.$strip>;
|