rpg-engine 0.7.0 → 0.9.0

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 (397) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.js +13 -13
  4. package/dist/campaign/create-campaign.js +10 -1
  5. package/dist/campaign/host-files.d.ts +2 -1
  6. package/dist/campaign/host-files.js +11 -11
  7. package/dist/campaign/index.d.ts +1 -1
  8. package/dist/campaign/index.js +1 -1
  9. package/dist/campaign/settings.d.ts +55 -64
  10. package/dist/campaign/settings.js +171 -174
  11. package/dist/{cli.js → cli/cli.js} +3 -3
  12. package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
  13. package/dist/{command-line.js → cli/command-line.js} +21 -20
  14. package/dist/commands/advance.d.ts +1 -1
  15. package/dist/commands/advance.js +7 -7
  16. package/dist/commands/ask.d.ts +1 -8
  17. package/dist/commands/ask.js +16 -29
  18. package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
  19. package/dist/commands/{change.js → change/change.js} +46 -52
  20. package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
  21. package/dist/commands/{game-damage.js → change/damage.js} +3 -3
  22. package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
  23. package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
  24. package/dist/commands/config.d.ts +4 -4
  25. package/dist/commands/config.js +142 -138
  26. package/dist/commands/effect.d.ts +1 -1
  27. package/dist/commands/effect.js +11 -12
  28. package/dist/commands/find.d.ts +4 -4
  29. package/dist/commands/find.js +2 -2
  30. package/dist/commands/image.js +6 -6
  31. package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
  32. package/dist/commands/{import.js → import/import.js} +101 -101
  33. package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
  34. package/dist/commands/{game-import.js → import/run.js} +13 -12
  35. package/dist/commands/index.js +7 -7
  36. package/dist/commands/init.js +3 -3
  37. package/dist/commands/install.js +1 -1
  38. package/dist/commands/instructions.js +6 -6
  39. package/dist/commands/mode.d.ts +2 -2
  40. package/dist/commands/mode.js +8 -8
  41. package/dist/commands/mood.js +4 -4
  42. package/dist/commands/move.js +13 -20
  43. package/dist/commands/package.d.ts +2 -2
  44. package/dist/commands/package.js +138 -93
  45. package/dist/commands/rename.js +3 -3
  46. package/dist/commands/reveal.js +29 -18
  47. package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
  48. package/dist/commands/{roll.js → roll/roll.js} +69 -69
  49. package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
  50. package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
  51. package/dist/commands/rules.d.ts +2 -2
  52. package/dist/commands/rules.js +17 -9
  53. package/dist/commands/save.d.ts +1 -1
  54. package/dist/commands/save.js +18 -18
  55. package/dist/commands/scene.d.ts +4 -4
  56. package/dist/commands/scene.js +31 -28
  57. package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
  58. package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
  59. package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
  60. package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
  61. package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
  62. package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
  63. package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
  64. package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
  65. package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
  66. package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
  67. package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
  68. package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
  69. package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
  70. package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
  71. package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
  72. package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
  73. package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
  74. package/dist/commands/{game-events.js → shared/events.js} +20 -22
  75. package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
  76. package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
  77. package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
  78. package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
  79. package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
  80. package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
  81. package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
  82. package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
  83. package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
  84. package/dist/commands/{game-images.js → shared/images.js} +7 -6
  85. package/dist/commands/shared/inputs.d.ts +9 -0
  86. package/dist/commands/shared/inputs.js +12 -0
  87. package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
  88. package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
  89. package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
  90. package/dist/commands/{game-knowledge.js → shared/knowledge.js} +56 -44
  91. package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
  92. package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
  93. package/dist/commands/{game-library.js → shared/library.js} +70 -50
  94. package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
  95. package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
  96. package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
  97. package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
  98. package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
  99. package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
  100. package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
  101. package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
  102. package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
  103. package/dist/commands/{game-money.js → shared/money.js} +4 -4
  104. package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
  105. package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
  106. package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
  107. package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
  108. package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
  109. package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
  110. package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
  111. package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
  112. package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
  113. package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
  114. package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
  115. package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
  116. package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
  117. package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
  118. package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
  119. package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
  120. package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
  121. package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
  122. package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
  123. package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
  124. package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
  125. package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
  126. package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
  127. package/dist/commands/{parts.js → shared/parts.js} +4 -4
  128. package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
  129. package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
  130. package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
  131. package/dist/commands/{problems.js → shared/problems.js} +21 -22
  132. package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
  133. package/dist/commands/{progression.js → shared/progression.js} +4 -4
  134. package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
  135. package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
  136. package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
  137. package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
  138. package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
  139. package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
  140. package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
  141. package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
  142. package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +13 -5
  143. package/dist/commands/shared/rules.js +66 -0
  144. package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
  145. package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
  146. package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
  147. package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
  148. package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
  149. package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
  150. package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
  151. package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
  152. package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
  153. package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
  154. package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
  155. package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
  156. package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
  157. package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
  158. package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
  159. package/dist/commands/{game-time.js → shared/time.js} +6 -6
  160. package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
  161. package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
  162. package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
  163. package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
  164. package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
  165. package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
  166. package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
  167. package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
  168. package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
  169. package/dist/commands/{game-world.js → shared/world.js} +72 -76
  170. package/dist/commands/show.d.ts +4 -1
  171. package/dist/commands/show.js +36 -18
  172. package/dist/commands/status.d.ts +1 -1
  173. package/dist/commands/status.js +28 -28
  174. package/dist/commands/thoughts.js +3 -3
  175. package/dist/commands/trade.js +9 -10
  176. package/dist/commands/translate.d.ts +1 -1
  177. package/dist/commands/translate.js +3 -3
  178. package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
  179. package/dist/commands/{game-open.js → travel/open.js} +4 -5
  180. package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
  181. package/dist/commands/{route.js → travel/route.js} +9 -10
  182. package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
  183. package/dist/commands/{travel.js → travel/travel.js} +19 -21
  184. package/dist/commands/validate.js +5 -5
  185. package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
  186. package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
  187. package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
  188. package/dist/commands/{game-view-map.js → view/map.js} +15 -16
  189. package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
  190. package/dist/commands/{game-view-place.js → view/place.js} +108 -108
  191. package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
  192. package/dist/commands/{view.js → view/view.js} +41 -36
  193. package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
  194. package/dist/commands/{game-view-world.js → view/world.js} +7 -7
  195. package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
  196. package/dist/commands/{game-here.js → write/here.js} +18 -12
  197. package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
  198. package/dist/commands/{write.js → write/write.js} +44 -41
  199. package/dist/confirm/confirm.d.ts +2 -0
  200. package/dist/confirm/confirm.js +15 -5
  201. package/dist/core/consents.d.ts +3 -2
  202. package/dist/core/consents.js +43 -4
  203. package/dist/core/context.d.ts +8 -6
  204. package/dist/core/context.js +4 -2
  205. package/dist/core/download.js +16 -5
  206. package/dist/core/files.d.ts +8 -1
  207. package/dist/core/files.js +53 -21
  208. package/dist/core/formula.d.ts +7 -2
  209. package/dist/core/formula.js +63 -66
  210. package/dist/core/instruction-parts.js +1 -1
  211. package/dist/core/mood.d.ts +0 -1
  212. package/dist/core/mood.js +3 -3
  213. package/dist/core/package-api.d.ts +11 -0
  214. package/dist/core/package-api.js +2 -1
  215. package/dist/core/package-declarations.d.ts +9 -9
  216. package/dist/core/package-declarations.js +3 -3
  217. package/dist/core/process-mark.d.ts +8 -0
  218. package/dist/core/process-mark.js +72 -0
  219. package/dist/core/registry.d.ts +5 -0
  220. package/dist/core/registry.js +10 -0
  221. package/dist/core/session-store.d.ts +0 -1
  222. package/dist/core/session-store.js +11 -14
  223. package/dist/core/store.d.ts +4 -0
  224. package/dist/core/store.js +29 -8
  225. package/dist/core/text.d.ts +4 -0
  226. package/dist/core/text.js +11 -2
  227. package/dist/core/yaml-file.js +2 -2
  228. package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
  229. package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
  230. package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
  231. package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
  232. package/dist/dashboard/app.js +13 -13
  233. package/dist/dashboard/asked.js +1 -1
  234. package/dist/dashboard/dice/burn.js +1 -1
  235. package/dist/dashboard/dice/stage.js +1 -1
  236. package/dist/dashboard/game-words.js +4 -4
  237. package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
  238. package/dist/dashboard/{help.js → help/help.js} +6 -6
  239. package/dist/dashboard/journal.js +1 -1
  240. package/dist/dashboard/kit.js +6 -5
  241. package/dist/dashboard/labels.js +7 -3
  242. package/dist/dashboard/markdown.js +1 -1
  243. package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
  244. package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
  245. package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
  246. package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
  247. package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
  248. package/dist/dashboard/party.js +1 -1
  249. package/dist/dashboard/person-panel.js +2 -13
  250. package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
  251. package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
  252. package/dist/dashboard/scene.js +4 -4
  253. package/dist/dashboard/settings.js +1 -1
  254. package/dist/dashboard/sheet.js +4 -4
  255. package/dist/dashboard/text.js +6 -0
  256. package/dist/dashboard/top.js +2 -2
  257. package/dist/dashboard/turns.js +2 -2
  258. package/dist/dashboard/widgets.js +1 -1
  259. package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
  260. package/dist/dashboard/{lore.js → world/known.js} +1 -1
  261. package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
  262. package/dist/dashboard/{world-map.js → world/map.js} +1 -1
  263. package/dist/dashboard/{world.js → world/world.js} +14 -14
  264. package/dist/dice/evaluate.js +1 -1
  265. package/dist/dice/index.d.ts +2 -2
  266. package/dist/dice/index.js +2 -2
  267. package/dist/dice/notation.d.ts +2 -0
  268. package/dist/dice/notation.js +22 -4
  269. package/dist/documents/markup.js +2 -2
  270. package/dist/documents/read.js +29 -13
  271. package/dist/effects/effect.js +2 -5
  272. package/dist/extensions/extension.js +6 -8
  273. package/dist/extensions/index.d.ts +1 -4
  274. package/dist/extensions/index.js +1 -4
  275. package/dist/extensions/words.js +2 -1
  276. package/dist/{pictures → helpers}/briefs.js +17 -14
  277. package/dist/{pictures → helpers}/claude.js +8 -18
  278. package/dist/{pictures → helpers}/codex.js +3 -15
  279. package/dist/helpers/index.d.ts +7 -0
  280. package/dist/helpers/index.js +9 -0
  281. package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
  282. package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
  283. package/dist/images/images.js +7 -5
  284. package/dist/images/index.d.ts +1 -1
  285. package/dist/images/index.js +1 -1
  286. package/dist/importer/index.d.ts +1 -1
  287. package/dist/importer/index.js +1 -1
  288. package/dist/importer/work.d.ts +0 -2
  289. package/dist/importer/work.js +9 -30
  290. package/dist/instructions/index.d.ts +2 -0
  291. package/dist/instructions/index.js +10 -0
  292. package/dist/languages/index.d.ts +1 -1
  293. package/dist/languages/index.js +1 -1
  294. package/dist/languages/language-pack.js +15 -3
  295. package/dist/library/books.js +29 -83
  296. package/dist/{extensions → packages}/engine.d.ts +1 -1
  297. package/dist/{extensions → packages}/engine.js +1 -1
  298. package/dist/packages/index.d.ts +3 -0
  299. package/dist/packages/index.js +4 -0
  300. package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
  301. package/dist/{extensions/packages.js → packages/npm.js} +74 -45
  302. package/dist/page.d.ts +9 -11
  303. package/dist/page.js +1 -2
  304. package/dist/pages/check.js +31 -40
  305. package/dist/pages/containers.js +20 -20
  306. package/dist/pages/environment.js +15 -15
  307. package/dist/pages/index.d.ts +9 -9
  308. package/dist/pages/index.js +9 -9
  309. package/dist/pages/inheritance.d.ts +2 -1
  310. package/dist/pages/inheritance.js +24 -24
  311. package/dist/pages/load.js +7 -7
  312. package/dist/pages/maps.d.ts +20 -0
  313. package/dist/pages/maps.js +51 -1
  314. package/dist/pages/markdown.d.ts +2 -0
  315. package/dist/pages/markdown.js +110 -79
  316. package/dist/pages/page-file.d.ts +2 -1
  317. package/dist/pages/page-file.js +31 -29
  318. package/dist/pages/rename-page.d.ts +4 -1
  319. package/dist/pages/rename-page.js +7 -3
  320. package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
  321. package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
  322. package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
  323. package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
  324. package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
  325. package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
  326. package/dist/pages/system-pages.js +15 -15
  327. package/dist/pages/world.d.ts +4 -0
  328. package/dist/pages/world.js +52 -20
  329. package/dist/pages/write-page.js +35 -34
  330. package/dist/player-notes/index.d.ts +1 -1
  331. package/dist/player-notes/index.js +1 -1
  332. package/dist/rules/page-search.js +3 -4
  333. package/dist/rules/rule-book.js +1 -1
  334. package/dist/rules/search.js +21 -21
  335. package/dist/rules/shown.js +1 -3
  336. package/dist/saves/saves.d.ts +2 -2
  337. package/dist/saves/saves.js +15 -3
  338. package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
  339. package/dist/server/dashboard/files.d.ts +59 -0
  340. package/dist/server/dashboard/files.js +326 -0
  341. package/dist/server/dashboard/index.d.ts +114 -0
  342. package/dist/server/dashboard/index.js +419 -0
  343. package/dist/server/dashboard/news.d.ts +39 -0
  344. package/dist/server/dashboard/news.js +390 -0
  345. package/dist/server/dashboard/player.d.ts +48 -0
  346. package/dist/server/dashboard/player.js +242 -0
  347. package/dist/server/dashboard/ports.d.ts +10 -0
  348. package/dist/server/dashboard/ports.js +15 -0
  349. package/dist/server/dashboard/writes.d.ts +58 -0
  350. package/dist/server/dashboard/writes.js +492 -0
  351. package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
  352. package/dist/{mcp-server.js → server/mcp.js} +57 -42
  353. package/dist/systems/game-system.d.ts +5 -3
  354. package/dist/systems/game-system.js +178 -149
  355. package/dist/systems/index.d.ts +1 -1
  356. package/dist/systems/index.js +1 -1
  357. package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
  358. package/dist/{testing.js → testing/index.js} +32 -18
  359. package/dist/{system-checks.js → testing/system-checks.js} +18 -12
  360. package/dist/themes/theme.d.ts +3 -3
  361. package/dist/themes/theme.js +14 -14
  362. package/dist/time/calendar.js +5 -2
  363. package/dist/triggers/trigger.js +5 -8
  364. package/instructions/dashboard-guide.md +2 -1
  365. package/instructions/play.md +1 -1
  366. package/package.json +5 -5
  367. package/dist/commands/game-maps.d.ts +0 -20
  368. package/dist/commands/game-maps.js +0 -51
  369. package/dist/commands/game-rules.js +0 -36
  370. package/dist/dashboard-server.d.ts +0 -47
  371. package/dist/dashboard-server.js +0 -1830
  372. package/dist/pictures/index.d.ts +0 -7
  373. package/dist/pictures/index.js +0 -9
  374. /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
  375. /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
  376. /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
  377. /package/dist/commands/{notes.js → shared/notes.js} +0 -0
  378. /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
  379. /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
  380. /package/dist/dashboard/{people.js → packages/people.js} +0 -0
  381. /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
  382. /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
  383. /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
  384. /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
  385. /package/dist/{pictures → helpers}/chosen.js +0 -0
  386. /package/dist/{pictures → helpers}/claude.d.ts +0 -0
  387. /package/dist/{pictures → helpers}/codex.d.ts +0 -0
  388. /package/dist/{pictures → helpers}/stop.d.ts +0 -0
  389. /package/dist/{pictures → helpers}/stop.js +0 -0
  390. /package/dist/{pictures → helpers}/svg.d.ts +0 -0
  391. /package/dist/{pictures → helpers}/svg.js +0 -0
  392. /package/dist/{extensions → packages}/tarball.d.ts +0 -0
  393. /package/dist/{extensions → packages}/tarball.js +0 -0
  394. /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
  395. /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
  396. /package/dist/{player-acts.js → server/player-acts.js} +0 -0
  397. /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
@@ -1,16 +1,15 @@
1
1
  // A journey under way (D-258, TRV-8, TRV-9, TRV-12), kept in state.yaml under journey: what travels, where to or which way, where it stopped (on a road, or at
2
2
  // a point in the open), the pace, the hours travelled since the last rest.
3
- import { changeStateAt, readStateValues } from "../campaign/index.js";
4
- import { readLength } from "../core/length.js";
5
- import { comparableText } from "../core/text.js";
6
- import { pointAlong } from "../map/index.js";
7
- import { formatPosition, isEmptyField, locate, pagesWithName, parsePageReference, readPosition } from "../pages/index.js";
8
- import { formatDuration, formatGameDate, minutesBetween, readDuration, readGameDate } from "../time/index.js";
9
- import { mapOf } from "./game-maps.js";
10
- import { pointText, positionOf, regionAt } from "./game-positions.js";
11
- import { hoursText, lengthText } from "./game-roads.js";
3
+ import { changeStateAt, readStateValues } from "../../campaign/index.js";
4
+ import { readLength } from "../../core/length.js";
5
+ import { comparableText } from "../../core/text.js";
6
+ import { pointAlong } from "../../map/index.js";
7
+ import { formatPosition, isEmptyField, locate, mapOf, pagesWithName, parsePageReference, readPosition } from "../../pages/index.js";
8
+ import { formatDuration, formatGameDate, minutesBetween, readDuration, readGameDate } from "../../time/index.js";
9
+ import { pointText, positionOf, regionAt } from "./positions.js";
10
+ import { hoursText, lengthText } from "./roads.js";
12
11
  /** How long a stop must last for the hours of travel to start again (TRV-8): a night's rest. */
13
- export const restMinutes = 8 * 60;
12
+ const restMinutes = 8 * 60;
14
13
  /** The journey in state.yaml; none when there is none, or it does not read: then the next travel starts afresh. */
15
14
  export function readJourney(root) {
16
15
  let value;
@@ -154,16 +153,15 @@ export function journeyText(world, roads, journey, measures) {
154
153
  return stopped === undefined ? undefined : `stopped ${region === undefined ? "in the open" : `in ${region}`}, ${pointText(world, stopped, measures, map)}.`;
155
154
  }
156
155
  const onRoad = journey.on === undefined ? undefined : journeyStart(world, roads, journey, movers);
157
- const open = journey.at === undefined ? undefined : journeyPoint(world, journey, movers);
158
- if ((journey.on !== undefined && onRoad === undefined) || (journey.at !== undefined && open === undefined)) {
156
+ if ((journey.on !== undefined && onRoad === undefined) || (journey.at !== undefined && stopped === undefined)) {
159
157
  return undefined;
160
158
  }
161
159
  const goal = journey.to === undefined ? `${journey.heading}${journey.left === undefined ? "" : ` for ${lengthText(journey.left, measures)} more`}` : `to ${journey.to}`;
162
- const region = open === undefined ? undefined : regionAt(world, open, map)?.page.name;
160
+ const region = stopped === undefined ? undefined : regionAt(world, stopped, map)?.page.name;
163
161
  const where = journey.on !== undefined
164
162
  ? `, on ${journey.on.road}, ${lengthText(journey.on.done, measures)} past ${journey.on.from}, toward ${journey.on.toward}`
165
- : open !== undefined
166
- ? `, ${region === undefined ? "in the open" : `in ${region}`}, ${pointText(world, open, measures, map)}`
163
+ : stopped !== undefined
164
+ ? `, ${region === undefined ? "in the open" : `in ${region}`}, ${pointText(world, stopped, measures, map)}`
167
165
  : "";
168
166
  const call = journey.to === undefined ? `travel toward ${journey.heading}` : `travel to ${journey.to}${journey.at === undefined ? "" : ", across"}`;
169
167
  return `${goal}${where}; ${hoursText(journey.travelled)} of travel since the last rest. To go on: ${call}.`;
@@ -1,6 +1,6 @@
1
- import { type LogEntry } from "../core/log.ts";
2
- import { type Page, type World } from "../pages/index.ts";
3
- import type { Scene } from "../scene/index.ts";
1
+ import { type LogEntry } from "../../core/log.ts";
2
+ import { type Link, type Page, type World } from "../../pages/index.ts";
3
+ import type { Scene } from "../../scene/index.ts";
4
4
  /** What a character knows: the pages, and the secrets by the page that writes them. */
5
5
  export interface Knowledge {
6
6
  /** Whose knowledge it is: the player character, the one in the foreground when there are more (VIEW-12), or another character for the character agent voicing them (VIEW-10). */
@@ -13,11 +13,6 @@ export interface Knowledge {
13
13
  }
14
14
  /** The player character: the first living character with role pc, else the first dead one; undefined before there is one. */
15
15
  export declare function playerCharacter(world: World): Page | undefined;
16
- /**
17
- * The player character in the foreground (VIEW-12), whose place, map and squares the view shows: the one named; else, of the living, the one whose turn it is in
18
- * the open scene, then one in the open scene, then the first; else the first. Undefined before there is one.
19
- */
20
- export declare function foregroundCharacter(root: string, world: World, wanted?: string): Page | undefined;
21
16
  /**
22
17
  * What the player characters know (VIEW-12): with one, its knowledge; with more, what any of them knows, living or dead, with what each does, and the one in the
23
18
  * foreground as whose it is. Undefined before there is one.
@@ -74,6 +69,18 @@ export declare function playerStory(page: Page): string;
74
69
  export declare function knownPart(world: World, knowledge: Knowledge, page: Page, name: string): string | undefined;
75
70
  /** Whether a page's own text, not its bases', tells the character something: its introduction, or a section or secret of it the character may read (VIEW-3). */
76
71
  export declare function writesKnownText(knowledge: Knowledge, page: Page): boolean;
72
+ /** The links of a character's knows (REV-1), each with its page and the secret it names, as knownLink finds them. */
73
+ export declare function knownLinks(world: World, character: Page): KnownLink[];
74
+ /** A link of knows with its page and secret (REV-1), found as knownLinks finds them. */
75
+ export interface KnownLink {
76
+ name: string;
77
+ page?: Page;
78
+ secret?: string;
79
+ }
80
+ /** One link as knows means it: its page, by a name or an alias (D-417), and the secret it names; of two pages by one name, the one that writes the secret. */
81
+ export declare function knownLink(world: World, link: Link): KnownLink;
82
+ /** The texts of a field, one or a list, without what is not text. */
83
+ export declare function textList(value: unknown): string[];
77
84
  /** The log and the open scene, read once for what several characters lived. */
78
85
  interface LogRead {
79
86
  log: LogEntry[];
@@ -1,32 +1,14 @@
1
1
  // What a character knows, as the player's view and a character agent's read it (D-250, VIEW-2, VIEW-3, VIEW-10): the pages it knows and the text of each as it knows it;
2
2
  // with more than one player character, what any of them knows, and who (VIEW-12).
3
- import { readLog } from "../core/log.js";
4
- import { comparableText } from "../core/text.js";
5
- import { baseChain, inheritedByBase, introductionText, isPartyMember, isPlayerCharacter, links, locate, pagesWithNameOrAlias, parsePageReference, partContent, playerCharacters, readSection, secretNames, stacksOf, systemPageNamed, textParts, textsIn, withLinksAsWords, withoutComments, } from "../pages/index.js";
6
- import { readOpenScene } from "./game-scene.js";
3
+ import { readLog } from "../../core/log.js";
4
+ import { comparableText } from "../../core/text.js";
5
+ import { baseChain, inheritedByBase, introductionText, isPartyMember, isPlayerCharacter, links, locate, pagesWithNameOrAlias, parsePageReference, partContent, playerCharacters, readSection, secretNames, stacksOf, systemPageNamed, textParts, textsIn, withLinksAsWords, withoutComments, } from "../../pages/index.js";
6
+ import { readOpenScene } from "./scene.js";
7
7
  /** The player character: the first living character with role pc, else the first dead one; undefined before there is one. */
8
8
  export function playerCharacter(world) {
9
9
  const players = playerCharacters(world);
10
10
  return players.find((page) => page.fields.status !== "dead") ?? players[0];
11
11
  }
12
- /**
13
- * The player character in the foreground (VIEW-12), whose place, map and squares the view shows: the one named; else, of the living, the one whose turn it is in
14
- * the open scene, then one in the open scene, then the first; else the first. Undefined before there is one.
15
- */
16
- export function foregroundCharacter(root, world, wanted) {
17
- const players = playerCharacters(world);
18
- if (wanted !== undefined && wanted.trim() !== "") {
19
- const page = pagesWithNameOrAlias(world, parsePageReference(wanted).name).find(isPlayerCharacter);
20
- if (page === undefined) {
21
- throw new Error(`${wanted.trim()} is not a player character: give one of ${players.map((player) => player.name).join(", ") || "them, once there is one"}.`);
22
- }
23
- return page;
24
- }
25
- const living = players.filter((page) => page.fields.status !== "dead");
26
- const { scene } = readOpenScene(root);
27
- const named = (page, name) => name !== undefined && pagesWithNameOrAlias(world, parsePageReference(name).name)[0] === page;
28
- return living.find((page) => named(page, scene?.turn)) ?? living.find((page) => (scene?.with ?? []).some((link) => named(page, link))) ?? living[0] ?? players[0];
29
- }
30
12
  /**
31
13
  * What the player characters know (VIEW-12): with one, its knowledge; with more, what any of them knows, living or dead, with what each does, and the one in the
32
14
  * foreground as whose it is. Undefined before there is one.
@@ -100,8 +82,8 @@ export function knowsPage(knowledge, page) {
100
82
  */
101
83
  export function knownText(world, knowledge, page) {
102
84
  const parts = [
103
- ...partsOf(page),
104
- ...inheritedByBase(world, page).flatMap((group) => group.parts.map((part) => ({ ...part, holder: group.base }))),
85
+ ...readableParts(page),
86
+ ...inheritedByBase(world, page).flatMap((group) => readableInherited(group).map((part) => ({ ...part, holder: group.base }))),
105
87
  ].filter((part) => isShown(knowledge, page, part));
106
88
  return inKnownWords(world, knowledge, withoutComments([knownIntroduction(world, knowledge, page), ...parts.map((part) => part.text)].filter((text) => text !== "").join("\n\n")));
107
89
  }
@@ -115,7 +97,8 @@ export function knownSecretsApart(world, knowledge, page) {
115
97
  }
116
98
  /** A page's introduction as the character knows it (VIEW-3): its own, else that of its nearest base it knows; without comments. */
117
99
  export function knownIntroduction(world, knowledge, page) {
118
- const introduction = introductionText(page.body) || (baseChain(world, page).filter((base) => knowsPage(knowledge, base)).map((base) => introductionText(base.body)).find((text) => text !== "") ?? "");
100
+ const introduction = introductionText(page.translated ?? page.body)
101
+ || (baseChain(world, page).filter((base) => knowsPage(knowledge, base)).map((base) => introductionText(base.translated ?? base.body)).find((text) => text !== "") ?? "");
119
102
  return inKnownWords(world, knowledge, withoutComments(introduction));
120
103
  }
121
104
  /**
@@ -167,6 +150,44 @@ export function writesKnownText(knowledge, page) {
167
150
  const said = (text) => withoutComments(text ?? "").trim() !== "";
168
151
  return said(introductionText(page.body)) || partsOf(page).some((part) => isShown(knowledge, page, part) && said(partContent(page.body, part.name)?.content));
169
152
  }
153
+ /** The links of a character's knows (REV-1), each with its page and the secret it names, as knownLink finds them. */
154
+ export function knownLinks(world, character) {
155
+ return textsIn(character.fields.knows).flatMap(links).map((link) => knownLink(world, link));
156
+ }
157
+ /** One link as knows means it: its page, by a name or an alias (D-417), and the secret it names; of two pages by one name, the one that writes the secret. */
158
+ export function knownLink(world, link) {
159
+ const pages = pagesWithNameOrAlias(world, parsePageReference(link.page).name);
160
+ const wanted = link.section === undefined || link.section === "" ? undefined : comparableText(link.section);
161
+ for (const page of wanted === undefined ? [] : pages) {
162
+ const secret = secretNames(page.body).find((name) => comparableText(name) === wanted);
163
+ if (secret !== undefined) {
164
+ return { name: page.name, page, secret };
165
+ }
166
+ }
167
+ return { name: pages[0]?.name ?? link.page, ...(pages[0] === undefined ? {} : { page: pages[0] }), ...(link.section === undefined ? {} : { secret: link.section }) };
168
+ }
169
+ /** The texts of a field, one or a list, without what is not text. */
170
+ export function textList(value) {
171
+ return (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string");
172
+ }
173
+ /**
174
+ * The player character in the foreground (VIEW-12), whose place, map and squares the view shows: the one named; else, of the living, the one whose turn it is in
175
+ * the open scene, then one in the open scene, then the first; else the first. Undefined before there is one.
176
+ */
177
+ function foregroundCharacter(root, world, wanted) {
178
+ const players = playerCharacters(world);
179
+ if (wanted !== undefined && wanted.trim() !== "") {
180
+ const page = pagesWithNameOrAlias(world, parsePageReference(wanted).name).find(isPlayerCharacter);
181
+ if (page === undefined) {
182
+ throw new Error(`${wanted.trim()} is not a player character: give one of ${players.map((player) => player.name).join(", ") || "them, once there is one"}.`);
183
+ }
184
+ return page;
185
+ }
186
+ const living = players.filter((page) => page.fields.status !== "dead");
187
+ const { scene } = readOpenScene(root);
188
+ const named = (page, name) => name !== undefined && pagesWithNameOrAlias(world, parsePageReference(name).name)[0] === page;
189
+ return living.find((page) => named(page, scene?.turn)) ?? living.find((page) => (scene?.with ?? []).some((link) => named(page, link))) ?? living[0] ?? players[0];
190
+ }
170
191
  /** A text as the character may read it (VIEW-3): a link to a page it does not know, or to none, written as its words, so that no name tells the page exists. */
171
192
  function inKnownWords(world, knowledge, text) {
172
193
  return withLinksAsWords(text, (link) => [...pagesWithNameOrAlias(world, link.page), systemPageNamed(world, link.page)].some((page) => page !== undefined && knowsPage(knowledge, page)));
@@ -179,25 +200,19 @@ function isShown(knowledge, page, part) {
179
200
  function partsOf(page) {
180
201
  return textParts(page.body).map((part) => ({ ...part, holder: page }));
181
202
  }
182
- function isSecretText(text) {
183
- return /^[ \t]{0,3}>[ \t]*\[!secret\]/i.test(text);
203
+ /** A page's sections as the player reads them: a system's page in the campaign's language where it has it (D-542). */
204
+ function readableParts(page) {
205
+ return textParts(page.translated ?? page.body).map((part) => ({ ...part, holder: page }));
184
206
  }
185
207
  /**
186
- * The links of a character's knows (REV-1), each with its page, found by a name or an old one among its aliases (D-417), and the secret it names, as that page
187
- * writes it: of two pages by one name, the one that writes the secret.
208
+ * The sections a page inherits from a base as the player reads them: in the campaign's language when the base has it and every section of it reaches the page
209
+ * (D-542), as the stat block of a wolf for a companion; else as the base writes them, since a section the page has of its own hides one by its English name.
188
210
  */
189
- function knownLinks(world, character) {
190
- return textsIn(character.fields.knows).flatMap(links).map((link) => {
191
- const pages = pagesWithNameOrAlias(world, parsePageReference(link.page).name);
192
- const wanted = link.section === undefined || link.section === "" ? undefined : comparableText(link.section);
193
- for (const page of wanted === undefined ? [] : pages) {
194
- const secret = secretNames(page.body).find((name) => comparableText(name) === wanted);
195
- if (secret !== undefined) {
196
- return { name: page.name, page, secret };
197
- }
198
- }
199
- return { name: pages[0]?.name ?? link.page, ...(pages[0] === undefined ? {} : { page: pages[0] }), ...(link.section === undefined ? {} : { secret: link.section }) };
200
- });
211
+ function readableInherited(group) {
212
+ return group.base.translated !== undefined && group.parts.length === textParts(group.base.body).length ? textParts(group.base.translated) : group.parts;
213
+ }
214
+ function isSecretText(text) {
215
+ return /^[ \t]{0,3}>[ \t]*\[!secret\]/i.test(text);
201
216
  }
202
217
  /** The names of the player characters a test holds for, when more than one is played and not all of them pass it. */
203
218
  function knownApart(knowledge, knows) {
@@ -244,6 +259,3 @@ function placesAtDeath(read, world, page) {
244
259
  const holder = typeof from === "string" ? pagesWithNameOrAlias(world, parsePageReference(from).name)[0] : undefined;
245
260
  return moved === undefined ? locate(world, page).chain : holder === undefined ? [] : [holder, ...locate(world, holder).chain];
246
261
  }
247
- function textList(value) {
248
- return (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string");
249
- }
@@ -1,10 +1,10 @@
1
1
  // The reading of the player's books apart from the chat (D-491, LIB-3): rules and config start a process of its own, `rpg --read-library`, which reads each
2
2
  // book of this computer's library still to read, its PDF pages without readable text by the system's OCR, and writes its index; one at a time on a computer.
3
3
  import { spawn } from "node:child_process";
4
- import { libraryScope } from "./commands/game-library.js";
5
- import { defaultContext } from "./core/context.js";
6
- import { readDocument, systemPageReader } from "./documents/index.js";
7
- import { claimLibrary, dropUnlisted, libraryFolders, readLibrary, releaseLibrary } from "./library/index.js";
4
+ import { defaultContext } from "../../core/context.js";
5
+ import { readDocument, systemPageReader } from "../../documents/index.js";
6
+ import { claimLibrary, dropUnlisted, libraryFolders, readLibrary, releaseLibrary } from "../../library/index.js";
7
+ import { libraryScope } from "./library.js";
8
8
  // The argument of the command line that reads the library, as cli.ts takes it: not a command, only what rules starts.
9
9
  const readLibraryArgument = "--read-library";
10
10
  /** Starts the reading of the library apart, by the command line this process runs, outliving the chat: what Context.readLibrary is where a player sits. */
@@ -1,5 +1,5 @@
1
- import type { Context } from "../core/context.ts";
2
- import { type LibraryScope, type LibraryState } from "../library/index.ts";
1
+ import type { Context } from "../../core/context.ts";
2
+ import { type LibraryScope, type LibraryState } from "../../library/index.ts";
3
3
  /** What rules shows of the player's books (LIB-7). */
4
4
  export interface LibraryAnswer {
5
5
  /** The languages the books are in, by name, such as Italian. */
@@ -41,8 +41,11 @@ export declare function libraryAdditions(root: string, context: Context, given:
41
41
  * their books' text, and only those the campaign holds are turned off. Refused for one neither holds.
42
42
  */
43
43
  export declare function libraryRemovals(root: string, context: Context, given: string[], computer: boolean): string[];
44
- /** The campaign's library as it is used: the entries it turns on that are in this computer's library, which the player allowed (LIB-1). */
45
- export declare function campaignLibrary(root: string, context: Context): string[];
44
+ /**
45
+ * The entries to turn off as full paths, before anything is written (LIB-1): refused for one the campaign does not hold, or with `computer` for one neither the
46
+ * campaign nor this computer's library holds.
47
+ */
48
+ export declare function checkLibraryRemovals(root: string, context: Context, given: string[], computer: boolean): string[];
46
49
  /**
47
50
  * An entry of the library as config and the dashboard show it (LIB-5, D-491 (13)): its books read and those still being read, those skipped with why, whether
48
51
  * it is there now and whether it holds more than a library takes; whether this campaign uses it, and whether it is in this computer's library.
@@ -1,14 +1,14 @@
1
1
  // The player's library as the commands use it (D-491): the entries config adds, checked and allowed by the player; what config shows of each; and what rules
2
2
  // finds in the books, after the game system's rules.
3
3
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
4
- import { campaignFileName, findCampaign, readListSetting, readTextSetting } from "../campaign/index.js";
5
- import { comparableText } from "../core/text.js";
6
- import { documentAt, documentKinds } from "../documents/index.js";
7
- import { dropUnlisted, foldersIn, isWithin, libraryFolders, libraryReader, libraryState, mostBooks, samePath, saveLibraryFolders } from "../library/index.js";
8
- import { bookHeadings, findPages, hasAllWords, pageExcerpt, pageTitle } from "../rules/index.js";
9
- import { layeredSystemWords, systemContentFolders } from "../systems/index.js";
10
- import { languageName } from "./game-world.js";
11
- import { YesRefused } from "./package.js";
4
+ import { campaignFileName, findCampaign, readListSetting, readTextSetting } from "../../campaign/index.js";
5
+ import { comparableText } from "../../core/text.js";
6
+ import { documentAt, documentKinds } from "../../documents/index.js";
7
+ import { dropUnlisted, foldersIn, isWithin, libraryFolders, libraryReader, libraryState, mostBooks, samePath, saveLibraryFolders } from "../../library/index.js";
8
+ import { bookHeadings, findPages, hasAllWords, pageExcerpt, pageTitle } from "../../rules/index.js";
9
+ import { layeredSystemWords, systemContentFolders } from "../../systems/index.js";
10
+ import { YesRefused } from "../package.js";
11
+ import { languageName } from "./world.js";
12
12
  /** What a library takes: the documents the engine reads, outside every campaign (LIB-2). */
13
13
  export const libraryScope = { kinds: documentKinds, skipFoldersWith: campaignFileName };
14
14
  // About how many words each excerpt shows: the first, the second, and the only one when the system has answered (LIB-7); the other pages named.
@@ -66,24 +66,37 @@ export async function libraryAdditions(root, context, given) {
66
66
  */
67
67
  export function libraryRemovals(root, context, given, computer) {
68
68
  const held = readListSetting(root, "library");
69
- const entries = given.map((entry) => resolve(context.folder, unquoted(entry)));
69
+ const entries = checkLibraryRemovals(root, context, given, computer);
70
70
  const index = context.bookIndex;
71
71
  if (!computer || index === undefined) {
72
72
  return entries.map((entry) => held.find((other) => samePath(other, entry)) ?? entry);
73
73
  }
74
- const folders = libraryFolders(index);
75
- const unknown = entries.find((entry) => ![...folders, ...held].some((other) => samePath(other, entry)));
76
- if (unknown !== undefined) {
77
- throw new Error(`${unknown} is not in this computer's library, so nothing changed. It holds: ${folders.length > 0 ? folders.join("; ") : "nothing"}.`);
78
- }
79
- const remaining = folders.filter((other) => !entries.some((entry) => samePath(other, entry)));
74
+ const remaining = libraryFolders(index).filter((other) => !entries.some((entry) => samePath(other, entry)));
80
75
  saveLibraryFolders(index, remaining);
81
76
  dropUnlisted(index, remaining);
82
77
  return held.filter((other) => entries.some((entry) => samePath(other, entry)));
83
78
  }
84
- /** The campaign's library as it is used: the entries it turns on that are in this computer's library, which the player allowed (LIB-1). */
85
- export function campaignLibrary(root, context) {
86
- return readListSetting(root, "library").filter((entry) => computerSpelling(context, entry) !== undefined);
79
+ /**
80
+ * The entries to turn off as full paths, before anything is written (LIB-1): refused for one the campaign does not hold, or with `computer` for one neither the
81
+ * campaign nor this computer's library holds.
82
+ */
83
+ export function checkLibraryRemovals(root, context, given, computer) {
84
+ const held = readListSetting(root, "library");
85
+ const entries = given.map((entry) => resolve(context.folder, unquoted(entry)));
86
+ const index = context.bookIndex;
87
+ if (computer && index !== undefined) {
88
+ const folders = libraryFolders(index);
89
+ const unknown = entries.find((entry) => ![...folders, ...held].some((other) => samePath(other, entry)));
90
+ if (unknown !== undefined) {
91
+ throw new Error(`${unknown} is not in this computer's library, so nothing changed. It holds: ${folders.length > 0 ? folders.join("; ") : "nothing"}.`);
92
+ }
93
+ return entries;
94
+ }
95
+ const missing = entries.find((entry) => !held.some((other) => samePath(other, entry)));
96
+ if (missing !== undefined) {
97
+ throw new Error(`"library" does not hold "${missing}", so nothing changed. It holds: ${held.length > 0 ? held.join("; ") : "nothing"}.`);
98
+ }
99
+ return entries;
87
100
  }
88
101
  /** The kind of why a book was skipped, from the engine's words without the book's name or path, which may hold any word. */
89
102
  export function skippedKind(why) {
@@ -109,7 +122,10 @@ export function libraryEntries(root, context) {
109
122
  path: entry,
110
123
  books: state?.books.length ?? 0,
111
124
  reading: state?.waiting.length ?? 0,
112
- skipped: state?.skipped.map((one) => ({ name: relative(entry, one.path) || basename(one.path), why: skippedWhy(one.path, one.why), kind: skippedKind(skippedWhy(one.path, one.why)) })) ?? [],
125
+ skipped: state?.skipped.map((one) => {
126
+ const why = skippedWhy(one.path, one.why);
127
+ return { name: relative(entry, one.path) || basename(one.path), why, kind: skippedKind(why) };
128
+ }) ?? [],
113
129
  missing: state === undefined ? false : state.missing.length > 0,
114
130
  crowded: state === undefined ? false : state.crowded.length > 0,
115
131
  used: held.some((other) => samePath(other, entry)),
@@ -208,7 +224,7 @@ export function libraryAnswer(root, context, system, text, systemAnswered) {
208
224
  books: state.books.map((book) => `${book.name} (${[book.language === undefined ? "" : languageName(book.language), partsOf(book)].filter((part) => part !== "").join(", ")})`),
209
225
  ...(system?.lengthUnit === undefined ? {} : { unit: system.lengthUnit }),
210
226
  };
211
- const page = pageNamed(state.books, text);
227
+ const page = bookPageNamed(state.books, text);
212
228
  if (page !== undefined || text === "") {
213
229
  return { ...base, ...(page === undefined ? {} : { page }) };
214
230
  }
@@ -257,6 +273,39 @@ export function libraryLines(answer, text) {
257
273
  const recognized = answer.shown.some((shown) => shown.recognized === true) ? recognizedRule : "";
258
274
  return [`From the player's books${language}:`, ...excerpts, others, recognized, libraryRule(answer.unit), reading].filter((line) => line !== "");
259
275
  }
276
+ /**
277
+ * The system's words that a search names, from the system's language into another or back (LIB-6, RUL-8): "grapple" gives Afferrato, the system's Italian, for
278
+ * an Italian book; "afferrato" gives Grappled, for the system. Only words of four letters or more find one; none in the system's own language, and none of the
279
+ * words a foe's hits are heard in. Each says whether its words are the whole search, as afferrato is, or only part of it, as tiro of tiro per colpire.
280
+ */
281
+ export function systemWordsNamed(system, language, text, intoSystem) {
282
+ if (language.split("-")[0] === system.language.split("-")[0]) {
283
+ return [];
284
+ }
285
+ try {
286
+ const words = layeredSystemWords(systemContentFolders(system), language);
287
+ const heard = (system.combat?.inWords ?? []).map(comparableText);
288
+ // Not the names, which are of fields by their ids, as cha or str-save.
289
+ const pairs = Object.entries({ ...words?.groups, ...words?.words }).filter(([own]) => !heard.includes(comparableText(own)));
290
+ const found = pairs.map(([own, translated]) => (intoSystem ? [translated, own] : [own, translated])).filter(([searched]) => /\p{L}{4}/u.test(searched) && hasAllWords(text, searched));
291
+ // Grappled and grappled, a name and a word of the same, are one.
292
+ return found
293
+ .filter(([, named], at) => found.findIndex(([, other]) => comparableText(other) === comparableText(named)) === at)
294
+ .slice(0, mostTranslations)
295
+ .map(([searched, named]) => ({ named, whole: hasAllWords(searched, text) }));
296
+ }
297
+ catch {
298
+ return [];
299
+ }
300
+ }
301
+ /** A path as given, without the quotes of one copied from the file manager. */
302
+ export function unquoted(entry) {
303
+ return entry.trim().replace(/^"(.*)"$/, "$1").replace(/^'(.*)'$/, "$1").trim();
304
+ }
305
+ /** The campaign's library as it is used: the entries it turns on that are in this computer's library, which the player allowed (LIB-1). */
306
+ function campaignLibrary(root, context) {
307
+ return readListSetting(root, "library").filter((entry) => computerSpelling(context, entry) !== undefined);
308
+ }
260
309
  /**
261
310
  * The precedence of the books, and how their words may be used (LIB-7, D-491 (7), (9)): the sheets' numbers the system's, a variant through config, the books
262
311
  * data quoted in the chat, the campaign's files the master's own words and numbers in the system's units.
@@ -283,7 +332,7 @@ function byBook(found, text, also) {
283
332
  * The page a text names, read whole, or saying it has no readable text: "Book › p. 194", or as an excerpt cites it, "Book, PDF p. 194"; undefined when the text
284
333
  * names no book's page. Refused for a page the book has not.
285
334
  */
286
- function pageNamed(books, text) {
335
+ function bookPageNamed(books, text) {
287
336
  const match = /^(.+?)[\s›>,]+(?:pdf\s*)?(?:p|pp|pag|page|pagina|part|parte)\.?\s*(\d+)$/i.exec(text.trim());
288
337
  const name = match?.[1].trim() ?? "";
289
338
  const number = match?.[2];
@@ -306,31 +355,6 @@ function pageNamed(books, text) {
306
355
  function translationsOf(system, languages, text) {
307
356
  return [...new Set(languages.flatMap((language) => systemWordsNamed(system, language, text, false).map((one) => one.named)))].slice(0, mostTranslations);
308
357
  }
309
- /**
310
- * The system's words that a search names, from the system's language into another or back (LIB-6, RUL-8): "grapple" gives Afferrato, the system's Italian, for
311
- * an Italian book; "afferrato" gives Grappled, for the system. Only words of four letters or more find one; none in the system's own language, and none of the
312
- * words a foe's hits are heard in. Each says whether its words are the whole search, as afferrato is, or only part of it, as tiro of tiro per colpire.
313
- */
314
- export function systemWordsNamed(system, language, text, intoSystem) {
315
- if (language.split("-")[0] === system.language.split("-")[0]) {
316
- return [];
317
- }
318
- try {
319
- const words = layeredSystemWords(systemContentFolders(system), language);
320
- const heard = (system.combat?.inWords ?? []).map(comparableText);
321
- // Not the names, which are of fields by their ids, as cha or str-save.
322
- const pairs = Object.entries({ ...words?.groups, ...words?.words }).filter(([own]) => !heard.includes(comparableText(own)));
323
- const found = pairs.map(([own, translated]) => (intoSystem ? [translated, own] : [own, translated])).filter(([searched]) => /\p{L}{4}/u.test(searched) && hasAllWords(text, searched));
324
- // Grappled and grappled, a name and a word of the same, are one.
325
- return found
326
- .filter(([, named], at) => found.findIndex(([, other]) => comparableText(other) === comparableText(named)) === at)
327
- .slice(0, mostTranslations)
328
- .map(([searched, named]) => ({ named, whole: hasAllWords(searched, text) }));
329
- }
330
- catch {
331
- return [];
332
- }
333
- }
334
358
  /** How a part of a book is cited: "Book, PDF p. 194", or "Book, part 3" for a document without pages. */
335
359
  function citeOf(book, part) {
336
360
  return `${book.name}, ${book.pdf === true ? "PDF p." : "part"} ${part + 1}`;
@@ -370,10 +394,6 @@ function libraryPath(context, given) {
370
394
  }
371
395
  return resolve(context.folder, entry);
372
396
  }
373
- /** A path as given, without the quotes of one copied from the file manager. */
374
- export function unquoted(entry) {
375
- return entry.trim().replace(/^"(.*)"$/, "$1").replace(/^'(.*)'$/, "$1").trim();
376
- }
377
397
  /**
378
398
  * The folders inside one too big for a library, a few by name, for the player to choose the game's books among: in their terminal or on the dashboard, never
379
399
  * to the master, before the player allowed anything there.
@@ -1,6 +1,6 @@
1
- import type { Problem } from "../core/problem.ts";
2
- import { type FieldChange, type Page, type World } from "../pages/index.ts";
3
- import type { GameSystem } from "../systems/index.ts";
1
+ import type { Problem } from "../../core/problem.ts";
2
+ import { type FieldChange, type Page, type World } from "../../pages/index.ts";
3
+ import type { GameSystem } from "../../systems/index.ts";
4
4
  /** Refuses a change of a sheet that writes a number above its most, or makes a list longer than its most (LIM-1); before anything is written. */
5
5
  export declare function checkLimits(world: World, system: GameSystem | undefined, page: Page | undefined, name: string, change: FieldChange): void;
6
6
  /** Sheets written by hand above their most (LIM-2). */
@@ -1,8 +1,8 @@
1
1
  // The most a sheet holds (D-449, LIM-1, LIM-2): a number written no higher than the system's formula, as an ability score of 20, and a list no longer, as
2
2
  // the spells prepared; what an item or an effect raises is no part of it.
3
- import { numberOf } from "../core/formula.js";
4
- import { comparableText, valueNamed } from "../core/text.js";
5
- import { textsIn } from "../pages/index.js";
3
+ import { numberOf } from "../../core/formula.js";
4
+ import { comparableText, valueNamed } from "../../core/text.js";
5
+ import { textsIn } from "../../pages/index.js";
6
6
  import { effectiveFields } from "./effect-layer.js";
7
7
  import { formulaValue, hasSheet, keepsSheet } from "./worked-out.js";
8
8
  /** Refuses a change of a sheet that writes a number above its most, or makes a list longer than its most (LIM-1); before anything is written. */
@@ -1,5 +1,5 @@
1
- import { type Page, type World } from "../pages/index.ts";
2
- import type { GameSystem } from "../systems/index.ts";
1
+ import { type Page, type World } from "../../pages/index.ts";
2
+ import type { GameSystem } from "../../systems/index.ts";
3
3
  /** What the master is told of what the fallen carry: there, for the player to take. */
4
4
  export declare const lootAdvice = "tell what the party sees, and let the player say what is taken, and by whom.";
5
5
  /** Whether a character or creature outside the party, a copy too, is dead or at the system's down value or below. */
@@ -1,8 +1,8 @@
1
1
  // What the fallen carry and what a container holds is there to be found, and what is taken is the player's to say (D-530, Elena's tests of 27 and 28 October,
2
2
  // where the master put a fallen foe's coins in the character's pocket): text for the master where they read it, show of the page or the close of the scene.
3
- import { valueNamed } from "../core/text.js";
4
- import { readCounter } from "../counters/index.js";
5
- import { inheritedFields, isEmptyField, isPartyMember } from "../pages/index.js";
3
+ import { valueNamed } from "../../core/text.js";
4
+ import { readCounter } from "../../counters/index.js";
5
+ import { inheritedFields, isEmptyField, isPartyMember } from "../../pages/index.js";
6
6
  /** What the master is told of what the fallen carry: there, for the player to take. */
7
7
  export const lootAdvice = "tell what the party sees, and let the player say what is taken, and by whom.";
8
8
  /** Whether a character or creature outside the party, a copy too, is dead or at the system's down value or below. */
@@ -1,5 +1,5 @@
1
- import type { Context } from "../core/context.ts";
2
- import type { LogEntry } from "../core/log.ts";
1
+ import type { Context } from "../../core/context.ts";
2
+ import type { LogEntry } from "../../core/log.ts";
3
3
  /** What the master is told of a roll the setting hid. */
4
4
  export declare const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
5
5
  /**
@@ -1,10 +1,10 @@
1
1
  // The master's rolls for anyone outside the party (D-287): hidden behind the screen, as the master-rolls setting has them when unset too, or in view.
2
- import { readTextSetting } from "../campaign/index.js";
3
- import { sameName } from "../core/text.js";
4
- import { createProof, fingerprint } from "../dice/index.js";
5
- import { isPartyMember, pagesWithNameOrAlias } from "../pages/index.js";
6
- import { readOpenScene } from "./game-scene.js";
7
- import { campaignWorld } from "./game-world.js";
2
+ import { readTextSetting } from "../../campaign/index.js";
3
+ import { sameName } from "../../core/text.js";
4
+ import { createProof, fingerprint } from "../../dice/index.js";
5
+ import { isPartyMember, pagesWithNameOrAlias } from "../../pages/index.js";
6
+ import { readOpenScene } from "./scene.js";
7
+ import { campaignWorld } from "./world.js";
8
8
  /** What the master is told of a roll the setting hid. */
9
9
  export const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
10
10
  /**
@@ -1,7 +1,7 @@
1
- import type { Context } from "../core/context.ts";
2
- import type { Problem } from "../core/problem.ts";
3
- import { type World } from "../pages/index.ts";
4
- import type { GameSystem } from "../systems/index.ts";
1
+ import type { Context } from "../../core/context.ts";
2
+ import type { Problem } from "../../core/problem.ts";
3
+ import { type World } from "../../pages/index.ts";
4
+ import type { GameSystem } from "../../systems/index.ts";
5
5
  /** The modes, in their order (D-75, D-77). */
6
6
  export declare const modes: readonly ["setup", "session zero", "play"];
7
7
  export type Mode = (typeof modes)[number];
@@ -25,7 +25,5 @@ export declare function missingText(blocked: Blocked): string;
25
25
  export declare function campaignNote(root: string, context: Context): string;
26
26
  /** Before play, what the next mode still needs and the call that enters it once the player confirms (MOD-7); undefined in play. */
27
27
  export declare function checklistLine(mode: Mode, root: string, context: Context, world: World): string | undefined;
28
- /** The call that enters a mode, as outputs give it: mode, to "session zero". */
29
- export declare function modeCall(mode: Mode): string;
30
28
  /** The part of the instructions of a mode, the core's with the system's (MOD-5): the file setup, session-zero or play. */
31
29
  export declare function modePart(mode: Mode, system: GameSystem | undefined): string | undefined;
@@ -1,14 +1,14 @@
1
1
  // The mode of the campaign, the main state of the game (D-77): setup, session zero or play, each opened by the checklist of the one before (D-221, D-241; MOD-1–MOD-7).
2
2
  import { basename } from "node:path";
3
- import { companionWays, diceWays, difficulties, lethalities, masterRollWays, missingSettings, preparations, readSettings, readStateValues, rigors, saveModes, unansweredSettings, unitSystems } from "../campaign/index.js";
4
- import { readLog } from "../core/log.js";
5
- import { comparableText } from "../core/text.js";
6
- import { isInParty, playerCharacters } from "../pages/index.js";
7
- import { missingWithSystems, offeredLabel } from "./game-offers.js";
8
- import { campaignSystem, campaignWorld } from "./game-world.js";
3
+ import { companionWays, diceWays, difficulties, lethalities, masterRollWays, missingSettings, preparations, readSettings, readStateValues, rigors, saveModes, unansweredSettings, unitSystems, } from "../../campaign/index.js";
4
+ import { readLog } from "../../core/log.js";
5
+ import { comparableText } from "../../core/text.js";
6
+ import { isInParty, playerCharacters } from "../../pages/index.js";
9
7
  import { missingSettingsNote } from "./notes.js";
8
+ import { missingWithSystems, offeredLabel } from "./offers.js";
10
9
  import { partText } from "./parts.js";
11
10
  import { missingSheetFields } from "./sheet.js";
11
+ import { campaignSystem, campaignWorld } from "./world.js";
12
12
  /** The modes, in their order (D-75, D-77). */
13
13
  export const modes = ["setup", "session zero", "play"];
14
14
  // The settings the setup asks, with the values they take, so that the master offers them as they are (MOD-3).
@@ -95,14 +95,14 @@ export function checklistLine(mode, root, context, world) {
95
95
  : "";
96
96
  return `${missing.charAt(0).toUpperCase()}${missing.slice(1)}. When ${blocked === undefined ? "" : "none is left and "}the player confirms: ${modeCall(next)}.${name}${page}`;
97
97
  }
98
- /** The call that enters a mode, as outputs give it: mode, to "session zero". */
99
- export function modeCall(mode) {
100
- return `mode, to ${mode.includes(" ") ? `"${mode}"` : mode}`;
101
- }
102
98
  /** The part of the instructions of a mode, the core's with the system's (MOD-5): the file setup, session-zero or play. */
103
99
  export function modePart(mode, system) {
104
100
  return partText(mode.replace(" ", "-"), system);
105
101
  }
102
+ /** The call that enters a mode, as outputs give it: mode, to "session zero". */
103
+ function modeCall(mode) {
104
+ return `mode, to ${mode.includes(" ") ? `"${mode}"` : mode}`;
105
+ }
106
106
  /** The mode state.yaml writes; undefined when it writes none, or cannot be read, which status and validate say elsewhere: the other commands go on. */
107
107
  function writtenMode(root) {
108
108
  try {
@@ -1,6 +1,6 @@
1
- import type { Context } from "../core/context.ts";
2
- import type { Problem } from "../core/problem.ts";
3
- import { type Coin } from "../money/index.ts";
1
+ import type { Context } from "../../core/context.ts";
2
+ import type { Problem } from "../../core/problem.ts";
3
+ import { type Coin } from "../../money/index.ts";
4
4
  /**
5
5
  * The coins of the campaign, or the problem that keeps campaign.yaml from giving them; neither when the game has no money (MON-1).
6
6
  * They are read on their own, so that a mistake in another setting does not turn every purse into text. A campaign without coins of its own