@archivist-gg/dnd5e 0.3.6 → 0.3.7

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.
@@ -193,6 +193,15 @@ var characterStateSchema = z.object({
193
193
  used: z.number().int().nonnegative(),
194
194
  max: z.number().int().nonnegative()
195
195
  })).default({}),
196
+ // R4-G5 G8 (research D §3.3, the booked design): banked PREROLLED dice, keyed by the SAME id as
197
+ // feature_uses (the resource id, e.g. "wizard-2024:foretelling-roll" for Portent). SIGN IS STATE
198
+ // (the G8 shuffle fix): a value is stored NEGATIVE while spent, positive while live, so positions
199
+ // are STABLE and "spend the right-hand roll" never reorders the bank (the earlier spent-prefix
200
+ // shape moved a spent value into a prefix and visibly shuffled its neighbours). The count axis
201
+ // stays on feature_uses (the tracker remains the single source of how many are left); the
202
+ // writers on the plugin edit state keep the sign set and `used` in step. Without this line a
203
+ // non-strict parse STRIPS the key and the rolls never survive a load.
204
+ feature_rolls: z.record(z.string(), z.array(z.number().int().refine((n) => n !== 0 && Math.abs(n) <= 999, "banked rolls are nonzero, |value| 1..999"))).default({}),
196
205
  // Phase 3 activatable buffs: ids/slugs of activatable features/boons that are
197
206
  // currently toggled on. Their effects fold into recalc only while listed here.
198
207
  active_buffs: z.array(z.string()).optional(),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  characterSchema
3
- } from "../chunk-E4KG7HXO.js";
3
+ } from "../chunk-PZCE7DJM.js";
4
4
  import "../chunk-S7REMWW4.js";
5
5
 
6
6
  // src/pc/pc.parser.ts
@@ -65,7 +65,7 @@ function pushBuffEnds(cats, character, resolved) {
65
65
  }
66
66
  }
67
67
  function computeRestPlan(character, resolved, derived, registry, type) {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
69
69
  const cats = [];
70
70
  let hdRegainDist;
71
71
  const index = resolveResourceIndex(resolved);
@@ -128,14 +128,17 @@ function computeRestPlan(character, resolved, derived, registry, type) {
128
128
  }
129
129
  }
130
130
  for (const [key, fu] of Object.entries((_f = character.state.feature_uses) != null ? _f : {})) {
131
- if (fu.used <= 0) continue;
131
+ const banked = (_g = character.state.feature_rolls) == null ? void 0 : _g[key];
132
+ const bankedRolls = banked ? banked.filter((v) => v > 0).length : 0;
133
+ if (fu.used <= 0 && bankedRolls <= 0) continue;
132
134
  const res = index.get(key);
133
- const reset = (_g = res == null ? void 0 : res.reset) != null ? _g : "long-rest";
135
+ const reset = (_h = res == null ? void 0 : res.reset) != null ? _h : "long-rest";
134
136
  if (reset !== "short-rest" && reset !== "long-rest" && reset !== "either" && reset !== "dawn" && reset !== "dusk") continue;
137
+ const rollsNote = bankedRolls > 0 ? ` \xB7 ${bankedRolls} roll${bankedRolls === 1 ? "" : "s"} cleared` : "";
135
138
  cats.push({
136
139
  id: `feature:${key}`,
137
- label: (_h = res == null ? void 0 : res.name) != null ? _h : key,
138
- preview: `${fu.used}/${fu.max} restored`
140
+ label: (_i = res == null ? void 0 : res.name) != null ? _i : key,
141
+ preview: `${fu.used}/${fu.max} restored${rollsNote}`
139
142
  });
140
143
  }
141
144
  pushPartialRecoveries(cats, character, index, "long");
@@ -155,15 +158,18 @@ function computeRestPlan(character, resolved, derived, registry, type) {
155
158
  });
156
159
  }
157
160
  if (type === "short") {
158
- for (const [key, fu] of Object.entries((_i = character.state.feature_uses) != null ? _i : {})) {
159
- if (fu.used <= 0) continue;
161
+ for (const [key, fu] of Object.entries((_j = character.state.feature_uses) != null ? _j : {})) {
162
+ const banked = (_k = character.state.feature_rolls) == null ? void 0 : _k[key];
163
+ const bankedRolls = banked ? banked.filter((v) => v > 0).length : 0;
164
+ if (fu.used <= 0 && bankedRolls <= 0) continue;
160
165
  const res = index.get(key);
161
- const r = (_j = res == null ? void 0 : res.reset) != null ? _j : "long-rest";
166
+ const r = (_l = res == null ? void 0 : res.reset) != null ? _l : "long-rest";
162
167
  if (r !== "short-rest" && r !== "either") continue;
168
+ const rollsNote = bankedRolls > 0 ? ` \xB7 ${bankedRolls} roll${bankedRolls === 1 ? "" : "s"} cleared` : "";
163
169
  cats.push({
164
170
  id: `feature:${key}`,
165
- label: (_k = res == null ? void 0 : res.name) != null ? _k : key,
166
- preview: `${fu.used}/${fu.max} restored`
171
+ label: (_m = res == null ? void 0 : res.name) != null ? _m : key,
172
+ preview: `${fu.used}/${fu.max} restored${rollsNote}`
167
173
  });
168
174
  }
169
175
  pushPartialRecoveries(cats, character, index, "short");
@@ -183,7 +189,7 @@ function computeRestPlan(character, resolved, derived, registry, type) {
183
189
  });
184
190
  }
185
191
  pushBuffEnds(cats, character, resolved);
186
- const hdAvailable = type === "short" ? Object.entries((_l = character.state.hit_dice) != null ? _l : {}).filter(([, hd]) => hd.used < hd.total).map(([die, hd]) => ({ die, remaining: hd.total - hd.used })) : [];
192
+ const hdAvailable = type === "short" ? Object.entries((_n = character.state.hit_dice) != null ? _n : {}).filter(([, hd]) => hd.used < hd.total).map(([die, hd]) => ({ die, remaining: hd.total - hd.used })) : [];
187
193
  return { type, categories: cats, hdAvailable, hdRegainDist };
188
194
  }
189
195
  export {
@@ -450,6 +450,7 @@ export declare const characterSchema: z.ZodObject<{
450
450
  used: z.ZodNumber;
451
451
  max: z.ZodNumber;
452
452
  }, z.core.$strip>>>;
453
+ feature_rolls: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>;
453
454
  active_buffs: z.ZodOptional<z.ZodArray<z.ZodString>>;
454
455
  attuned_items: z.ZodOptional<z.ZodArray<z.ZodString>>;
455
456
  }, z.core.$strip>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  characterOverridesShape,
3
3
  characterSchema
4
- } from "../chunk-E4KG7HXO.js";
4
+ } from "../chunk-PZCE7DJM.js";
5
5
  import "../chunk-S7REMWW4.js";
6
6
  export {
7
7
  characterOverridesShape,
@@ -217,6 +217,9 @@ export interface CharacterState {
217
217
  used: number;
218
218
  max: number;
219
219
  }>;
220
+ /** R4-G5 G8: banked prerolled dice, keyed by the SAME resource id as feature_uses.
221
+ * SIGN IS STATE: negative = spent, positive = live; positions never move. */
222
+ feature_rolls: Record<string, number[]>;
220
223
  /** Phase 3 activatable buffs: ids/slugs of activatable features/boons currently
221
224
  * toggled on. Their effects fold into recalc only while listed here. */
222
225
  active_buffs?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archivist-gg/dnd5e",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "license": "MIT AND CC-BY-4.0",
5
5
  "type": "module",
6
6
  "publishConfig": {