@archivist-gg/dnd5e 0.3.29 → 0.3.31

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 (96) hide show
  1. package/dist/background/background.codec.js +1 -1
  2. package/dist/background/background.parser.js +1 -1
  3. package/dist/background/background.schema.js +1 -1
  4. package/dist/chunk-34ZLX4TM.js +1 -0
  5. package/dist/{chunk-WXL7ABDO.js → chunk-3CHDDX6S.js} +1 -1
  6. package/dist/chunk-4F5F5A3X.js +1 -0
  7. package/dist/{chunk-OV4FG4KO.js → chunk-5NGQM3TO.js} +1 -1
  8. package/dist/{chunk-ADX7435T.js → chunk-655UY3MP.js} +1 -1
  9. package/dist/{chunk-IR5BA2DZ.js → chunk-65VM2BAA.js} +1 -1
  10. package/dist/{chunk-5QDSAZG6.js → chunk-6GFBSYE3.js} +1 -1
  11. package/dist/{chunk-J27N3KUE.js → chunk-6WRU5I75.js} +1 -1
  12. package/dist/{chunk-YWKC2LJY.js → chunk-73HBCVPD.js} +1 -1
  13. package/dist/{chunk-E4E6YEN6.js → chunk-7S4VMK3R.js} +1 -1
  14. package/dist/{chunk-EON7T2SN.js → chunk-7TH4WPSU.js} +1 -1
  15. package/dist/{chunk-EBFLUJIW.js → chunk-A25HLCQ7.js} +1 -1
  16. package/dist/{chunk-M2UA2FAK.js → chunk-FC4OPNZM.js} +1 -1
  17. package/dist/{chunk-7HOOPNF5.js → chunk-FDWQ6P7Z.js} +1 -1
  18. package/dist/{chunk-RR26E7LH.js → chunk-HI2BXTGB.js} +1 -1
  19. package/dist/{chunk-J6FIBUI4.js → chunk-HPBEMAM6.js} +1 -1
  20. package/dist/{chunk-NB4QWMF5.js → chunk-I6J6ZGZB.js} +1 -1
  21. package/dist/{chunk-GKNOCYDT.js → chunk-IK7XM6BW.js} +1 -1
  22. package/dist/{chunk-XFFFTR6O.js → chunk-IOFGBEGA.js} +1 -1
  23. package/dist/{chunk-U7BPRRY5.js → chunk-JLW7XFFL.js} +1 -1
  24. package/dist/{chunk-XCF5R5XX.js → chunk-JOLGJYDS.js} +1 -1
  25. package/dist/{chunk-NU6WP4P5.js → chunk-KGRRQ4US.js} +1 -1
  26. package/dist/chunk-KWETUSIQ.js +1 -0
  27. package/dist/chunk-LXISMSPG.js +1 -0
  28. package/dist/{chunk-2OVDSMPY.js → chunk-MJJQQI44.js} +1 -1
  29. package/dist/{chunk-D2BXAFOL.js → chunk-Q2U7MWMC.js} +1 -1
  30. package/dist/{chunk-AFEWQFQZ.js → chunk-QCCA46KM.js} +1 -1
  31. package/dist/{chunk-C4T6BUSP.js → chunk-RI4YYU75.js} +1 -1
  32. package/dist/{chunk-R2YRQM7G.js → chunk-TGZ6WQUX.js} +1 -1
  33. package/dist/{chunk-PFQPP77Q.js → chunk-YDN6GD2B.js} +1 -1
  34. package/dist/{chunk-VY5ZEOLG.js → chunk-Z362RQTB.js} +1 -1
  35. package/dist/{chunk-VHIE2KYQ.js → chunk-ZK3P4RSE.js} +1 -1
  36. package/dist/{chunk-CCFIINBA.js → chunk-ZKDHCDJ2.js} +1 -1
  37. package/dist/{chunk-DXJ5NKKB.js → chunk-ZYMWQ7PG.js} +1 -1
  38. package/dist/{chunk-KGZXAAFN.js → chunk-ZZ6QHLWX.js} +1 -1
  39. package/dist/class/class.codec.js +1 -1
  40. package/dist/class/class.parser.js +1 -1
  41. package/dist/class/class.schema.js +1 -1
  42. package/dist/class/class.slug.d.ts +1 -0
  43. package/dist/class/class.slug.js +1 -1
  44. package/dist/feat/feat.codec.js +1 -1
  45. package/dist/feat/feat.parser.js +1 -1
  46. package/dist/feat/feat.schema.d.ts +12 -0
  47. package/dist/feat/feat.schema.js +1 -1
  48. package/dist/index.js +17 -13
  49. package/dist/monster/monster.parser.js +1 -1
  50. package/dist/monster/monster.schema.js +1 -1
  51. package/dist/optional-feature/optional-feature.codec.js +1 -1
  52. package/dist/optional-feature/optional-feature.parser.js +1 -1
  53. package/dist/optional-feature/optional-feature.schema.d.ts +13 -0
  54. package/dist/optional-feature/optional-feature.schema.js +1 -1
  55. package/dist/pc/pc.additional-spells.js +1 -1
  56. package/dist/pc/pc.amount-bindings.d.ts +1 -0
  57. package/dist/pc/pc.amount-bindings.js +1 -1
  58. package/dist/pc/pc.decision-engine.js +1 -1
  59. package/dist/pc/pc.entry-overrides.js +1 -1
  60. package/dist/pc/pc.equipment.js +1 -1
  61. package/dist/pc/pc.feature-effects.d.ts +18 -0
  62. package/dist/pc/pc.feature-effects.js +1 -1
  63. package/dist/pc/pc.granted-spends.d.ts +2 -0
  64. package/dist/pc/pc.infusions.js +1 -1
  65. package/dist/pc/pc.item-effects.js +1 -1
  66. package/dist/pc/pc.member-choices.js +1 -1
  67. package/dist/pc/pc.pools.js +1 -1
  68. package/dist/pc/pc.proficiencies.js +1 -1
  69. package/dist/pc/pc.recalc.js +1 -1
  70. package/dist/pc/pc.resolver.js +1 -1
  71. package/dist/pc/pc.resource-seed.js +1 -1
  72. package/dist/pc/pc.resources.js +1 -1
  73. package/dist/pc/pc.rest.js +1 -1
  74. package/dist/pc/pc.schema.d.ts +1 -1
  75. package/dist/pc/pc.spellcasting.js +1 -1
  76. package/dist/pc/pc.types.d.ts +25 -0
  77. package/dist/race/race.codec.js +1 -1
  78. package/dist/race/race.parser.js +1 -1
  79. package/dist/race/race.schema.js +1 -1
  80. package/dist/schemas/choice-schema.js +1 -1
  81. package/dist/schemas/feature-effect-schema.d.ts +12 -0
  82. package/dist/schemas/feature-effect-schema.js +1 -1
  83. package/dist/schemas/feature-schema.js +1 -1
  84. package/dist/schemas/resource-schema.d.ts +1 -0
  85. package/dist/schemas/resource-schema.js +1 -1
  86. package/dist/spell/spell.access.js +1 -1
  87. package/dist/subclass/subclass.codec.js +1 -1
  88. package/dist/subclass/subclass.parser.js +1 -1
  89. package/dist/subclass/subclass.schema.js +1 -1
  90. package/dist/types/feature-effect.d.ts +10 -0
  91. package/dist/types/resource.d.ts +1 -0
  92. package/package.json +1 -1
  93. package/dist/chunk-53SHSS4M.js +0 -1
  94. package/dist/chunk-B2JSF2LL.js +0 -1
  95. package/dist/chunk-CAPYNIGK.js +0 -1
  96. package/dist/chunk-JSI2G6LE.js +0 -1
@@ -1 +1 @@
1
- import{readTableColumn}from"./chunk-CSTAQQGX.js";import{bareSlug,baseClassName}from"./chunk-CAPYNIGK.js";import{abilityModifier}from"./chunk-7FPQJDFD.js";function hasPreparedColumn(table){return Object.values(table).some(row=>PREPARED_COLUMNS.some(k=>{var _a;return((_a=row==null?void 0:row.columns)==null?void 0:_a[k])!==void 0}))}function resolveSpellcasting(rc){var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p;const sub=(_b=(_a=rc.subclass)==null?void 0:_a.spellcasting)!=null?_b:null;const cls=(_d=(_c=rc.entity)==null?void 0:_c.spellcasting)!=null?_d:null;const casterType=(_f=(_e=sub==null?void 0:sub.caster_type)!=null?_e:cls==null?void 0:cls.caster_type)!=null?_f:null;const ability=(_h=(_g=sub==null?void 0:sub.ability)!=null?_g:cls==null?void 0:cls.ability)!=null?_h:null;if(!casterType||!ability)return null;const table=(_l=(_k=(sub==null?void 0:sub.caster_type)?(_i=rc.subclass)==null?void 0:_i.table:void 0)!=null?_k:(_j=rc.entity)==null?void 0:_j.table)!=null?_l:{};const preparation=(_n=(_m=sub==null?void 0:sub.preparation)!=null?_m:cls==null?void 0:cls.preparation)!=null?_n:hasPreparedColumn(table)?"prepared":"known";const spellList=(_p=(_o=sub==null?void 0:sub.spell_list)!=null?_o:cls==null?void 0:cls.spell_list)!=null?_p:null;return{ability,casterType,preparation,spellList,table}}function effectiveSpellcastingAbility(classSlug,dataAbility,overrides){var _a,_b;return(_b=(_a=overrides.spellcasting_ability_by_class)==null?void 0:_a[classSlug])!=null?_b:dataAbility}function normalizeKnownSpell(entry){var _a,_b;if(typeof entry==="string"){return{slug:bareSlug(entry),classSlug:null,source:"class",preparedFlag:void 0,alwaysPrepared:false}}return{slug:bareSlug(entry.spell),classSlug:entry.class?bareSlug(entry.class):null,source:(_a=entry.source)!=null?_a:"class",preparedFlag:entry.prepared,alwaysPrepared:(_b=entry.always_prepared)!=null?_b:false}}function firstListedCasterClass(spellClasses,casterClassSlugs){var _a;if(!Array.isArray(spellClasses)||spellClasses.length===0)return null;const listed=new Set(spellClasses.map(c=>baseClassName(String(c))));return(_a=casterClassSlugs.find(slug=>listed.has(baseClassName(slug))))!=null?_a:null}var LISTED_CLASS_NAMES=new WeakMap;var NO_NAMES=new Set;function listedSpellClassNames(registry,compendium){var _a;const count=registry.count();let cached=LISTED_CLASS_NAMES.get(registry);if(!cached||cached.count!==count){const byCompendium=new Map;for(const e of registry.search("","spell",Number.POSITIVE_INFINITY)){const classes=e.data.classes;if(!Array.isArray(classes))continue;let names=byCompendium.get(e.compendium);if(!names)byCompendium.set(e.compendium,names=new Set);for(const c of classes)names.add(baseClassName(String(c)))}cached={count,byCompendium};LISTED_CLASS_NAMES.set(registry,cached)}return(_a=cached.byCompendium.get(compendium))!=null?_a:NO_NAMES}function attributeUnclassedSpell(spellClasses,casters,registry){var _a;const first=casters[0];if(!first)return null;const listed=firstListedCasterClass(spellClasses,casters.map(c=>c.classSlug));if(listed==null||listed===first.classSlug)return first.classSlug;if(first.spellList==null)return first.classSlug;const compendium=(_a=registry.getByTypeAndSlug("class",first.classSlug))==null?void 0:_a.compendium;if(compendium==null||!listedSpellClassNames(registry,compendium).has(baseClassName(first.classSlug)))return first.classSlug;return listed}var FULL_CASTER_SLOTS=[[2,0,0,0,0,0,0,0,0],[3,0,0,0,0,0,0,0,0],[4,2,0,0,0,0,0,0,0],[4,3,0,0,0,0,0,0,0],[4,3,2,0,0,0,0,0,0],[4,3,3,0,0,0,0,0,0],[4,3,3,1,0,0,0,0,0],[4,3,3,2,0,0,0,0,0],[4,3,3,3,1,0,0,0,0],[4,3,3,3,2,0,0,0,0],[4,3,3,3,2,1,0,0,0],[4,3,3,3,2,1,0,0,0],[4,3,3,3,2,1,1,0,0],[4,3,3,3,2,1,1,0,0],[4,3,3,3,2,1,1,1,0],[4,3,3,3,2,1,1,1,0],[4,3,3,3,2,1,1,1,1],[4,3,3,3,3,1,1,1,1],[4,3,3,3,3,2,1,1,1],[4,3,3,3,3,2,2,1,1]];var HALF_CASTER_SLOTS=[[0,0,0,0,0],[2,0,0,0,0],[3,0,0,0,0],[3,0,0,0,0],[4,2,0,0,0],[4,2,0,0,0],[4,3,0,0,0],[4,3,0,0,0],[4,3,2,0,0],[4,3,2,0,0],[4,3,3,0,0],[4,3,3,0,0],[4,3,3,1,0],[4,3,3,1,0],[4,3,3,2,0],[4,3,3,2,0],[4,3,3,3,1],[4,3,3,3,1],[4,3,3,3,2],[4,3,3,3,2]];var THIRD_CASTER_SLOTS=[[0,0,0,0],[0,0,0,0],[2,0,0,0],[3,0,0,0],[3,0,0,0],[3,0,0,0],[4,2,0,0],[4,2,0,0],[4,2,0,0],[4,3,0,0],[4,3,0,0],[4,3,0,0],[4,3,2,0],[4,3,2,0],[4,3,2,0],[4,3,3,0],[4,3,3,0],[4,3,3,0],[4,3,3,1],[4,3,3,1]];var PACT_MAGIC=[{level:1,total:1},{level:1,total:2},{level:2,total:2},{level:2,total:2},{level:3,total:2},{level:3,total:2},{level:4,total:2},{level:4,total:2},{level:5,total:2},{level:5,total:2},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:4},{level:5,total:4},{level:5,total:4},{level:5,total:4}];var HALF_UP_CASTER_SLOTS=HALF_CASTER_SLOTS.map(row=>[...row]);HALF_UP_CASTER_SLOTS[0]=[2,0,0,0,0];function slotTableFor(caster){switch(caster){case"full":return FULL_CASTER_SLOTS;case"half":return HALF_CASTER_SLOTS;case"third":return THIRD_CASTER_SLOTS;case"half-up":return HALF_UP_CASTER_SLOTS;default:{const _n=caster;throw new Error(`unknown caster type ${String(_n)}`)}}}function rowToRecord(row){const out={};row.forEach((n,i)=>{if(n>0)out[i+1]=n});return out}function deriveSpellSlots(classes){let fullLevels=0,halfLevels=0,thirdLevels=0,halfUpLevels=0,warlockLevel=0;const regular=[];for(const c of classes){if(c.casterType==="pact"){warlockLevel+=c.level;continue}regular.push({caster:c.casterType,level:c.level});switch(c.casterType){case"full":fullLevels+=c.level;break;case"half":halfLevels+=c.level;break;case"third":thirdLevels+=c.level;break;case"half-up":halfUpLevels+=c.level;break;default:{const _n=c.casterType;throw new Error(`unknown caster type ${String(_n)}`)}}}let standard={};if(regular.length===1){const only=regular[0];const table=slotTableFor(only.caster);const idx=only.level-1;if(idx>=0&&idx<table.length)standard=rowToRecord(table[idx])}else if(regular.length>=2){const cl=fullLevels+Math.floor(halfLevels/2)+Math.floor(thirdLevels/3)+Math.ceil(halfUpLevels/2);if(cl>=1&&cl<=FULL_CASTER_SLOTS.length)standard=rowToRecord(FULL_CASTER_SLOTS[cl-1])}const pact=warlockLevel>=1&&warlockLevel<=PACT_MAGIC.length?PACT_MAGIC[warlockLevel-1]:null;return{standard,pact}}var PREPARED_COLUMNS=["Prepared Spells","Spells Prepared"];function preparedLevelTerm(caster,level){switch(caster){case"full":case"pact":return level;case"half":case"half-up":return Math.floor(level/2);case"third":return Math.floor(level/3);default:{const _n=caster;throw new Error(`unknown caster type ${String(_n)}`)}}}function computeSpellLimits(inputs){const out=[];for(const i of inputs){const p=i.profile;const cantripsKnown=readTableColumn(p.table,i.level,["Cantrips Known","Cantrips"]);const mod=abilityModifier(i.abilityScore);let preparedOrKnown;if(p.preparation==="prepared"){const fromTable=readTableColumn(p.table,i.level,PREPARED_COLUMNS);preparedOrKnown=fromTable!==null?fromTable:Math.max(1,mod+preparedLevelTerm(p.casterType,i.level))}else{preparedOrKnown=readTableColumn(p.table,i.level,["Spells Known","Prepared Spells"])}out.push({classSlug:i.classSlug,kind:p.preparation,cantripsKnown,preparedOrKnown})}return out}export{resolveSpellcasting,effectiveSpellcastingAbility,normalizeKnownSpell,listedSpellClassNames,attributeUnclassedSpell,slotTableFor,deriveSpellSlots,PREPARED_COLUMNS,preparedLevelTerm,computeSpellLimits};
1
+ import{readTableColumn}from"./chunk-CSTAQQGX.js";import{bareSlug,baseClassName}from"./chunk-4F5F5A3X.js";import{abilityModifier}from"./chunk-7FPQJDFD.js";function hasPreparedColumn(table){return Object.values(table).some(row=>PREPARED_COLUMNS.some(k=>{var _a;return((_a=row==null?void 0:row.columns)==null?void 0:_a[k])!==void 0}))}function resolveSpellcasting(rc){var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p;const sub=(_b=(_a=rc.subclass)==null?void 0:_a.spellcasting)!=null?_b:null;const cls=(_d=(_c=rc.entity)==null?void 0:_c.spellcasting)!=null?_d:null;const casterType=(_f=(_e=sub==null?void 0:sub.caster_type)!=null?_e:cls==null?void 0:cls.caster_type)!=null?_f:null;const ability=(_h=(_g=sub==null?void 0:sub.ability)!=null?_g:cls==null?void 0:cls.ability)!=null?_h:null;if(!casterType||!ability)return null;const table=(_l=(_k=(sub==null?void 0:sub.caster_type)?(_i=rc.subclass)==null?void 0:_i.table:void 0)!=null?_k:(_j=rc.entity)==null?void 0:_j.table)!=null?_l:{};const preparation=(_n=(_m=sub==null?void 0:sub.preparation)!=null?_m:cls==null?void 0:cls.preparation)!=null?_n:hasPreparedColumn(table)?"prepared":"known";const spellList=(_p=(_o=sub==null?void 0:sub.spell_list)!=null?_o:cls==null?void 0:cls.spell_list)!=null?_p:null;return{ability,casterType,preparation,spellList,table}}function effectiveSpellcastingAbility(classSlug,dataAbility,overrides){var _a,_b;return(_b=(_a=overrides.spellcasting_ability_by_class)==null?void 0:_a[classSlug])!=null?_b:dataAbility}function normalizeKnownSpell(entry){var _a,_b;if(typeof entry==="string"){return{slug:bareSlug(entry),classSlug:null,source:"class",preparedFlag:void 0,alwaysPrepared:false}}return{slug:bareSlug(entry.spell),classSlug:entry.class?bareSlug(entry.class):null,source:(_a=entry.source)!=null?_a:"class",preparedFlag:entry.prepared,alwaysPrepared:(_b=entry.always_prepared)!=null?_b:false}}function firstListedCasterClass(spellClasses,casterClassSlugs){var _a;if(!Array.isArray(spellClasses)||spellClasses.length===0)return null;const listed=new Set(spellClasses.map(c=>baseClassName(String(c))));return(_a=casterClassSlugs.find(slug=>listed.has(baseClassName(slug))))!=null?_a:null}var LISTED_CLASS_NAMES=new WeakMap;var NO_NAMES=new Set;function listedSpellClassNames(registry,compendium){var _a;const count=registry.count();let cached=LISTED_CLASS_NAMES.get(registry);if(!cached||cached.count!==count){const byCompendium=new Map;for(const e of registry.search("","spell",Number.POSITIVE_INFINITY)){const classes=e.data.classes;if(!Array.isArray(classes))continue;let names=byCompendium.get(e.compendium);if(!names)byCompendium.set(e.compendium,names=new Set);for(const c of classes)names.add(baseClassName(String(c)))}cached={count,byCompendium};LISTED_CLASS_NAMES.set(registry,cached)}return(_a=cached.byCompendium.get(compendium))!=null?_a:NO_NAMES}function attributeUnclassedSpell(spellClasses,casters,registry){var _a;const first=casters[0];if(!first)return null;const listed=firstListedCasterClass(spellClasses,casters.map(c=>c.classSlug));if(listed==null||listed===first.classSlug)return first.classSlug;if(first.spellList==null)return first.classSlug;const compendium=(_a=registry.getByTypeAndSlug("class",first.classSlug))==null?void 0:_a.compendium;if(compendium==null||!listedSpellClassNames(registry,compendium).has(baseClassName(first.classSlug)))return first.classSlug;return listed}var FULL_CASTER_SLOTS=[[2,0,0,0,0,0,0,0,0],[3,0,0,0,0,0,0,0,0],[4,2,0,0,0,0,0,0,0],[4,3,0,0,0,0,0,0,0],[4,3,2,0,0,0,0,0,0],[4,3,3,0,0,0,0,0,0],[4,3,3,1,0,0,0,0,0],[4,3,3,2,0,0,0,0,0],[4,3,3,3,1,0,0,0,0],[4,3,3,3,2,0,0,0,0],[4,3,3,3,2,1,0,0,0],[4,3,3,3,2,1,0,0,0],[4,3,3,3,2,1,1,0,0],[4,3,3,3,2,1,1,0,0],[4,3,3,3,2,1,1,1,0],[4,3,3,3,2,1,1,1,0],[4,3,3,3,2,1,1,1,1],[4,3,3,3,3,1,1,1,1],[4,3,3,3,3,2,1,1,1],[4,3,3,3,3,2,2,1,1]];var HALF_CASTER_SLOTS=[[0,0,0,0,0],[2,0,0,0,0],[3,0,0,0,0],[3,0,0,0,0],[4,2,0,0,0],[4,2,0,0,0],[4,3,0,0,0],[4,3,0,0,0],[4,3,2,0,0],[4,3,2,0,0],[4,3,3,0,0],[4,3,3,0,0],[4,3,3,1,0],[4,3,3,1,0],[4,3,3,2,0],[4,3,3,2,0],[4,3,3,3,1],[4,3,3,3,1],[4,3,3,3,2],[4,3,3,3,2]];var THIRD_CASTER_SLOTS=[[0,0,0,0],[0,0,0,0],[2,0,0,0],[3,0,0,0],[3,0,0,0],[3,0,0,0],[4,2,0,0],[4,2,0,0],[4,2,0,0],[4,3,0,0],[4,3,0,0],[4,3,0,0],[4,3,2,0],[4,3,2,0],[4,3,2,0],[4,3,3,0],[4,3,3,0],[4,3,3,0],[4,3,3,1],[4,3,3,1]];var PACT_MAGIC=[{level:1,total:1},{level:1,total:2},{level:2,total:2},{level:2,total:2},{level:3,total:2},{level:3,total:2},{level:4,total:2},{level:4,total:2},{level:5,total:2},{level:5,total:2},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:3},{level:5,total:4},{level:5,total:4},{level:5,total:4},{level:5,total:4}];var HALF_UP_CASTER_SLOTS=HALF_CASTER_SLOTS.map(row=>[...row]);HALF_UP_CASTER_SLOTS[0]=[2,0,0,0,0];function slotTableFor(caster){switch(caster){case"full":return FULL_CASTER_SLOTS;case"half":return HALF_CASTER_SLOTS;case"third":return THIRD_CASTER_SLOTS;case"half-up":return HALF_UP_CASTER_SLOTS;default:{const _n=caster;throw new Error(`unknown caster type ${String(_n)}`)}}}function rowToRecord(row){const out={};row.forEach((n,i)=>{if(n>0)out[i+1]=n});return out}function deriveSpellSlots(classes){let fullLevels=0,halfLevels=0,thirdLevels=0,halfUpLevels=0,warlockLevel=0;const regular=[];for(const c of classes){if(c.casterType==="pact"){warlockLevel+=c.level;continue}regular.push({caster:c.casterType,level:c.level});switch(c.casterType){case"full":fullLevels+=c.level;break;case"half":halfLevels+=c.level;break;case"third":thirdLevels+=c.level;break;case"half-up":halfUpLevels+=c.level;break;default:{const _n=c.casterType;throw new Error(`unknown caster type ${String(_n)}`)}}}let standard={};if(regular.length===1){const only=regular[0];const table=slotTableFor(only.caster);const idx=only.level-1;if(idx>=0&&idx<table.length)standard=rowToRecord(table[idx])}else if(regular.length>=2){const cl=fullLevels+Math.floor(halfLevels/2)+Math.floor(thirdLevels/3)+Math.ceil(halfUpLevels/2);if(cl>=1&&cl<=FULL_CASTER_SLOTS.length)standard=rowToRecord(FULL_CASTER_SLOTS[cl-1])}const pact=warlockLevel>=1&&warlockLevel<=PACT_MAGIC.length?PACT_MAGIC[warlockLevel-1]:null;return{standard,pact}}var PREPARED_COLUMNS=["Prepared Spells","Spells Prepared"];function preparedLevelTerm(caster,level){switch(caster){case"full":case"pact":return level;case"half":case"half-up":return Math.floor(level/2);case"third":return Math.floor(level/3);default:{const _n=caster;throw new Error(`unknown caster type ${String(_n)}`)}}}function computeSpellLimits(inputs){const out=[];for(const i of inputs){const p=i.profile;const cantripsKnown=readTableColumn(p.table,i.level,["Cantrips Known","Cantrips"]);const mod=abilityModifier(i.abilityScore);let preparedOrKnown;if(p.preparation==="prepared"){const fromTable=readTableColumn(p.table,i.level,PREPARED_COLUMNS);preparedOrKnown=fromTable!==null?fromTable:Math.max(1,mod+preparedLevelTerm(p.casterType,i.level))}else{preparedOrKnown=readTableColumn(p.table,i.level,["Spells Known","Prepared Spells"])}out.push({classSlug:i.classSlug,kind:p.preparation,cantripsKnown,preparedOrKnown})}return out}export{resolveSpellcasting,effectiveSpellcastingAbility,normalizeKnownSpell,listedSpellClassNames,attributeUnclassedSpell,slotTableFor,deriveSpellSlots,PREPARED_COLUMNS,preparedLevelTerm,computeSpellLimits};
@@ -1 +1 @@
1
- import{MONSTER_KNOWN_KEYS,monsterSchema}from"./chunk-5QDSAZG6.js";import{parseYaml}from"@archivist-gg/core";var VALID_RECHARGE_TYPES=new Set(["recharge_on_roll","per_day","per_short_rest","per_long_rest"]);var NUMERIC_STRING=/^[+-]?\d+(\.\d+)?$/;var FEATURE_ARRAYS=["traits","actions","reactions","legendary_actions","bonus_actions","mythic"];var SPEED_MODES=["walk","fly","swim","climb","burrow"];var ABILITY_KEYS=["str","dex","con","int","wis","cha"];var NULL_KEPT=new Set(["senses","languages","group"]);function isRecord(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function coerceNumeric(obj,key){const v=obj[key];if(typeof v==="string"&&NUMERIC_STRING.test(v.trim()))obj[key]=Number(v)}function scrubNulls(v,top){if(Array.isArray(v)){for(let i=v.length-1;i>=0;i--){if(v[i]===null)v.splice(i,1);else scrubNulls(v[i],false)}return}if(!isRecord(v))return;for(const[k,x]of Object.entries(v)){if(x===null){if(!(top&&NULL_KEPT.has(k)))delete v[k]}else scrubNulls(x,false)}}function scrubNonFinite(v){if(Array.isArray(v)){for(const x of v)scrubNonFinite(x);return}if(!isRecord(v))return;for(const[k,x]of Object.entries(v)){if(typeof x==="number"&&!Number.isFinite(x))delete v[k];else scrubNonFinite(x)}}function migrateLegacy(raw){scrubNulls(raw,true);if(raw.legendary_actions!=null&&!Array.isArray(raw.legendary_actions)&&typeof raw.legendary_actions!=="object"){if(raw.legendary_action_uses==null)raw.legendary_action_uses=Number(raw.legendary_actions);delete raw.legendary_actions}if(!Array.isArray(raw.legendary_actions)&&Array.isArray(raw.legendary))raw.legendary_actions=raw.legendary;delete raw.legendary;if(typeof raw.ac==="number")raw.ac=[{ac:raw.ac}];if(Array.isArray(raw.ac))raw.ac=raw.ac.map(e=>typeof e==="number"?{ac:e}:e);if(typeof raw.hp==="number")raw.hp={average:raw.hp};if(typeof raw.cr==="number")raw.cr=String(raw.cr);for(const k of["passive_perception","legendary_action_uses","legendary_resistance","columns","initiative"])coerceNumeric(raw,k);if(isRecord(raw.initiative))coerceNumeric(raw.initiative,"proficiency");for(const k of["saves","skills"]){const o=raw[k];if(isRecord(o))for(const m of Object.keys(o))coerceNumeric(o,m)}if(isRecord(raw.hp))coerceNumeric(raw.hp,"average");if(Array.isArray(raw.ac)){for(const e of raw.ac)if(isRecord(e))coerceNumeric(e,"ac")}if(isRecord(raw.abilities))for(const k of ABILITY_KEYS)coerceNumeric(raw.abilities,k);if(isRecord(raw.speed))for(const k of SPEED_MODES){coerceNumeric(raw.speed,k);const v=raw.speed[k];if(isRecord(v))coerceNumeric(v,"number")}scrubNonFinite(raw);if(isRecord(raw.abilities)){for(const k of ABILITY_KEYS)if(raw.abilities[k]==null)raw.abilities[k]=10}if(typeof raw.senses==="string")raw.senses=[raw.senses];if(typeof raw.languages==="string")raw.languages=[raw.languages];for(const k of FEATURE_ARRAYS){const arr=raw[k];if(!Array.isArray(arr))continue;for(const f of arr){if(!isRecord(f))continue;if(typeof f.desc==="string"&&f.description===void 0&&!Array.isArray(f.entries)){f.description=f.desc;delete f.desc}const r=f.recharge;if(r!==void 0&&!(isRecord(r)&&typeof r.param==="number"&&VALID_RECHARGE_TYPES.has(r.type)))delete f.recharge}}}function parseMonster(source){var _a,_b;const result=parseYaml(source,["name"]);if(!result.success)return result;const raw=result.data;migrateLegacy(raw);const parsed=monsterSchema.safeParse(raw);if(!parsed.success){return{success:false,error:`monster schema validation failed: ${parsed.error.message}`}}const monster=parsed.data;const extras={};for(const[k,v]of Object.entries(raw))if(!MONSTER_KNOWN_KEYS.has(k))extras[k]=v;if(Object.keys(extras).length>0)monster.raw={...(_a=monster.raw)!=null?_a:{},...extras};if(!monster.legendary_resistance&&monster.traits){const lrIndex=monster.traits.findIndex(t=>{var _a2;return/^Legendary Resistance\s*\(/i.test((_a2=t.name)!=null?_a2:"")});if(lrIndex!==-1){const match=(_b=monster.traits[lrIndex].name)==null?void 0:_b.match(/\((\d+)\/Day\)/i);if(match){monster.legendary_resistance=parseInt(match[1],10);monster.traits.splice(lrIndex,1)}}}return{success:true,data:monster}}export{migrateLegacy,parseMonster};
1
+ import{MONSTER_KNOWN_KEYS,monsterSchema}from"./chunk-6GFBSYE3.js";import{parseYaml}from"@archivist-gg/core";var VALID_RECHARGE_TYPES=new Set(["recharge_on_roll","per_day","per_short_rest","per_long_rest"]);var NUMERIC_STRING=/^[+-]?\d+(\.\d+)?$/;var FEATURE_ARRAYS=["traits","actions","reactions","legendary_actions","bonus_actions","mythic"];var SPEED_MODES=["walk","fly","swim","climb","burrow"];var ABILITY_KEYS=["str","dex","con","int","wis","cha"];var NULL_KEPT=new Set(["senses","languages","group"]);function isRecord(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function coerceNumeric(obj,key){const v=obj[key];if(typeof v==="string"&&NUMERIC_STRING.test(v.trim()))obj[key]=Number(v)}function scrubNulls(v,top){if(Array.isArray(v)){for(let i=v.length-1;i>=0;i--){if(v[i]===null)v.splice(i,1);else scrubNulls(v[i],false)}return}if(!isRecord(v))return;for(const[k,x]of Object.entries(v)){if(x===null){if(!(top&&NULL_KEPT.has(k)))delete v[k]}else scrubNulls(x,false)}}function scrubNonFinite(v){if(Array.isArray(v)){for(const x of v)scrubNonFinite(x);return}if(!isRecord(v))return;for(const[k,x]of Object.entries(v)){if(typeof x==="number"&&!Number.isFinite(x))delete v[k];else scrubNonFinite(x)}}function migrateLegacy(raw){scrubNulls(raw,true);if(raw.legendary_actions!=null&&!Array.isArray(raw.legendary_actions)&&typeof raw.legendary_actions!=="object"){if(raw.legendary_action_uses==null)raw.legendary_action_uses=Number(raw.legendary_actions);delete raw.legendary_actions}if(!Array.isArray(raw.legendary_actions)&&Array.isArray(raw.legendary))raw.legendary_actions=raw.legendary;delete raw.legendary;if(typeof raw.ac==="number")raw.ac=[{ac:raw.ac}];if(Array.isArray(raw.ac))raw.ac=raw.ac.map(e=>typeof e==="number"?{ac:e}:e);if(typeof raw.hp==="number")raw.hp={average:raw.hp};if(typeof raw.cr==="number")raw.cr=String(raw.cr);for(const k of["passive_perception","legendary_action_uses","legendary_resistance","columns","initiative"])coerceNumeric(raw,k);if(isRecord(raw.initiative))coerceNumeric(raw.initiative,"proficiency");for(const k of["saves","skills"]){const o=raw[k];if(isRecord(o))for(const m of Object.keys(o))coerceNumeric(o,m)}if(isRecord(raw.hp))coerceNumeric(raw.hp,"average");if(Array.isArray(raw.ac)){for(const e of raw.ac)if(isRecord(e))coerceNumeric(e,"ac")}if(isRecord(raw.abilities))for(const k of ABILITY_KEYS)coerceNumeric(raw.abilities,k);if(isRecord(raw.speed))for(const k of SPEED_MODES){coerceNumeric(raw.speed,k);const v=raw.speed[k];if(isRecord(v))coerceNumeric(v,"number")}scrubNonFinite(raw);if(isRecord(raw.abilities)){for(const k of ABILITY_KEYS)if(raw.abilities[k]==null)raw.abilities[k]=10}if(typeof raw.senses==="string")raw.senses=[raw.senses];if(typeof raw.languages==="string")raw.languages=[raw.languages];for(const k of FEATURE_ARRAYS){const arr=raw[k];if(!Array.isArray(arr))continue;for(const f of arr){if(!isRecord(f))continue;if(typeof f.desc==="string"&&f.description===void 0&&!Array.isArray(f.entries)){f.description=f.desc;delete f.desc}const r=f.recharge;if(r!==void 0&&!(isRecord(r)&&typeof r.param==="number"&&VALID_RECHARGE_TYPES.has(r.type)))delete f.recharge}}}function parseMonster(source){var _a,_b;const result=parseYaml(source,["name"]);if(!result.success)return result;const raw=result.data;migrateLegacy(raw);const parsed=monsterSchema.safeParse(raw);if(!parsed.success){return{success:false,error:`monster schema validation failed: ${parsed.error.message}`}}const monster=parsed.data;const extras={};for(const[k,v]of Object.entries(raw))if(!MONSTER_KNOWN_KEYS.has(k))extras[k]=v;if(Object.keys(extras).length>0)monster.raw={...(_a=monster.raw)!=null?_a:{},...extras};if(!monster.legendary_resistance&&monster.traits){const lrIndex=monster.traits.findIndex(t=>{var _a2;return/^Legendary Resistance\s*\(/i.test((_a2=t.name)!=null?_a2:"")});if(lrIndex!==-1){const match=(_b=monster.traits[lrIndex].name)==null?void 0:_b.match(/\((\d+)\/Day\)/i);if(match){monster.legendary_resistance=parseInt(match[1],10);monster.traits.splice(lrIndex,1)}}}return{success:true,data:monster}}export{migrateLegacy,parseMonster};
@@ -1 +1 @@
1
- import{featureEffectSchema}from"./chunk-EON7T2SN.js";import{z}from"zod";var abilityEnum=z.enum(["str","dex","con","int","wis","cha"]);var entityFilterSchema=z.object({feature_type:z.string().min(1).optional(),category:z.string().min(1).optional(),parent_class:z.literal("self").optional(),available_to:z.literal("self").optional(),weapon_category:z.enum(["simple","martial"]).optional(),armor_category:z.enum(["light","medium","heavy","shield"]).optional(),item_type:z.array(z.string().min(1)).nonempty().optional(),mundane:z.boolean().optional(),list:z.string().min(1).optional(),level:z.number().int().min(0).max(9).optional(),edition:z.string().min(1).optional(),ritual:z.boolean().optional(),inventory:z.boolean().optional()}).strict();var inlineOptionSchema=z.lazy(()=>z.object({value:z.string().min(1),label:z.string().min(1),description:z.string().optional(),effects:z.array(featureEffectSchema).optional(),choices:z.array(choiceSchema).optional()}).strict());var choiceSchema=z.lazy(()=>z.discriminatedUnion("kind",[z.object({kind:z.literal("select-inline"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive().optional(),options:z.array(inlineOptionSchema).nonempty()}).strict(),z.object({kind:z.literal("select-entity"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive().optional(),entity_type:z.string().min(1),from:z.array(z.string().min(1)).nonempty().optional(),where:entityFilterSchema.optional(),target:z.literal(true).optional()}).strict(),z.object({kind:z.literal("select-proficiency"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive(),domain:z.enum(["skill","tool","language","save"]),from:z.array(z.string().min(1)).nonempty().optional(),from_proficient:z.boolean().optional(),expertise:z.boolean().optional()}).strict(),z.object({kind:z.literal("ability-points"),id:z.string().min(1),label:z.string().optional(),points:z.number().int().positive(),max_per:z.number().int().positive(),pool:z.array(abilityEnum).nonempty().optional()}).strict()]));export{choiceSchema};
1
+ import{featureEffectSchema}from"./chunk-7TH4WPSU.js";import{z}from"zod";var abilityEnum=z.enum(["str","dex","con","int","wis","cha"]);var entityFilterSchema=z.object({feature_type:z.string().min(1).optional(),category:z.string().min(1).optional(),parent_class:z.literal("self").optional(),available_to:z.literal("self").optional(),weapon_category:z.enum(["simple","martial"]).optional(),armor_category:z.enum(["light","medium","heavy","shield"]).optional(),item_type:z.array(z.string().min(1)).nonempty().optional(),mundane:z.boolean().optional(),list:z.string().min(1).optional(),level:z.number().int().min(0).max(9).optional(),edition:z.string().min(1).optional(),ritual:z.boolean().optional(),inventory:z.boolean().optional()}).strict();var inlineOptionSchema=z.lazy(()=>z.object({value:z.string().min(1),label:z.string().min(1),description:z.string().optional(),effects:z.array(featureEffectSchema).optional(),choices:z.array(choiceSchema).optional()}).strict());var choiceSchema=z.lazy(()=>z.discriminatedUnion("kind",[z.object({kind:z.literal("select-inline"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive().optional(),options:z.array(inlineOptionSchema).nonempty()}).strict(),z.object({kind:z.literal("select-entity"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive().optional(),entity_type:z.string().min(1),from:z.array(z.string().min(1)).nonempty().optional(),where:entityFilterSchema.optional(),target:z.literal(true).optional()}).strict(),z.object({kind:z.literal("select-proficiency"),id:z.string().min(1),label:z.string().optional(),count:z.number().int().positive(),domain:z.enum(["skill","tool","language","save"]),from:z.array(z.string().min(1)).nonempty().optional(),from_proficient:z.boolean().optional(),expertise:z.boolean().optional()}).strict(),z.object({kind:z.literal("ability-points"),id:z.string().min(1),label:z.string().optional(),points:z.number().int().positive(),max_per:z.number().int().positive(),pool:z.array(abilityEnum).nonempty().optional()}).strict()]));export{choiceSchema};
@@ -1 +1 @@
1
- import{z}from"zod";var resetTriggerEnum=z.enum(["short-rest","long-rest","either","dawn","dusk","turn","round","custom"]);var actionCostEnum=z.enum(["action","bonus-action","reaction","free","special"]);var resourceSchema=z.object({id:z.string().min(1),name:z.string().min(1),max_formula:z.string().min(1),scales_at:z.array(z.object({level:z.number().int().positive(),max:z.string().min(1)}).strict()).optional(),die:z.object({base:z.string().min(1),scaling:z.record(z.string(),z.string()).optional()}).optional(),reset:resetTriggerEnum,consumes:z.object({resource:z.string().min(1),amount:z.number().int().positive()}).optional(),rendering_hint:z.string().optional(),surface:z.enum(["band","tab"]).optional(),equivalent_ids:z.array(z.string().min(1)).optional(),recovery:z.array(z.object({id:z.string().min(1),name:z.string().min(1),amount:z.union([z.number(),z.string()]),action:actionCostEnum.optional(),uses:z.number().int().nonnegative().optional(),reset:resetTriggerEnum,restores:z.enum(["uses","spell-slots"]).optional()})).optional()});var resourceConsumptionSchema=z.object({source:z.enum(["resource","class-column","attack-dice","spell-slots"]).optional(),resource:z.string().optional(),column:z.string().optional(),amount:z.number().int().positive(),amount_max:z.number().int().positive().optional(),expend_condition:z.enum(["roll_succeeds","roll_fails","target_takes_damage","always"]).optional(),free_uses:z.object({amount:z.number().int().positive(),reset:resetTriggerEnum,state_key:z.string().optional()}).optional()}).refine(c=>c.amount_max===void 0||c.amount_max>=c.amount,{path:["amount_max"],message:"amount_max must be >= amount"});export{resetTriggerEnum,actionCostEnum,resourceSchema,resourceConsumptionSchema};
1
+ import{z}from"zod";var resetTriggerEnum=z.enum(["short-rest","long-rest","either","dawn","dusk","turn","round","custom"]);var actionCostEnum=z.enum(["action","bonus-action","reaction","free","special"]);var resourceSchema=z.object({id:z.string().min(1),name:z.string().min(1),max_formula:z.string().min(1),scales_at:z.array(z.object({level:z.number().int().positive(),max:z.string().min(1)}).strict()).optional(),die:z.object({base:z.string().min(1),scaling:z.record(z.string(),z.string()).optional()}).optional(),reset:resetTriggerEnum,consumes:z.object({resource:z.string().min(1),amount:z.number().int().positive()}).optional(),rendering_hint:z.string().optional(),surface:z.enum(["band","tab"]).optional(),equivalent_ids:z.array(z.string().min(1)).optional(),recovery:z.array(z.object({id:z.string().min(1),name:z.string().min(1),amount:z.union([z.number(),z.string()]),action:actionCostEnum.optional(),uses:z.number().int().nonnegative().optional(),reset:resetTriggerEnum,restores:z.enum(["uses","spell-slots"]).optional()})).optional()});var resourceConsumptionSchema=z.object({source:z.enum(["resource","class-column","attack-dice","spell-slots"]).optional(),resource:z.string().optional(),column:z.string().optional(),amount:z.number().int().positive(),amount_max:z.number().int().positive().optional(),expend_condition:z.enum(["roll_succeeds","roll_fails","target_takes_damage","always"]).optional(),free_uses:z.object({amount:z.number().int().positive(),reset:resetTriggerEnum,state_key:z.string().optional()}).optional(),for_feature:z.string().min(1).optional()}).refine(c=>c.amount_max===void 0||c.amount_max>=c.amount,{path:["amount_max"],message:"amount_max must be >= amount"});export{resetTriggerEnum,actionCostEnum,resourceSchema,resourceConsumptionSchema};
@@ -1 +1 @@
1
- import{isConsumedOnUse,itemSpellUse,resolveEntryEntity}from"./chunk-E4E6YEN6.js";import{isReadOnceItem}from"./chunk-DVUXUIPV.js";import{requiresAttunement}from"./chunk-YGH7S5ZF.js";import{resolveEntityForEntry}from"./chunk-4IAMSRHD.js";import{featureEffectSchema}from"./chunk-EON7T2SN.js";var linkSlug=item=>{var _a,_b;return(_b=(_a=/^\[\[(.+?)(\|.*)?\]\]$/.exec(item.trim()))==null?void 0:_a[1])!=null?_b:null};function itemBenefitsActive(entry,entity,registry,view){var _a;if(!entry.equipped)return false;if(requiresAttunement(entity)&&entry.attuned!==true)return false;if(isConsumedOnUse(entry,registry,view))return false;const slug=entity==null?void 0:entity.slug;if(isReadOnceItem(typeof slug==="string"&&slug?slug:(_a=linkSlug(entry.item))!=null?_a:entry.item))return false;return true}function itemSpellCastable(entry,registry,view){const use=itemSpellUse(entry,registry,view);if(!use||!registry)return false;if(use.kind==="consume")return true;const entity=view?view.entity:resolveEntityForEntry(entry.item,registry).entity;return itemBenefitsActive(entry,entity,registry,view)}function itemLabel(entry,entity){var _a,_b,_c,_d;return(_d=(_a=entry.overrides)==null?void 0:_a.name)!=null?_d:String((_c=(_b=entity==null?void 0:entity.name)!=null?_b:linkSlug(entry.item))!=null?_c:entry.item)}var ITEM_ROW_KINDS=new Set(["damage-bonus","crit-range","reroll-damage","extra-attack","weapon-ability","attack-rule"]);var GATE_VERB="(?:wear|wearing|hold|holding|wield|wielding)";var GATE_SUBJECT="(?:you |you're |you are )?";var ITEM_NAME="([a-z][a-z'-]*(?: [a-z][a-z'-]*){0,2})";var GATE_OBJECT=`(?:it|them|(?:this|these|the) ${ITEM_NAME})`;var GATE_PHRASES=[new RegExp(`^while ${GATE_SUBJECT}${GATE_VERB}(?: or ${GATE_VERB})? ${GATE_OBJECT}$`),new RegExp(`^while ${GATE_SUBJECT}attuned to ${GATE_OBJECT}$`),/^while (?:(?:it is|it's|they are) )?(?:worn|held|wielded)$/,new RegExp(`^while (?:this|the) ${ITEM_NAME} orbits your head$`)];var NOT_AN_ITEM_NAME=new Set(["and","or","with","without","in","on","at","of","to","from","while","when","if","but","against","within","near","until","during","for","is","are","you","your"]);function restatesItemGate(text){const t=(text!=null?text:"").replace(/’/g,"'").trim().toLowerCase().replace(/\s+/g," ").replace(/[.,;:]+$/,"");for(const re of GATE_PHRASES){const m=re.exec(t);if(!m)continue;if(m[1]!==void 0&&m[1].split(" ").some(w=>NOT_AN_ITEM_NAME.has(w)))continue;return true}return false}function withoutGateRestatement(e){if(e.kind==="apply-condition"||e.kind==="immune-condition")return e;if(!("condition"in e)||!restatesItemGate(e.condition))return e;const copy={...e};delete copy.condition;return copy}function readItemEffects(entity){const raw=entity==null?void 0:entity.effects;const effects=[];const invalid=[];if(!Array.isArray(raw))return{effects,invalid};for(const e of raw){const parsed=featureEffectSchema.safeParse(e);if(parsed.success)effects.push(withoutGateRestatement(parsed.data));else invalid.push(typeof(e==null?void 0:e.kind)==="string"?String(e.kind):"unknown")}return{effects,invalid}}function itemRowEffects(entity){return readItemEffects(entity).effects.filter(e=>ITEM_ROW_KINDS.has(e.kind))}function buildItemFeatures(equipment,registry,infusions,warnings){const out=[];if(typeof registry.getBySlug!=="function")return out;equipment.forEach((entry,index)=>{var _a,_b;if(!entry.equipped)return;const{entity,entityType}=resolveEntryEntity(entry,index,registry,infusions);if(!entity||entityType!=="item")return;if(!itemBenefitsActive(entry,entity,registry,infusions==null?void 0:infusions.views.get(index)))return;const{effects,invalid}=readItemEffects(entity);const name=itemLabel(entry,entity);if(invalid.length){warnings.push(`${name}: the sheet cannot read ${invalid.length===1?"this effect":"these effects"} (${invalid.join(", ")}); ignored.`)}const own=effects.filter(e=>!ITEM_ROW_KINDS.has(e.kind));if(own.length===0)return;const slug=String((_b=(_a=entity.slug)!=null?_a:linkSlug(entry.item))!=null?_b:entry.item);out.push({feature:{id:`item:${index}:${slug}`,name,activatable:false,effects:own},source:{kind:"item",slug,index}})});return out}export{itemBenefitsActive,itemSpellCastable,itemLabel,ITEM_ROW_KINDS,restatesItemGate,readItemEffects,itemRowEffects,buildItemFeatures};
1
+ import{isConsumedOnUse,itemSpellUse,resolveEntryEntity}from"./chunk-7S4VMK3R.js";import{isReadOnceItem}from"./chunk-DVUXUIPV.js";import{requiresAttunement}from"./chunk-YGH7S5ZF.js";import{resolveEntityForEntry}from"./chunk-4IAMSRHD.js";import{featureEffectSchema}from"./chunk-7TH4WPSU.js";var linkSlug=item=>{var _a,_b;return(_b=(_a=/^\[\[(.+?)(\|.*)?\]\]$/.exec(item.trim()))==null?void 0:_a[1])!=null?_b:null};function itemBenefitsActive(entry,entity,registry,view){var _a;if(!entry.equipped)return false;if(requiresAttunement(entity)&&entry.attuned!==true)return false;if(isConsumedOnUse(entry,registry,view))return false;const slug=entity==null?void 0:entity.slug;if(isReadOnceItem(typeof slug==="string"&&slug?slug:(_a=linkSlug(entry.item))!=null?_a:entry.item))return false;return true}function itemSpellCastable(entry,registry,view){const use=itemSpellUse(entry,registry,view);if(!use||!registry)return false;if(use.kind==="consume")return true;const entity=view?view.entity:resolveEntityForEntry(entry.item,registry).entity;return itemBenefitsActive(entry,entity,registry,view)}function itemLabel(entry,entity){var _a,_b,_c,_d;return(_d=(_a=entry.overrides)==null?void 0:_a.name)!=null?_d:String((_c=(_b=entity==null?void 0:entity.name)!=null?_b:linkSlug(entry.item))!=null?_c:entry.item)}var ITEM_ROW_KINDS=new Set(["damage-bonus","crit-range","reroll-damage","extra-attack","weapon-ability","attack-rule"]);var GATE_VERB="(?:wear|wearing|hold|holding|wield|wielding)";var GATE_SUBJECT="(?:you |you're |you are )?";var ITEM_NAME="([a-z][a-z'-]*(?: [a-z][a-z'-]*){0,2})";var GATE_OBJECT=`(?:it|them|(?:this|these|the) ${ITEM_NAME})`;var GATE_PHRASES=[new RegExp(`^while ${GATE_SUBJECT}${GATE_VERB}(?: or ${GATE_VERB})? ${GATE_OBJECT}$`),new RegExp(`^while ${GATE_SUBJECT}attuned to ${GATE_OBJECT}$`),/^while (?:(?:it is|it's|they are) )?(?:worn|held|wielded)$/,new RegExp(`^while (?:this|the) ${ITEM_NAME} orbits your head$`)];var NOT_AN_ITEM_NAME=new Set(["and","or","with","without","in","on","at","of","to","from","while","when","if","but","against","within","near","until","during","for","is","are","you","your"]);function restatesItemGate(text){const t=(text!=null?text:"").replace(/’/g,"'").trim().toLowerCase().replace(/\s+/g," ").replace(/[.,;:]+$/,"");for(const re of GATE_PHRASES){const m=re.exec(t);if(!m)continue;if(m[1]!==void 0&&m[1].split(" ").some(w=>NOT_AN_ITEM_NAME.has(w)))continue;return true}return false}function withoutGateRestatement(e){if(e.kind==="apply-condition"||e.kind==="immune-condition")return e;if(!("condition"in e)||!restatesItemGate(e.condition))return e;const copy={...e};delete copy.condition;return copy}function readItemEffects(entity){const raw=entity==null?void 0:entity.effects;const effects=[];const invalid=[];if(!Array.isArray(raw))return{effects,invalid};for(const e of raw){const parsed=featureEffectSchema.safeParse(e);if(parsed.success)effects.push(withoutGateRestatement(parsed.data));else invalid.push(typeof(e==null?void 0:e.kind)==="string"?String(e.kind):"unknown")}return{effects,invalid}}function itemRowEffects(entity){return readItemEffects(entity).effects.filter(e=>ITEM_ROW_KINDS.has(e.kind))}function buildItemFeatures(equipment,registry,infusions,warnings){const out=[];if(typeof registry.getBySlug!=="function")return out;equipment.forEach((entry,index)=>{var _a,_b;if(!entry.equipped)return;const{entity,entityType}=resolveEntryEntity(entry,index,registry,infusions);if(!entity||entityType!=="item")return;if(!itemBenefitsActive(entry,entity,registry,infusions==null?void 0:infusions.views.get(index)))return;const{effects,invalid}=readItemEffects(entity);const name=itemLabel(entry,entity);if(invalid.length){warnings.push(`${name}: the sheet cannot read ${invalid.length===1?"this effect":"these effects"} (${invalid.join(", ")}); ignored.`)}const own=effects.filter(e=>!ITEM_ROW_KINDS.has(e.kind));if(own.length===0)return;const slug=String((_b=(_a=entity.slug)!=null?_a:linkSlug(entry.item))!=null?_b:entry.item);out.push({feature:{id:`item:${index}:${slug}`,name,activatable:false,effects:own},source:{kind:"item",slug,index}})});return out}export{itemBenefitsActive,itemSpellCastable,itemLabel,ITEM_ROW_KINDS,restatesItemGate,readItemEffects,itemRowEffects,buildItemFeatures};
@@ -1 +1 @@
1
- import{raceEntitySchema}from"./chunk-D2BXAFOL.js";import{aliasFeatureListActionCost}from"./chunk-S5UCI27C.js";import{parseYaml}from"@archivist-gg/core";function parseRace(source){const raw=parseYaml(source,["name","slug"]);if(!raw.success)return raw;aliasFeatureListActionCost(raw.data.traits);const result=raceEntitySchema.safeParse({edition:"2014",...raw.data});if(!result.success){return{success:false,error:`race schema validation failed: ${result.error.message}`}}return{success:true,data:result.data}}export{parseRace};
1
+ import{raceEntitySchema}from"./chunk-Q2U7MWMC.js";import{aliasFeatureListActionCost}from"./chunk-S5UCI27C.js";import{parseYaml}from"@archivist-gg/core";function parseRace(source){const raw=parseYaml(source,["name","slug"]);if(!raw.success)return raw;aliasFeatureListActionCost(raw.data.traits);const result=raceEntitySchema.safeParse({edition:"2014",...raw.data});if(!result.success){return{success:false,error:`race schema validation failed: ${result.error.message}`}}return{success:true,data:result.data}}export{parseRace};
@@ -1 +1 @@
1
- import{classCodec}from"../chunk-C4T6BUSP.js";import"../chunk-7HOOPNF5.js";import"../chunk-S5UCI27C.js";import"../chunk-ADX7435T.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-M2UA2FAK.js";import"../chunk-ZE46ADXS.js";import"../chunk-CCFIINBA.js";import"../chunk-TKIEPC6F.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{classCodec};
1
+ import{classCodec}from"../chunk-RI4YYU75.js";import"../chunk-FDWQ6P7Z.js";import"../chunk-S5UCI27C.js";import"../chunk-655UY3MP.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-FC4OPNZM.js";import"../chunk-ZE46ADXS.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-TKIEPC6F.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{classCodec};
@@ -1 +1 @@
1
- import{parseClass}from"../chunk-7HOOPNF5.js";import"../chunk-S5UCI27C.js";import"../chunk-ADX7435T.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-M2UA2FAK.js";import"../chunk-ZE46ADXS.js";import"../chunk-CCFIINBA.js";import"../chunk-TKIEPC6F.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{parseClass};
1
+ import{parseClass}from"../chunk-FDWQ6P7Z.js";import"../chunk-S5UCI27C.js";import"../chunk-655UY3MP.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-FC4OPNZM.js";import"../chunk-ZE46ADXS.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-TKIEPC6F.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{parseClass};
@@ -1 +1 @@
1
- import{classEntitySchema}from"../chunk-ADX7435T.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-M2UA2FAK.js";import"../chunk-ZE46ADXS.js";import"../chunk-CCFIINBA.js";import"../chunk-TKIEPC6F.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{classEntitySchema};
1
+ import{classEntitySchema}from"../chunk-655UY3MP.js";import"../chunk-GCYUCIDN.js";import"../chunk-X22SISGM.js";import"../chunk-FC4OPNZM.js";import"../chunk-ZE46ADXS.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-TKIEPC6F.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{classEntitySchema};
@@ -1,2 +1,3 @@
1
1
  export declare function bareSlug(ref: string): string;
2
2
  export declare function baseClassName(ref: string): string;
3
+ export declare function matchesSpellClass(word: string | undefined, classSlug: string | null | undefined): boolean;
@@ -1 +1 @@
1
- import{bareSlug,baseClassName}from"../chunk-CAPYNIGK.js";export{bareSlug,baseClassName};
1
+ import{bareSlug,baseClassName,matchesSpellClass}from"../chunk-4F5F5A3X.js";export{bareSlug,baseClassName,matchesSpellClass};
@@ -1 +1 @@
1
- import{featCodec}from"../chunk-GKNOCYDT.js";import"../chunk-EBFLUJIW.js";import"../chunk-AFEWQFQZ.js";import"../chunk-CCFIINBA.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{featCodec};
1
+ import{featCodec}from"../chunk-IK7XM6BW.js";import"../chunk-A25HLCQ7.js";import"../chunk-QCCA46KM.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{featCodec};
@@ -1 +1 @@
1
- import{parseFeat}from"../chunk-EBFLUJIW.js";import"../chunk-AFEWQFQZ.js";import"../chunk-CCFIINBA.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{parseFeat};
1
+ import{parseFeat}from"../chunk-A25HLCQ7.js";import"../chunk-QCCA46KM.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{parseFeat};
@@ -316,6 +316,7 @@ export declare const featEntitySchema: z.ZodObject<{
316
316
  any: "any";
317
317
  }>;
318
318
  scope: z.ZodOptional<z.ZodString>;
319
+ spell_class: z.ZodOptional<z.ZodString>;
319
320
  condition: z.ZodOptional<z.ZodString>;
320
321
  subject: z.ZodOptional<z.ZodString>;
321
322
  }, z.core.$strip>, z.ZodObject<{
@@ -374,6 +375,17 @@ export declare const featEntitySchema: z.ZodObject<{
374
375
  }>;
375
376
  condition: z.ZodOptional<z.ZodString>;
376
377
  subject: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$strip>, z.ZodObject<{
379
+ kind: z.ZodLiteral<"spell-bonus">;
380
+ save_dc: z.ZodOptional<z.ZodNumber>;
381
+ attack: z.ZodOptional<z.ZodNumber>;
382
+ spell_class: z.ZodOptional<z.ZodString>;
383
+ subject: z.ZodOptional<z.ZodString>;
384
+ }, z.core.$strip>, z.ZodObject<{
385
+ kind: z.ZodLiteral<"extra-cantrips">;
386
+ count: z.ZodNumber;
387
+ class: z.ZodOptional<z.ZodString>;
388
+ subject: z.ZodOptional<z.ZodString>;
377
389
  }, z.core.$strip>, z.ZodObject<{
378
390
  kind: z.ZodLiteral<"damage-roll-option">;
379
391
  mode: z.ZodEnum<{
@@ -1 +1 @@
1
- import{featEntitySchema}from"../chunk-AFEWQFQZ.js";import"../chunk-CCFIINBA.js";import"../chunk-VHIE2KYQ.js";import"../chunk-EON7T2SN.js";import"../chunk-I26FHSI6.js";export{featEntitySchema};
1
+ import{featEntitySchema}from"../chunk-QCCA46KM.js";import"../chunk-ZKDHCDJ2.js";import"../chunk-ZK3P4RSE.js";import"../chunk-7TH4WPSU.js";import"../chunk-I26FHSI6.js";export{featEntitySchema};