@archivist-gg/dnd5e 0.3.9 → 0.3.10

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.
@@ -0,0 +1,16 @@
1
+ // src/spell/casting-time.ts
2
+ function parseCastingTime(token) {
3
+ var _a;
4
+ const t = (_a = token == null ? void 0 : token.trim()) != null ? _a : "";
5
+ if (!t) return null;
6
+ if (/^(?:1\s*)?reaction\b/i.test(t)) return { kind: "reaction", count: 1 };
7
+ if (/^(?:1\s*)?bonus(?:[\s-]*action)?\b/i.test(t)) return { kind: "bonus", count: 1 };
8
+ if (/^(?:1\s*)?action\b/i.test(t)) return { kind: "action", count: 1 };
9
+ const m = /^(\d+)?[\s-]*(minute|min|hour|hr)s?\b/i.exec(t);
10
+ if (m) return { kind: "time", count: m[1] ? Number(m[1]) : 1, unit: /^h/i.test(m[2]) ? "hour" : "minute" };
11
+ return null;
12
+ }
13
+
14
+ export {
15
+ parseCastingTime
16
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The ONE reader of a spell's `casting_time` string. Every consumer (the plugin's compact Cast-table label,
3
+ * the add-drawer's filter bucket and its sort rank) goes through here, so a spelling that one of them
4
+ * understands the others understand too. Before this, each kept its own exact-string switch over the bundle's
5
+ * spellings (`action`, `bonus-action`, `1minute`), and they drifted: a converted or AI-generated spell's
6
+ * `1 action` / `10 minute` printed raw in the Cast table, and every vault spell spelled `bonus action`,
7
+ * `1 minute` or `1 hour` filtered as "special".
8
+ *
9
+ * The LEADING token decides. Prose after it (a reaction's trigger, Plant Growth's "or 8 hours") is left for
10
+ * the caller's tooltip and never matched, and the trailing word boundary stops a word that merely starts with
11
+ * a unit (`reactionary`, `bonuses`, `minuteman`) from reading as one. A count is optional and only meaningful
12
+ * for minutes and hours; `bonus` may drop the word `action`, which hand-authored spells do.
13
+ */
14
+ export type CastingTimeKind = "action" | "bonus" | "reaction" | "time";
15
+ export interface ParsedCastingTime {
16
+ kind: CastingTimeKind;
17
+ /** 1 for the action economy; the stated number of minutes / hours for `time` (1 when omitted). */
18
+ count: number;
19
+ /** Present only for `time`. */
20
+ unit?: "minute" | "hour";
21
+ }
22
+ export declare function parseCastingTime(token: string | undefined): ParsedCastingTime | null;
@@ -0,0 +1,6 @@
1
+ import {
2
+ parseCastingTime
3
+ } from "../chunk-W6GC6OKK.js";
4
+ export {
5
+ parseCastingTime
6
+ };
@@ -1,8 +1,8 @@
1
1
  import type { SpellCandidate } from "./spell.access.js";
2
2
  export type CastTimeCat = "action" | "bonus" | "reaction" | "long" | "special";
3
3
  export type RangeCat = "self" | "touch" | "ranged" | "special";
4
- /** Cast-time bucket from the stored token (mirrors compactCastingTime's set).
5
- * Rounds/minutes/hours fold into "long"; null/unknown → "special". */
4
+ /** Cast-time bucket, read through `parseCastingTime` (the same reader the Cast table's label uses, so the two
5
+ * cannot drift). Minutes/hours fold into "long"; unreadable or absent → "special". */
6
6
  export declare function castTimeCategory(token: string | undefined): CastTimeCat;
7
7
  /** Range bucket from the human range string. Honest read, documented buckets:
8
8
  * "Self…"→self, "Touch…"→touch, "<n> feet|ft"→ranged, else (mile/Sight/…)→special. */
@@ -1,24 +1,12 @@
1
+ import {
2
+ parseCastingTime
3
+ } from "../chunk-W6GC6OKK.js";
4
+
1
5
  // src/spell/spell.filter.ts
2
6
  function castTimeCategory(token) {
3
- switch (token) {
4
- case "action":
5
- return "action";
6
- case "bonus-action":
7
- return "bonus";
8
- case "reaction":
9
- return "reaction";
10
- case "minute":
11
- case "1minute":
12
- case "10minutes":
13
- case "hour":
14
- case "1hour":
15
- case "8hours":
16
- case "12hours":
17
- case "24hours":
18
- return "long";
19
- default:
20
- return "special";
21
- }
7
+ const parsed = parseCastingTime(token);
8
+ if (!parsed) return "special";
9
+ return parsed.kind === "time" ? "long" : parsed.kind;
22
10
  }
23
11
  function rangeCategory(range) {
24
12
  if (!range) return "special";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archivist-gg/dnd5e",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "license": "MIT AND CC-BY-4.0",
5
5
  "type": "module",
6
6
  "publishConfig": {