@scrthq/runlog 0.0.43 → 0.0.44

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 (2) hide show
  1. package/dist/runlog.js +33 -8
  2. package/package.json +1 -1
package/dist/runlog.js CHANGED
@@ -26448,13 +26448,15 @@ var Action = external_exports.lazy(
26448
26448
  do: external_exports.literal("modCounter").describe("Adjust a counter."),
26449
26449
  counter: Id.describe("Id of the counter to change."),
26450
26450
  by: external_exports.number().int().optional().describe("Amount to add; negative subtracts."),
26451
- set: external_exports.number().int().optional().describe("Absolute value to set, overriding `by`.")
26451
+ set: external_exports.number().int().optional().describe("Absolute value to set, overriding `by`."),
26452
+ setFrom: external_exports.string().min(1).optional().describe("Set it to a value bound earlier \u2014 a roll's total or a prompt's answer \u2014 by name. Overrides `by` and `set`.")
26452
26453
  }).strict().describe("Adjust a counter."),
26453
26454
  external_exports.object({
26454
26455
  do: external_exports.literal("modResource").describe("Adjust a resource."),
26455
26456
  resource: Id.describe("Id of the resource to change."),
26456
26457
  by: external_exports.number().int().optional().describe("Amount to add; negative spends."),
26457
- set: external_exports.number().int().optional().describe("Absolute value to set, overriding `by`.")
26458
+ set: external_exports.number().int().optional().describe("Absolute value to set, overriding `by`."),
26459
+ setFrom: external_exports.string().min(1).optional().describe("Set it to a value bound earlier \u2014 a roll's total or a prompt's answer \u2014 by name. Overrides `by` and `set`.")
26458
26460
  }).strict().describe("Adjust a resource, clamped to its declared min and max."),
26459
26461
  external_exports.object({
26460
26462
  do: external_exports.literal("grantCard").describe("Draw cards into the player's hand."),
@@ -26669,7 +26671,10 @@ var StateDef = external_exports.object({
26669
26671
  short: external_exports.string().max(8).optional().describe(
26670
26672
  "Compact form for embedding in the name of the thing itself \u2014 a file, a layer, a DAW track. Keep it very short, e.g. VF."
26671
26673
  ),
26672
- scope: external_exports.enum(["subject", "run"]).default("subject").describe("Whether this attaches to one subject or to the whole run."),
26674
+ scope: external_exports.enum(["subject", "run", "contestant"]).default("subject").describe(
26675
+ "Whether this attaches to one subject, to the whole run, or \u2014 in moderated play \u2014 to one contestant on the roster, marked by the moderator: spared from a curse, disqualified, and so on."
26676
+ ),
26677
+ until: external_exports.enum(["unitEnd"]).optional().describe("When the state lifts by itself. `unitEnd`: it is taken off everything it is on when the unit closes \u2014 a curse for this region, a cure for this region."),
26673
26678
  semantics: external_exports.array(
26674
26679
  external_exports.enum(["blocksEdit", "makesUntargetable", "excludesFromResult", "locksValue", "removesFromPlay"])
26675
26680
  ).optional().describe(
@@ -27259,6 +27264,7 @@ function lintPack(pack) {
27259
27264
  let usesResources = resourceIds.size > 0;
27260
27265
  let usesTimers = false;
27261
27266
  let usesResolveTarget = false;
27267
+ const movedCounters = /* @__PURE__ */ new Set();
27262
27268
  for (const site of collectActionSites(pack)) {
27263
27269
  walkActions(site.actions, (a) => {
27264
27270
  switch (a.do) {
@@ -27277,6 +27283,7 @@ function lintPack(pack) {
27277
27283
  if (!counterIds.has(a.counter)) {
27278
27284
  d.push(err("ref/unknown-counter", site.path, `references unknown counter ${a.counter}`));
27279
27285
  }
27286
+ movedCounters.add(a.counter);
27280
27287
  break;
27281
27288
  case "modResource":
27282
27289
  if (!resourceIds.has(a.resource)) {
@@ -27385,6 +27392,7 @@ function lintPack(pack) {
27385
27392
  if (typeof item !== "string" && item.tally && !counterIds.has(item.tally)) {
27386
27393
  d.push(err("ref/unknown-counter", `${path}.${field}[${ii}]`, `tallies unknown counter ${item.tally}`));
27387
27394
  }
27395
+ if (typeof item !== "string" && item.tally) movedCounters.add(item.tally);
27388
27396
  if (typeof item !== "string" && item.shows && !tableIds.has(item.shows.table)) {
27389
27397
  d.push(err("ref/unknown-table", `${path}.${field}[${ii}]`, `shows unknown table ${item.shows.table}`));
27390
27398
  }
@@ -27493,8 +27501,8 @@ function lintPack(pack) {
27493
27501
  d.push(err("ref/unknown-state", path, `hooks unknown state ${sel.state}`));
27494
27502
  }
27495
27503
  }
27496
- if (!counter.incrementOn?.length && !counter.triggers?.length) {
27497
- d.push(warn("counter/inert", path, "counter has no incrementOn and no triggers; nothing will ever change it"));
27504
+ if (!counter.incrementOn?.length && !counter.triggers?.length && !movedCounters.has(counterId)) {
27505
+ d.push(warn("counter/inert", path, "counter has no incrementOn, no triggers, and nothing moves it; it will never change"));
27498
27506
  }
27499
27507
  }
27500
27508
  if (pack.targeting?.strategy === "anchoredOffset") {
@@ -28422,8 +28430,8 @@ function rulebookDoc(pack) {
28422
28430
  ["State", "On", "Means"],
28423
28431
  states.map(([, s]) => [
28424
28432
  s.short ? `${s.label} (${s.short})` : s.label,
28425
- s.scope === "run" ? `the ${n.run}` : `a ${n.subject}`,
28426
- [s.description ?? "", ...(s.semantics ?? []).map(semanticInWords), s.group ? `Replaces any other \u201C${s.group}\u201D state.` : ""].filter(Boolean).join(" ")
28433
+ s.scope === "run" ? `the ${n.run}` : s.scope === "contestant" ? "a contestant" : `a ${n.subject}`,
28434
+ [s.description ?? "", ...(s.semantics ?? []).map(semanticInWords), s.group ? `Replaces any other \u201C${s.group}\u201D state.` : "", s.until === "unitEnd" ? `Lifts when the ${n.unit} closes.` : ""].filter(Boolean).join(" ")
28427
28435
  ])
28428
28436
  );
28429
28437
  }
@@ -28985,6 +28993,10 @@ function reduce(pack, log) {
28985
28993
  for (const subject of state.subjects) {
28986
28994
  if (subject.unit === state.unit) subject.finalized = true;
28987
28995
  }
28996
+ const lifts = (id) => pack.states?.[id]?.until === "unitEnd";
28997
+ state.runStates = state.runStates.filter((id) => !lifts(id));
28998
+ for (const subject of state.subjects) subject.states = subject.states.filter((id) => !lifts(id));
28999
+ for (const who of state.contestants) who.states = who.states.filter((id) => !lifts(id));
28988
29000
  break;
28989
29001
  }
28990
29002
  case "JournalWritten":
@@ -29020,12 +29032,25 @@ function reduce(pack, log) {
29020
29032
  break;
29021
29033
  case "ContestantAdded":
29022
29034
  if (!state.contestants.some((c) => c.id === event.contestant)) {
29023
- state.contestants.push({ id: event.contestant, name: event.name });
29035
+ state.contestants.push({ id: event.contestant, name: event.name, states: [] });
29024
29036
  }
29025
29037
  break;
29026
29038
  case "ContestantRemoved":
29027
29039
  state.contestants = state.contestants.filter((c) => c.id !== event.contestant);
29028
29040
  break;
29041
+ case "ContestantStateApplied": {
29042
+ const who = state.contestants.find((c) => c.id === event.contestant);
29043
+ if (!who) break;
29044
+ const group = pack.states?.[event.state]?.group;
29045
+ if (group) who.states = who.states.filter((s) => s === event.state || pack.states?.[s]?.group !== group);
29046
+ if (!who.states.includes(event.state)) who.states.push(event.state);
29047
+ break;
29048
+ }
29049
+ case "ContestantStateRemoved": {
29050
+ const who = state.contestants.find((c) => c.id === event.contestant);
29051
+ if (who) who.states = who.states.filter((s) => s !== event.state);
29052
+ break;
29053
+ }
29029
29054
  case "Awarded":
29030
29055
  if (!state.awards.some((a) => a.contestant === event.contestant && a.outcome === event.outcome)) {
29031
29056
  state.awards.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrthq/runlog",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "Validate, lint, bundle and test Runlog rule packs.",
5
5
  "type": "module",
6
6
  "license": "MIT",