@archivist-gg/dnd5e 0.3.0 → 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.
Files changed (260) hide show
  1. package/LICENSES/SRD.md +25 -6
  2. package/dist/armor/armor.codec.js +4 -3
  3. package/dist/armor/armor.parser.js +3 -2
  4. package/dist/armor/armor.schema.d.ts +4 -0
  5. package/dist/armor/armor.schema.js +2 -1
  6. package/dist/armor/armor.types.d.ts +8 -0
  7. package/dist/background/background.codec.js +7 -6
  8. package/dist/background/background.parser.js +6 -5
  9. package/dist/background/background.schema.d.ts +34 -0
  10. package/dist/background/background.schema.js +9 -6
  11. package/dist/background/background.types.d.ts +22 -0
  12. package/dist/{chunk-4TIJKN6O.js → chunk-23LZLBJK.js} +1 -1
  13. package/dist/{chunk-AFKTJXRA.js → chunk-2DFENQIJ.js} +18 -0
  14. package/dist/chunk-2FRUSVZS.js +489 -0
  15. package/dist/chunk-4FWNK4FD.js +159 -0
  16. package/dist/chunk-4U55VNC7.js +22 -0
  17. package/dist/{chunk-4JHOHWBI.js → chunk-4XTNPNQB.js} +1 -1
  18. package/dist/{chunk-HCP3GMHS.js → chunk-5N2GW72F.js} +15 -2
  19. package/dist/{chunk-42Y5IJKT.js → chunk-5U5FFFA3.js} +5 -1
  20. package/dist/{chunk-4F6AIZ36.js → chunk-5XMQPTHD.js} +1 -1
  21. package/dist/{chunk-GJOI2GHP.js → chunk-6GNXYAYP.js} +1 -1
  22. package/dist/chunk-6PKV5V2H.js +178 -0
  23. package/dist/{chunk-66XXW2Z2.js → chunk-6PXTNCBP.js} +2 -2
  24. package/dist/chunk-6X2NV665.js +33 -0
  25. package/dist/{chunk-LV4SNWZQ.js → chunk-6X4KUDMU.js} +8 -1
  26. package/dist/{chunk-ZMR77DDL.js → chunk-AW3EHF3L.js} +1 -1
  27. package/dist/chunk-CJYCVNW2.js +7 -0
  28. package/dist/chunk-COEOOQX2.js +133 -0
  29. package/dist/{chunk-XTIQWSFM.js → chunk-D5U7GMPX.js} +1 -1
  30. package/dist/{chunk-RAWJTA45.js → chunk-DEEHHLAP.js} +1 -1
  31. package/dist/chunk-DPUJDOKV.js +365 -0
  32. package/dist/{chunk-73HOFQQ5.js → chunk-ESS46GR4.js} +1 -1
  33. package/dist/chunk-EVMUJYUD.js +195 -0
  34. package/dist/{chunk-2BWAID3Y.js → chunk-FDBWYMZK.js} +29 -3
  35. package/dist/{chunk-K6Q5OUGK.js → chunk-GFZ7PITJ.js} +86 -10
  36. package/dist/chunk-H7KBLR4X.js +81 -0
  37. package/dist/{chunk-L7E2UT5A.js → chunk-HB7XZXDK.js} +5 -1
  38. package/dist/{chunk-VTYUBINW.js → chunk-HJ5EEZ47.js} +1 -1
  39. package/dist/{chunk-6NK2MUD3.js → chunk-HZA7OE7N.js} +9 -2
  40. package/dist/{chunk-A4WENOUQ.js → chunk-I2NDWFDD.js} +52 -8
  41. package/dist/{chunk-RSDRMH54.js → chunk-IMZFOOVL.js} +1 -1
  42. package/dist/{chunk-3DZ74AKK.js → chunk-IN4M4X7P.js} +8 -2
  43. package/dist/chunk-IUAAXXNO.js +58 -0
  44. package/dist/{chunk-XJNECUPT.js → chunk-JC5UNIVM.js} +19 -0
  45. package/dist/chunk-JJ46T5XX.js +297 -0
  46. package/dist/{chunk-TUIFSVLI.js → chunk-JRDPUDT5.js} +30 -3
  47. package/dist/{chunk-24GFQU7T.js → chunk-JSZ4H6AQ.js} +1 -1
  48. package/dist/chunk-KU3YLF6D.js +106 -0
  49. package/dist/{chunk-5INR4NSL.js → chunk-LDDCNPHD.js} +1 -1
  50. package/dist/{chunk-DZXSWSBP.js → chunk-LMBAEIP6.js} +1 -1
  51. package/dist/chunk-LVQLWRCU.js +15 -0
  52. package/dist/chunk-MI7P3NX3.js +161 -0
  53. package/dist/chunk-O4SRD3J5.js +165 -0
  54. package/dist/{chunk-EMOORSQ7.js → chunk-OSQFPGLM.js} +45 -6
  55. package/dist/chunk-OZP6JFGT.js +162 -0
  56. package/dist/{chunk-NAEPSZAM.js → chunk-PDJSUH24.js} +24 -2
  57. package/dist/chunk-PP2UHLBA.js +50 -0
  58. package/dist/chunk-PVCEA4HZ.js +6 -0
  59. package/dist/{chunk-XLSVNUTK.js → chunk-R3VAKWKW.js} +1 -1
  60. package/dist/chunk-RIXI5D3R.js +89 -0
  61. package/dist/chunk-RLGQ5PZZ.js +16 -0
  62. package/dist/chunk-S7REMWW4.js +21 -0
  63. package/dist/{chunk-7VJ6BOA5.js → chunk-SMLXZUBH.js} +9 -1
  64. package/dist/{chunk-NXSWH3AE.js → chunk-T26ZVCL5.js} +1 -1
  65. package/dist/chunk-TOM66P2P.js +38 -0
  66. package/dist/chunk-UA5KS2PL.js +26 -0
  67. package/dist/{chunk-N6N74K6X.js → chunk-UBBKSYBY.js} +1 -1
  68. package/dist/{chunk-353WXS6S.js → chunk-UIRMA5KM.js} +1 -1
  69. package/dist/{chunk-GE4TLPWM.js → chunk-US5IKYCW.js} +1 -1
  70. package/dist/chunk-UXPGW4TI.js +101 -0
  71. package/dist/chunk-VQAXTIBW.js +100 -0
  72. package/dist/{chunk-WP2CX2JO.js → chunk-WELIKLZF.js} +22 -1
  73. package/dist/chunk-WPWOHGPI.js +172 -0
  74. package/dist/{chunk-GZ46OVGZ.js → chunk-WSVMLNTO.js} +1 -1
  75. package/dist/{chunk-4LZJXJJS.js → chunk-WXWPK3LI.js} +6 -2
  76. package/dist/{chunk-ZZGEVJKX.js → chunk-XBQMCEI2.js} +1 -1
  77. package/dist/{chunk-PHQRGDRQ.js → chunk-XGOFP7AQ.js} +5 -1
  78. package/dist/chunk-XJ2F2WO6.js +8 -0
  79. package/dist/chunk-XQCSGNXE.js +1580 -0
  80. package/dist/chunk-YBLDE5CG.js +42 -0
  81. package/dist/{chunk-JEYQU3JT.js → chunk-YHYTW5QA.js} +2 -18
  82. package/dist/{chunk-TLYDBT5F.js → chunk-YJJTISBN.js} +64 -7
  83. package/dist/{chunk-PZOWBI3B.js → chunk-YLL2QXY2.js} +7 -2
  84. package/dist/{chunk-MDEJHMKK.js → chunk-ZONJ66NE.js} +26 -5
  85. package/dist/class/class.codec.js +12 -9
  86. package/dist/class/class.parser.js +11 -8
  87. package/dist/class/class.schema.d.ts +55 -3
  88. package/dist/class/class.schema.js +9 -7
  89. package/dist/class/class.types.d.ts +48 -3
  90. package/dist/condition/condition.codec.d.ts +9 -0
  91. package/dist/condition/condition.entity-type.d.ts +2 -0
  92. package/dist/condition/condition.parser.d.ts +13 -0
  93. package/dist/condition/condition.parser.js +7 -0
  94. package/dist/condition/condition.schema.d.ts +29 -0
  95. package/dist/condition/condition.types.d.ts +15 -0
  96. package/dist/condition/condition.types.js +0 -0
  97. package/dist/dnd/constants.d.ts +22 -0
  98. package/dist/dnd/constants.js +9 -3
  99. package/dist/dnd/formula-tags.js +2 -2
  100. package/dist/dnd/math.d.ts +26 -0
  101. package/dist/dnd/math.js +12 -2
  102. package/dist/dnd/prose-tags.js +1 -1
  103. package/dist/dnd/resource-formula.d.ts +36 -10
  104. package/dist/dnd/resource-formula.js +10 -155
  105. package/dist/dnd/srd-tag-converter.js +3 -3
  106. package/dist/dnd/tag-grammar.js +1 -1
  107. package/dist/dnd/warn-once.d.ts +2 -0
  108. package/dist/dnd/warn-once.js +8 -0
  109. package/dist/entities/base-item-resolver.js +2 -2
  110. package/dist/entities/slug.d.ts +13 -0
  111. package/dist/entities/slug.js +5 -3
  112. package/dist/entities/wikilink-display.d.ts +3 -0
  113. package/dist/entities/wikilink-display.js +10 -0
  114. package/dist/feat/feat.category-codes.d.ts +32 -0
  115. package/dist/feat/feat.category-codes.js +14 -0
  116. package/dist/feat/feat.codec.js +7 -5
  117. package/dist/feat/feat.parser.js +6 -4
  118. package/dist/feat/feat.schema.d.ts +230 -0
  119. package/dist/feat/feat.schema.js +5 -3
  120. package/dist/feat/feat.types.d.ts +37 -1
  121. package/dist/index.js +2120 -6923
  122. package/dist/item/item.ai-schema.d.ts +1 -1
  123. package/dist/item/item.codec.js +4 -3
  124. package/dist/item/item.enrichment.js +4 -4
  125. package/dist/item/item.parser.js +3 -2
  126. package/dist/item/item.schema.d.ts +69 -3
  127. package/dist/item/item.schema.js +2 -1
  128. package/dist/item/item.types.d.ts +69 -3
  129. package/dist/monster/monster.codec.d.ts +7 -6
  130. package/dist/monster/monster.enrichment.js +4 -4
  131. package/dist/monster/monster.format.d.ts +135 -0
  132. package/dist/monster/monster.format.js +78 -0
  133. package/dist/monster/monster.parser.d.ts +6 -1
  134. package/dist/monster/monster.parser.js +10 -1
  135. package/dist/monster/monster.schema.d.ts +369 -0
  136. package/dist/monster/monster.schema.js +34 -0
  137. package/dist/monster/monster.types.d.ts +200 -14
  138. package/dist/optional-feature/optional-feature.codec.js +6 -5
  139. package/dist/optional-feature/optional-feature.parser.js +5 -4
  140. package/dist/optional-feature/optional-feature.schema.d.ts +176 -0
  141. package/dist/optional-feature/optional-feature.schema.js +4 -3
  142. package/dist/pack.d.ts +1 -1
  143. package/dist/pc/conditions.constants.d.ts +0 -1
  144. package/dist/pc/conditions.constants.js +1 -3
  145. package/dist/pc/decision-recognizer.js +1 -1
  146. package/dist/pc/pc.additional-spells.d.ts +47 -0
  147. package/dist/pc/pc.additional-spells.js +23 -0
  148. package/dist/pc/pc.asi-flatten.d.ts +18 -0
  149. package/dist/pc/pc.decision-engine.d.ts +106 -5
  150. package/dist/pc/pc.decision-engine.js +28 -10
  151. package/dist/pc/pc.defense-normalize.d.ts +11 -0
  152. package/dist/pc/pc.defense-normalize.js +6 -0
  153. package/dist/pc/pc.equipment.d.ts +30 -1
  154. package/dist/pc/pc.equipment.js +12 -7
  155. package/dist/pc/pc.feature-effects.d.ts +225 -11
  156. package/dist/pc/pc.feature-effects.js +21 -5
  157. package/dist/pc/pc.parser.js +2 -2
  158. package/dist/pc/pc.pools.d.ts +11 -3
  159. package/dist/pc/pc.pools.js +9 -13
  160. package/dist/pc/pc.proficiencies.d.ts +60 -4
  161. package/dist/pc/pc.proficiencies.js +89 -37
  162. package/dist/pc/pc.proficiency-grants.d.ts +58 -0
  163. package/dist/pc/pc.proficiency-normalize.d.ts +29 -0
  164. package/dist/pc/pc.proficiency-normalize.js +12 -0
  165. package/dist/pc/pc.proficiency-query.d.ts +13 -0
  166. package/dist/pc/pc.proficiency-query.js +5 -1
  167. package/dist/pc/pc.recalc.d.ts +69 -14
  168. package/dist/pc/pc.recalc.js +291 -142
  169. package/dist/pc/pc.resolver.d.ts +34 -8
  170. package/dist/pc/pc.resolver.js +27 -12
  171. package/dist/pc/pc.resource-seed.d.ts +3 -2
  172. package/dist/pc/pc.resource-seed.js +19 -17
  173. package/dist/pc/pc.resources.d.ts +87 -0
  174. package/dist/pc/pc.resources.js +21 -0
  175. package/dist/pc/pc.rest.d.ts +10 -1
  176. package/dist/pc/pc.rest.js +66 -12
  177. package/dist/pc/pc.schema.d.ts +147 -7
  178. package/dist/pc/pc.schema.js +4 -2
  179. package/dist/pc/pc.slotting.js +3 -3
  180. package/dist/pc/pc.spellcasting.d.ts +80 -7
  181. package/dist/pc/pc.spellcasting.js +18 -6
  182. package/dist/pc/pc.table-column.d.ts +23 -0
  183. package/dist/pc/pc.table-column.js +13 -3
  184. package/dist/pc/pc.types.d.ts +253 -16
  185. package/dist/pc/pool-layout.d.ts +47 -0
  186. package/dist/pc/pool-layout.js +16 -0
  187. package/dist/pc/roll-scope.d.ts +2 -0
  188. package/dist/pc/roll-scope.js +8 -0
  189. package/dist/pc/roll-tag-labels.d.ts +40 -0
  190. package/dist/pc/roll-tag-labels.js +17 -0
  191. package/dist/pc/spell-source.d.ts +21 -0
  192. package/dist/pc/spell-source.js +13 -0
  193. package/dist/race/race.codec.js +9 -7
  194. package/dist/race/race.parser.js +8 -6
  195. package/dist/race/race.schema.d.ts +51 -1
  196. package/dist/race/race.schema.js +8 -5
  197. package/dist/race/race.structural.d.ts +7 -0
  198. package/dist/race/race.structural.js +6 -0
  199. package/dist/race/race.types.d.ts +20 -0
  200. package/dist/schemas/attack-schema.d.ts +5 -0
  201. package/dist/schemas/caster-type-schema.d.ts +14 -0
  202. package/dist/schemas/caster-type-schema.js +6 -0
  203. package/dist/schemas/choice-schema.js +2 -2
  204. package/dist/schemas/entity-extras-schema.d.ts +53 -0
  205. package/dist/schemas/entity-extras-schema.js +10 -0
  206. package/dist/schemas/equipment-grant-schema.d.ts +2 -0
  207. package/dist/schemas/equipment-grant-schema.js +1 -1
  208. package/dist/schemas/feature-alias.d.ts +34 -0
  209. package/dist/schemas/feature-effect-schema.d.ts +124 -0
  210. package/dist/schemas/feature-effect-schema.js +1 -1
  211. package/dist/schemas/feature-schema.d.ts +8 -0
  212. package/dist/schemas/feature-schema.js +6 -4
  213. package/dist/schemas/resource-schema.d.ts +43 -0
  214. package/dist/schemas/resource-schema.js +1 -1
  215. package/dist/schemas/selection-pool-schema.d.ts +2 -0
  216. package/dist/schemas/selection-pool-schema.js +1 -1
  217. package/dist/spell/spell.access.js +23 -3
  218. package/dist/spell/spell.codec.js +4 -3
  219. package/dist/spell/spell.enrichment.js +4 -4
  220. package/dist/spell/spell.parser.d.ts +30 -0
  221. package/dist/spell/spell.parser.js +9 -2
  222. package/dist/spell/spell.scaling.d.ts +27 -6
  223. package/dist/spell/spell.scaling.js +25 -6
  224. package/dist/spell/spell.schema.d.ts +44 -2
  225. package/dist/spell/spell.schema.js +2 -1
  226. package/dist/spell/spell.types.d.ts +14 -0
  227. package/dist/subclass/subclass.codec.d.ts +1 -1
  228. package/dist/subclass/subclass.codec.js +11 -8
  229. package/dist/subclass/subclass.parser.js +10 -7
  230. package/dist/subclass/subclass.schema.d.ts +54 -7
  231. package/dist/subclass/subclass.schema.js +8 -6
  232. package/dist/subclass/subclass.types.d.ts +20 -2
  233. package/dist/types/choice.d.ts +56 -0
  234. package/dist/types/choice.js +21 -3
  235. package/dist/types/equipment-grant.d.ts +8 -1
  236. package/dist/types/feature-effect.d.ts +78 -23
  237. package/dist/types/feature.d.ts +70 -1
  238. package/dist/types/optional-feature.types.d.ts +28 -0
  239. package/dist/types/resource.d.ts +21 -1
  240. package/dist/types/selection-pool.d.ts +17 -2
  241. package/dist/weapon/weapon.classify.js +2 -2
  242. package/dist/weapon/weapon.codec.js +4 -3
  243. package/dist/weapon/weapon.parser.js +3 -2
  244. package/dist/weapon/weapon.schema.d.ts +4 -0
  245. package/dist/weapon/weapon.schema.js +2 -1
  246. package/dist/weapon/weapon.types.d.ts +8 -0
  247. package/package.json +2 -2
  248. package/dist/chunk-5MZSB6OM.js +0 -1089
  249. package/dist/chunk-5XUXXAQJ.js +0 -30
  250. package/dist/chunk-7P65Q426.js +0 -158
  251. package/dist/chunk-AIRFC5NQ.js +0 -143
  252. package/dist/chunk-BH6AMZVY.js +0 -25
  253. package/dist/chunk-CZPMTQOY.js +0 -68
  254. package/dist/chunk-M2EMFD6S.js +0 -269
  255. package/dist/chunk-N2JE7BWL.js +0 -81
  256. package/dist/chunk-NXR3BD2V.js +0 -90
  257. package/dist/chunk-Q5K6LWBZ.js +0 -45
  258. package/dist/chunk-TZK36BU7.js +0 -38
  259. package/dist/chunk-W7HWMMBF.js +0 -46
  260. package/dist/chunk-Y4I74YEG.js +0 -33
@@ -1,30 +0,0 @@
1
- // src/pc/pc.table-column.ts
2
- function readTableColumn(table, level, keys) {
3
- var _a;
4
- const cols = (_a = table == null ? void 0 : table[level]) == null ? void 0 : _a.columns;
5
- if (!cols) return null;
6
- for (const k of keys) {
7
- const raw = cols[k];
8
- if (raw === void 0 || raw === null) continue;
9
- const n = typeof raw === "number" ? raw : parseInt(String(raw), 10);
10
- if (!Number.isNaN(n)) return n;
11
- }
12
- return null;
13
- }
14
- function numericColumnsAt(table, level) {
15
- var _a;
16
- const out = {};
17
- const cols = (_a = table == null ? void 0 : table[level]) == null ? void 0 : _a.columns;
18
- if (!cols) return out;
19
- for (const [k, raw] of Object.entries(cols)) {
20
- if (raw === void 0 || raw === null) continue;
21
- const n = typeof raw === "number" ? raw : parseInt(String(raw), 10);
22
- if (!Number.isNaN(n)) out[k] = n;
23
- }
24
- return out;
25
- }
26
-
27
- export {
28
- readTableColumn,
29
- numericColumnsAt
30
- };
@@ -1,158 +0,0 @@
1
- // src/monster/monster.parser.ts
2
- import { parseYaml, toStringSafe } from "@archivist-gg/core";
3
- var VALID_RECHARGE_TYPES = /* @__PURE__ */ new Set([
4
- "recharge_on_roll",
5
- "per_day",
6
- "per_short_rest",
7
- "per_long_rest"
8
- ]);
9
- function parseMonster(source) {
10
- var _a, _b, _c, _d, _e, _f, _g;
11
- const result = parseYaml(source, ["name"]);
12
- if (!result.success) return result;
13
- const raw = result.data;
14
- const monster = {
15
- name: toStringSafe(raw.name)
16
- };
17
- if (raw.size != null) monster.size = toStringSafe(raw.size);
18
- if (raw.type != null) monster.type = toStringSafe(raw.type);
19
- if (raw.subtype != null) monster.subtype = toStringSafe(raw.subtype);
20
- if (raw.alignment != null) monster.alignment = toStringSafe(raw.alignment);
21
- if (raw.cr != null) monster.cr = toStringSafe(raw.cr);
22
- if (Array.isArray(raw.ac)) {
23
- monster.ac = raw.ac.map((entry) => ({
24
- ac: Number(entry.ac),
25
- from: Array.isArray(entry.from) ? entry.from.map(String) : void 0
26
- }));
27
- }
28
- if (raw.hp && typeof raw.hp === "object") {
29
- const hp = raw.hp;
30
- monster.hp = {
31
- average: Number(hp.average),
32
- formula: hp.formula != null ? toStringSafe(hp.formula) : void 0
33
- };
34
- }
35
- if (raw.speed && typeof raw.speed === "object") {
36
- const speed = raw.speed;
37
- monster.speed = {};
38
- for (const key of ["walk", "fly", "swim", "climb", "burrow"]) {
39
- if (speed[key] != null) monster.speed[key] = Number(speed[key]);
40
- }
41
- }
42
- if (raw.abilities && typeof raw.abilities === "object") {
43
- const ab = raw.abilities;
44
- monster.abilities = {
45
- str: Number((_a = ab.str) != null ? _a : 10),
46
- dex: Number((_b = ab.dex) != null ? _b : 10),
47
- con: Number((_c = ab.con) != null ? _c : 10),
48
- int: Number((_d = ab.int) != null ? _d : 10),
49
- wis: Number((_e = ab.wis) != null ? _e : 10),
50
- cha: Number((_f = ab.cha) != null ? _f : 10)
51
- };
52
- }
53
- if (raw.saves && typeof raw.saves === "object") {
54
- const saves = {};
55
- for (const [key, val] of Object.entries(raw.saves)) {
56
- saves[key] = Number(val);
57
- }
58
- monster.saves = saves;
59
- }
60
- if (raw.skills && typeof raw.skills === "object") {
61
- const skills = {};
62
- for (const [key, val] of Object.entries(raw.skills)) {
63
- skills[key] = Number(val);
64
- }
65
- monster.skills = skills;
66
- }
67
- if (Array.isArray(raw.senses)) monster.senses = raw.senses.map(String);
68
- if (raw.passive_perception != null) monster.passive_perception = Number(raw.passive_perception);
69
- if (Array.isArray(raw.languages)) monster.languages = raw.languages.map(String);
70
- if (Array.isArray(raw.damage_vulnerabilities)) monster.damage_vulnerabilities = raw.damage_vulnerabilities.map(String);
71
- if (Array.isArray(raw.damage_resistances)) monster.damage_resistances = raw.damage_resistances.map(String);
72
- if (Array.isArray(raw.damage_immunities)) monster.damage_immunities = raw.damage_immunities.map(String);
73
- if (Array.isArray(raw.condition_immunities)) monster.condition_immunities = raw.condition_immunities.map(String);
74
- const parseAttack = (raw2) => {
75
- const a = {
76
- name: toStringSafe(raw2.name),
77
- type: toStringSafe(raw2.type)
78
- };
79
- if (typeof raw2.bonus === "number") a.bonus = raw2.bonus;
80
- if (typeof raw2.damage === "string") a.damage = raw2.damage;
81
- if (typeof raw2.damage_type === "string") a.damage_type = raw2.damage_type;
82
- if (typeof raw2.action === "string") a.action = raw2.action;
83
- if (Array.isArray(raw2.properties)) a.properties = raw2.properties.map(String);
84
- if (raw2.range && typeof raw2.range === "object") {
85
- const r = raw2.range;
86
- a.range = {};
87
- if (typeof r.normal === "number") a.range.normal = r.normal;
88
- if (typeof r.long === "number") a.range.long = r.long;
89
- if (typeof r.reach === "number") a.range.reach = r.reach;
90
- }
91
- if (raw2.extra_damage && typeof raw2.extra_damage === "object") {
92
- const ed = raw2.extra_damage;
93
- if (typeof ed.dice === "string" && typeof ed.type === "string") {
94
- a.extra_damage = { dice: ed.dice, type: ed.type };
95
- }
96
- }
97
- if (typeof raw2.condition === "string") a.condition = raw2.condition;
98
- return a;
99
- };
100
- const parseFeatures = (arr) => {
101
- if (!Array.isArray(arr)) return void 0;
102
- return arr.map((f) => {
103
- const feature = {
104
- name: toStringSafe(f.name),
105
- // Always set entries to an array so downstream renderers/editors
106
- // (which call .join/.map directly) keep working.
107
- entries: Array.isArray(f.entries) ? f.entries.map(String) : []
108
- };
109
- if (typeof f.description === "string") feature.description = f.description;
110
- if (Array.isArray(f.attacks)) {
111
- feature.attacks = f.attacks.map(parseAttack);
112
- }
113
- if (typeof f.action === "string") feature.action = f.action;
114
- if (f.recharge && typeof f.recharge === "object") {
115
- const r = f.recharge;
116
- if (typeof r.type === "string" && VALID_RECHARGE_TYPES.has(r.type) && typeof r.param === "number") {
117
- feature.recharge = {
118
- type: r.type,
119
- param: r.param
120
- };
121
- }
122
- }
123
- return feature;
124
- });
125
- };
126
- monster.traits = parseFeatures(raw.traits);
127
- monster.actions = parseFeatures(raw.actions);
128
- monster.reactions = parseFeatures(raw.reactions);
129
- const legendaryArrayRaw = Array.isArray(raw.legendary_actions) ? raw.legendary_actions : raw.legendary;
130
- monster.legendary_actions = parseFeatures(legendaryArrayRaw);
131
- if (raw.legendary_action_uses != null) {
132
- monster.legendary_action_uses = Number(raw.legendary_action_uses);
133
- } else if (raw.legendary_actions != null && !Array.isArray(raw.legendary_actions) && typeof raw.legendary_actions !== "object") {
134
- monster.legendary_action_uses = Number(raw.legendary_actions);
135
- }
136
- if (raw.legendary_resistance != null) monster.legendary_resistance = Number(raw.legendary_resistance);
137
- if (raw.columns != null) monster.columns = Number(raw.columns);
138
- if (!monster.legendary_resistance && monster.traits) {
139
- const lrIndex = monster.traits.findIndex(
140
- (t) => {
141
- var _a2;
142
- return /^Legendary Resistance\s*\(/i.test((_a2 = t.name) != null ? _a2 : "");
143
- }
144
- );
145
- if (lrIndex !== -1) {
146
- const match = (_g = monster.traits[lrIndex].name) == null ? void 0 : _g.match(/\((\d+)\/Day\)/i);
147
- if (match) {
148
- monster.legendary_resistance = parseInt(match[1], 10);
149
- monster.traits.splice(lrIndex, 1);
150
- }
151
- }
152
- }
153
- return { success: true, data: monster };
154
- }
155
-
156
- export {
157
- parseMonster
158
- };
@@ -1,143 +0,0 @@
1
- import {
2
- bareEntitySlug
3
- } from "./chunk-LV4SNWZQ.js";
4
- import {
5
- ABILITY_KEYS
6
- } from "./chunk-WP2CX2JO.js";
7
-
8
- // src/pc/pc.feature-effects.ts
9
- function emptyFeatureEffectTotals() {
10
- return {
11
- initiative_bonus: 0,
12
- hp_per_level_bonus: 0,
13
- hp_per_level_terms: [],
14
- speed_walk_bonus: 0,
15
- speed_walk_set: 0,
16
- senses: { darkvision: 0, blindsight: 0, tremorsense: 0, truesight: 0 },
17
- ac_terms: [],
18
- resistances: [],
19
- condition_immunities: [],
20
- proficiencies: { skills: [], tools: [], languages: [], saves: [], armor: [], weapons: [] },
21
- weaponAbilities: [],
22
- rollModifiers: [],
23
- critRange: 20,
24
- extraAttack: 0,
25
- attackNotes: [],
26
- damageBonuses: []
27
- };
28
- }
29
- var ABILITY_NAME_TO_KEY = {
30
- strength: "str",
31
- dexterity: "dex",
32
- constitution: "con",
33
- intelligence: "int",
34
- wisdom: "wis",
35
- charisma: "cha"
36
- };
37
- function normalizeAbility(value) {
38
- var _a;
39
- const k = value.trim().toLowerCase();
40
- if (ABILITY_KEYS.includes(k)) return k;
41
- return (_a = ABILITY_NAME_TO_KEY[k]) != null ? _a : null;
42
- }
43
- function pushUnique(list, value) {
44
- const key = value.trim().toLowerCase();
45
- if (!key) return;
46
- if (!list.some((v) => v.trim().toLowerCase() === key)) list.push(value.trim());
47
- }
48
- function computeFeatureEffects(features, opts) {
49
- var _a, _b, _c;
50
- const out = emptyFeatureEffectTotals();
51
- for (const rf of features) {
52
- if (rf.feature.activatable === true) {
53
- const id = rf.feature.id;
54
- if (!id || !((_a = opts == null ? void 0 : opts.activeBuffs) == null ? void 0 : _a.has(id))) continue;
55
- }
56
- for (const eff of (_b = rf.feature.effects) != null ? _b : []) {
57
- applyEffect(out, eff, (_c = rf.feature.name) != null ? _c : "Feature");
58
- }
59
- }
60
- return out;
61
- }
62
- function applyEffect(out, eff, label) {
63
- var _a, _b;
64
- switch (eff.kind) {
65
- case "initiative-bonus":
66
- out.initiative_bonus += eff.value;
67
- break;
68
- case "hp-per-level-bonus":
69
- out.hp_per_level_bonus += eff.value;
70
- out.hp_per_level_terms.push({ label, value: eff.value });
71
- break;
72
- case "speed-bonus":
73
- if (eff.mode === "walk") {
74
- if (eff.set) out.speed_walk_set = Math.max(out.speed_walk_set, eff.value);
75
- else out.speed_walk_bonus += eff.value;
76
- }
77
- break;
78
- case "sense":
79
- out.senses[eff.type] = Math.max(out.senses[eff.type], eff.range);
80
- break;
81
- case "resistance":
82
- pushUnique(out.resistances, eff.damage_type);
83
- break;
84
- case "immune-condition":
85
- if (!eff.while) pushUnique(out.condition_immunities, eff.condition);
86
- break;
87
- case "proficiency": {
88
- if (eff.proficiency_type === "skill") {
89
- pushUnique(out.proficiencies.skills, eff.value.toLowerCase().replace(/\s+/g, "-"));
90
- } else if (eff.proficiency_type === "tool") {
91
- pushUnique(out.proficiencies.tools, eff.value);
92
- } else if (eff.proficiency_type === "language") {
93
- pushUnique(out.proficiencies.languages, eff.value);
94
- } else if (eff.proficiency_type === "armor") {
95
- pushUnique(out.proficiencies.armor, eff.value.toLowerCase());
96
- } else if (eff.proficiency_type === "weapon") {
97
- pushUnique(out.proficiencies.weapons, eff.value.toLowerCase());
98
- } else {
99
- const ab = normalizeAbility(eff.value);
100
- if (ab && !out.proficiencies.saves.includes(ab)) out.proficiencies.saves.push(ab);
101
- }
102
- break;
103
- }
104
- case "ac-bonus":
105
- out.ac_terms.push({ value: eff.value, requires_armor: eff.requires_armor === true, label });
106
- break;
107
- case "weapon-ability": {
108
- if (eff.ability !== "spellcasting") {
109
- const w = eff.weapons;
110
- const weaponSlugs = !w || w === "chosen" ? void 0 : Array.isArray(w) ? w.map(bareEntitySlug) : [bareEntitySlug(w)];
111
- out.weaponAbilities.push({ ability: eff.ability, weaponSlugs });
112
- }
113
- break;
114
- }
115
- case "roll-modifier":
116
- out.rollModifiers.push({ mode: eff.mode, roll: eff.roll, scope: eff.scope, condition: eff.condition, label });
117
- break;
118
- case "crit-range":
119
- if (((_a = eff.applies_to) != null ? _a : "weapon") !== "spell") out.critRange = Math.min(out.critRange, eff.min_roll);
120
- break;
121
- case "extra-attack":
122
- out.extraAttack = Math.max(out.extraAttack, eff.count);
123
- break;
124
- case "reroll-damage":
125
- out.attackNotes.push(`Reroll ${eff.max_reroll}s${eff.once_per_die ? " (once/die)" : ""}`);
126
- break;
127
- case "attack-rule":
128
- if (eff.flag === "no-ranged-in-melee-disadvantage") out.attackNotes.push("No disadvantage firing in melee");
129
- break;
130
- case "damage-bonus":
131
- if (((_b = eff.applies_to) != null ? _b : "weapon") !== "spell") {
132
- out.damageBonuses.push({ amount: eff.amount, damage_type: eff.damage_type, source: label });
133
- }
134
- break;
135
- default:
136
- break;
137
- }
138
- }
139
-
140
- export {
141
- emptyFeatureEffectTotals,
142
- computeFeatureEffects
143
- };
@@ -1,25 +0,0 @@
1
- // src/types/choice.ts
2
- var ALL_SKILL_SLUGS = [
3
- "acrobatics",
4
- "animal-handling",
5
- "arcana",
6
- "athletics",
7
- "deception",
8
- "history",
9
- "insight",
10
- "intimidation",
11
- "investigation",
12
- "medicine",
13
- "nature",
14
- "perception",
15
- "performance",
16
- "persuasion",
17
- "religion",
18
- "sleight-of-hand",
19
- "stealth",
20
- "survival"
21
- ];
22
-
23
- export {
24
- ALL_SKILL_SLUGS
25
- };
@@ -1,68 +0,0 @@
1
- import {
2
- durationSchema
3
- } from "./chunk-WYGD2UGN.js";
4
- import {
5
- resourceConsumptionSchema,
6
- resourceSchema
7
- } from "./chunk-PZOWBI3B.js";
8
- import {
9
- choiceSchema
10
- } from "./chunk-NXSWH3AE.js";
11
- import {
12
- featureEffectSchema
13
- } from "./chunk-NXR3BD2V.js";
14
-
15
- // src/schemas/feature-schema.ts
16
- import { z as z2 } from "zod";
17
-
18
- // src/schemas/attack-schema.ts
19
- import { z } from "zod";
20
- var abilityEnum = z.enum(["str", "dex", "con", "int", "wis", "cha"]);
21
- var attackSchema = z.object({
22
- name: z.string().min(1),
23
- type: z.enum(["melee", "ranged", "spell"]),
24
- ability: z.union([abilityEnum, z.array(abilityEnum).nonempty()]).optional(),
25
- damage: z.string().optional(),
26
- damage_type: z.string().optional(),
27
- action: z.enum(["action", "bonus-action", "reaction"]).optional(),
28
- properties: z.array(z.string()).optional(),
29
- range: z.object({
30
- normal: z.number().int().nonnegative().optional(),
31
- long: z.number().int().nonnegative().optional(),
32
- reach: z.number().int().nonnegative().optional()
33
- }).optional(),
34
- condition: z.string().optional()
35
- });
36
-
37
- // src/schemas/feature-schema.ts
38
- var featureSchema = z2.lazy(
39
- () => z2.object({
40
- id: z2.string().min(1).optional(),
41
- name: z2.string().min(1),
42
- description: z2.string().optional(),
43
- entries: z2.array(z2.string()).optional(),
44
- choices: z2.array(choiceSchema).optional(),
45
- grants_resource: z2.string().optional(),
46
- consumes: resourceConsumptionSchema.optional(),
47
- attacks: z2.array(attackSchema).optional(),
48
- action: z2.enum(["action", "bonus-action", "reaction", "free", "special"]).optional(),
49
- trigger: z2.string().optional(),
50
- dc_formula: z2.string().optional(),
51
- effects: z2.array(featureEffectSchema).optional(),
52
- sub_features: z2.array(featureSchema).optional(),
53
- resources: z2.array(resourceSchema).optional(),
54
- // Phase 3 activatable buffs: a feature flagged `activatable` folds its effects
55
- // only while its id is present in state.active_buffs. `passive` renders a tag;
56
- // `duration` is a static label (no live countdown this phase).
57
- activatable: z2.boolean().optional(),
58
- passive: z2.boolean().optional(),
59
- duration: durationSchema.optional()
60
- }).refine(
61
- (f) => f.description !== void 0 || f.entries !== void 0 && f.entries.length > 0,
62
- { message: "feature requires either description or non-empty entries" }
63
- )
64
- );
65
-
66
- export {
67
- featureSchema
68
- };
@@ -1,269 +0,0 @@
1
- import {
2
- readTableColumn
3
- } from "./chunk-5XUXXAQJ.js";
4
- import {
5
- bareSlug
6
- } from "./chunk-VTTA2ALZ.js";
7
- import {
8
- abilityModifier
9
- } from "./chunk-NAEPSZAM.js";
10
-
11
- // src/pc/pc.spellcasting.ts
12
- function resolveSpellcasting(rc) {
13
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14
- const sub = (_b = (_a = rc.subclass) == null ? void 0 : _a.spellcasting) != null ? _b : null;
15
- const cls = (_d = (_c = rc.entity) == null ? void 0 : _c.spellcasting) != null ? _d : null;
16
- const sc = sub != null ? sub : cls;
17
- if (!sc) return null;
18
- const table = (_i = (_h = sub ? (_e = rc.subclass) == null ? void 0 : _e.table : (_f = rc.entity) == null ? void 0 : _f.table) != null ? _h : (_g = rc.entity) == null ? void 0 : _g.table) != null ? _i : {};
19
- return {
20
- ability: sc.ability,
21
- casterType: sc.caster_type,
22
- preparation: sc.preparation,
23
- spellList: sc.spell_list,
24
- table
25
- };
26
- }
27
- function normalizeKnownSpell(entry) {
28
- var _a, _b;
29
- if (typeof entry === "string") {
30
- return { slug: bareSlug(entry), classSlug: null, source: "class", preparedFlag: void 0, alwaysPrepared: false };
31
- }
32
- return {
33
- slug: bareSlug(entry.spell),
34
- classSlug: entry.class ? bareSlug(entry.class) : null,
35
- source: (_a = entry.source) != null ? _a : "class",
36
- preparedFlag: entry.prepared,
37
- alwaysPrepared: (_b = entry.always_prepared) != null ? _b : false
38
- };
39
- }
40
- var FULL_CASTER_SLOTS = [
41
- /* 1 */
42
- [2, 0, 0, 0, 0, 0, 0, 0, 0],
43
- /* 2 */
44
- [3, 0, 0, 0, 0, 0, 0, 0, 0],
45
- /* 3 */
46
- [4, 2, 0, 0, 0, 0, 0, 0, 0],
47
- /* 4 */
48
- [4, 3, 0, 0, 0, 0, 0, 0, 0],
49
- /* 5 */
50
- [4, 3, 2, 0, 0, 0, 0, 0, 0],
51
- /* 6 */
52
- [4, 3, 3, 0, 0, 0, 0, 0, 0],
53
- /* 7 */
54
- [4, 3, 3, 1, 0, 0, 0, 0, 0],
55
- /* 8 */
56
- [4, 3, 3, 2, 0, 0, 0, 0, 0],
57
- /* 9 */
58
- [4, 3, 3, 3, 1, 0, 0, 0, 0],
59
- /* 10 */
60
- [4, 3, 3, 3, 2, 0, 0, 0, 0],
61
- /* 11 */
62
- [4, 3, 3, 3, 2, 1, 0, 0, 0],
63
- /* 12 */
64
- [4, 3, 3, 3, 2, 1, 0, 0, 0],
65
- /* 13 */
66
- [4, 3, 3, 3, 2, 1, 1, 0, 0],
67
- /* 14 */
68
- [4, 3, 3, 3, 2, 1, 1, 0, 0],
69
- /* 15 */
70
- [4, 3, 3, 3, 2, 1, 1, 1, 0],
71
- /* 16 */
72
- [4, 3, 3, 3, 2, 1, 1, 1, 0],
73
- /* 17 */
74
- [4, 3, 3, 3, 2, 1, 1, 1, 1],
75
- /* 18 */
76
- [4, 3, 3, 3, 3, 1, 1, 1, 1],
77
- /* 19 */
78
- [4, 3, 3, 3, 3, 2, 1, 1, 1],
79
- /* 20 */
80
- [4, 3, 3, 3, 3, 2, 2, 1, 1]
81
- ];
82
- var HALF_CASTER_SLOTS = [
83
- /* 1 */
84
- [0, 0, 0, 0, 0],
85
- /* 2 */
86
- [2, 0, 0, 0, 0],
87
- /* 3 */
88
- [3, 0, 0, 0, 0],
89
- /* 4 */
90
- [3, 0, 0, 0, 0],
91
- /* 5 */
92
- [4, 2, 0, 0, 0],
93
- /* 6 */
94
- [4, 2, 0, 0, 0],
95
- /* 7 */
96
- [4, 3, 0, 0, 0],
97
- /* 8 */
98
- [4, 3, 0, 0, 0],
99
- /* 9 */
100
- [4, 3, 2, 0, 0],
101
- /* 10 */
102
- [4, 3, 2, 0, 0],
103
- /* 11 */
104
- [4, 3, 3, 0, 0],
105
- /* 12 */
106
- [4, 3, 3, 0, 0],
107
- /* 13 */
108
- [4, 3, 3, 1, 0],
109
- /* 14 */
110
- [4, 3, 3, 1, 0],
111
- /* 15 */
112
- [4, 3, 3, 2, 0],
113
- /* 16 */
114
- [4, 3, 3, 2, 0],
115
- /* 17 */
116
- [4, 3, 3, 3, 1],
117
- /* 18 */
118
- [4, 3, 3, 3, 1],
119
- /* 19 */
120
- [4, 3, 3, 3, 2],
121
- /* 20 */
122
- [4, 3, 3, 3, 2]
123
- ];
124
- var THIRD_CASTER_SLOTS = [
125
- /* 1 */
126
- [0, 0, 0, 0],
127
- /* 2 */
128
- [0, 0, 0, 0],
129
- /* 3 */
130
- [2, 0, 0, 0],
131
- /* 4 */
132
- [3, 0, 0, 0],
133
- /* 5 */
134
- [3, 0, 0, 0],
135
- /* 6 */
136
- [3, 0, 0, 0],
137
- /* 7 */
138
- [4, 2, 0, 0],
139
- /* 8 */
140
- [4, 2, 0, 0],
141
- /* 9 */
142
- [4, 2, 0, 0],
143
- /* 10 */
144
- [4, 3, 0, 0],
145
- /* 11 */
146
- [4, 3, 0, 0],
147
- /* 12 */
148
- [4, 3, 0, 0],
149
- /* 13 */
150
- [4, 3, 2, 0],
151
- /* 14 */
152
- [4, 3, 2, 0],
153
- /* 15 */
154
- [4, 3, 2, 0],
155
- /* 16 */
156
- [4, 3, 3, 0],
157
- /* 17 */
158
- [4, 3, 3, 0],
159
- /* 18 */
160
- [4, 3, 3, 0],
161
- /* 19 */
162
- [4, 3, 3, 1],
163
- /* 20 */
164
- [4, 3, 3, 1]
165
- ];
166
- var PACT_MAGIC = [
167
- /* 1 */
168
- { level: 1, total: 1 },
169
- /* 2 */
170
- { level: 1, total: 2 },
171
- /* 3 */
172
- { level: 2, total: 2 },
173
- /* 4 */
174
- { level: 2, total: 2 },
175
- /* 5 */
176
- { level: 3, total: 2 },
177
- /* 6 */
178
- { level: 3, total: 2 },
179
- /* 7 */
180
- { level: 4, total: 2 },
181
- /* 8 */
182
- { level: 4, total: 2 },
183
- /* 9 */
184
- { level: 5, total: 2 },
185
- /* 10 */
186
- { level: 5, total: 2 },
187
- /* 11 */
188
- { level: 5, total: 3 },
189
- /* 12 */
190
- { level: 5, total: 3 },
191
- /* 13 */
192
- { level: 5, total: 3 },
193
- /* 14 */
194
- { level: 5, total: 3 },
195
- /* 15 */
196
- { level: 5, total: 3 },
197
- /* 16 */
198
- { level: 5, total: 3 },
199
- /* 17 */
200
- { level: 5, total: 4 },
201
- /* 18 */
202
- { level: 5, total: 4 },
203
- /* 19 */
204
- { level: 5, total: 4 },
205
- /* 20 */
206
- { level: 5, total: 4 }
207
- ];
208
- function rowToRecord(row) {
209
- const out = {};
210
- row.forEach((n, i) => {
211
- if (n > 0) out[i + 1] = n;
212
- });
213
- return out;
214
- }
215
- function deriveSpellSlots(classes) {
216
- let fullLevels = 0, halfLevels = 0, thirdLevels = 0, warlockLevel = 0;
217
- const regular = [];
218
- for (const c of classes) {
219
- if (c.casterType === "pact") {
220
- warlockLevel += c.level;
221
- continue;
222
- }
223
- regular.push({ caster: c.casterType, level: c.level });
224
- if (c.casterType === "full") fullLevels += c.level;
225
- else if (c.casterType === "half") halfLevels += c.level;
226
- else if (c.casterType === "third") thirdLevels += c.level;
227
- }
228
- let standard = {};
229
- if (regular.length === 1) {
230
- const only = regular[0];
231
- const idx = only.level - 1;
232
- if (only.caster === "half") {
233
- if (idx >= 0 && idx < HALF_CASTER_SLOTS.length) standard = rowToRecord(HALF_CASTER_SLOTS[idx]);
234
- } else if (only.caster === "third") {
235
- if (idx >= 0 && idx < THIRD_CASTER_SLOTS.length) standard = rowToRecord(THIRD_CASTER_SLOTS[idx]);
236
- } else {
237
- if (only.level >= 1 && only.level <= FULL_CASTER_SLOTS.length) standard = rowToRecord(FULL_CASTER_SLOTS[only.level - 1]);
238
- }
239
- } else if (regular.length >= 2) {
240
- const cl = fullLevels + Math.floor(halfLevels / 2) + Math.floor(thirdLevels / 3);
241
- if (cl >= 1 && cl <= FULL_CASTER_SLOTS.length) standard = rowToRecord(FULL_CASTER_SLOTS[cl - 1]);
242
- }
243
- const pact = warlockLevel >= 1 && warlockLevel <= PACT_MAGIC.length ? PACT_MAGIC[warlockLevel - 1] : null;
244
- return { standard, pact };
245
- }
246
- function computeSpellLimits(inputs) {
247
- const out = [];
248
- for (const i of inputs) {
249
- const p = i.profile;
250
- const cantripsKnown = readTableColumn(p.table, i.level, ["Cantrips Known", "Cantrips"]);
251
- const mod = abilityModifier(i.abilityScore);
252
- let preparedOrKnown;
253
- if (p.preparation === "prepared") {
254
- const levelTerm = p.casterType === "half" ? Math.floor(i.level / 2) : i.level;
255
- preparedOrKnown = Math.max(1, mod + levelTerm);
256
- } else {
257
- preparedOrKnown = readTableColumn(p.table, i.level, ["Spells Known", "Prepared Spells"]);
258
- }
259
- out.push({ classSlug: i.classSlug, kind: p.preparation, cantripsKnown, preparedOrKnown });
260
- }
261
- return out;
262
- }
263
-
264
- export {
265
- resolveSpellcasting,
266
- normalizeKnownSpell,
267
- deriveSpellSlots,
268
- computeSpellLimits
269
- };