rpg-engine 0.14.1 → 0.16.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 (493) hide show
  1. package/dist/campaign/index.d.ts +1 -1
  2. package/dist/campaign/index.js +1 -1
  3. package/dist/campaign/last-choices.js +1 -1
  4. package/dist/campaign/settings.d.ts +25 -5
  5. package/dist/campaign/settings.js +38 -9
  6. package/dist/cli/cli.js +1 -1
  7. package/dist/cli/command-line.js +1 -1
  8. package/dist/commands/advance.d.ts +1 -1
  9. package/dist/commands/advance.js +6 -6
  10. package/dist/commands/ask.js +7 -7
  11. package/dist/commands/change/amounts.d.ts +32 -0
  12. package/dist/commands/change/amounts.js +150 -0
  13. package/dist/commands/change/change.d.ts +4 -54
  14. package/dist/commands/change/change.js +19 -749
  15. package/dist/commands/change/damage.d.ts +30 -0
  16. package/dist/commands/change/damage.js +73 -2
  17. package/dist/commands/change/dice.d.ts +34 -0
  18. package/dist/commands/change/dice.js +59 -0
  19. package/dist/commands/change/fields.d.ts +37 -0
  20. package/dist/commands/change/fields.js +156 -0
  21. package/dist/commands/change/holder.d.ts +48 -0
  22. package/dist/commands/change/holder.js +162 -0
  23. package/dist/commands/change/recipe-pace.js +1 -1
  24. package/dist/commands/change/recipe.d.ts +58 -0
  25. package/dist/commands/change/recipe.js +179 -0
  26. package/dist/commands/choices.js +3 -3
  27. package/dist/commands/config/config.d.ts +15 -0
  28. package/dist/commands/config/config.js +355 -0
  29. package/dist/commands/config/custom-levels.d.ts +7 -0
  30. package/dist/commands/config/custom-levels.js +32 -0
  31. package/dist/commands/{config.d.ts → config/dashboard.d.ts} +4 -26
  32. package/dist/commands/config/dashboard.js +171 -0
  33. package/dist/commands/config/entries.d.ts +17 -0
  34. package/dist/commands/config/entries.js +76 -0
  35. package/dist/commands/config/news.d.ts +7 -0
  36. package/dist/commands/config/news.js +88 -0
  37. package/dist/commands/config/shown.d.ts +9 -0
  38. package/dist/commands/config/shown.js +80 -0
  39. package/dist/commands/config/words.d.ts +27 -0
  40. package/dist/commands/config/words.js +204 -0
  41. package/dist/commands/effect.js +9 -9
  42. package/dist/commands/find.d.ts +4 -4
  43. package/dist/commands/find.js +1 -1
  44. package/dist/commands/image.js +6 -6
  45. package/dist/commands/import/import.d.ts +0 -2
  46. package/dist/commands/import/import.js +45 -44
  47. package/dist/commands/import/run.js +1 -1
  48. package/dist/commands/index.js +3 -3
  49. package/dist/commands/init.js +2 -2
  50. package/dist/commands/install.js +1 -1
  51. package/dist/commands/instructions.js +17 -6
  52. package/dist/commands/mode.d.ts +2 -2
  53. package/dist/commands/mode.js +17 -9
  54. package/dist/commands/mood.js +4 -4
  55. package/dist/commands/move.js +10 -10
  56. package/dist/commands/package/consent.d.ts +11 -0
  57. package/dist/commands/package/consent.js +52 -0
  58. package/dist/commands/package/here.d.ts +51 -0
  59. package/dist/commands/package/here.js +128 -0
  60. package/dist/commands/package/install.d.ts +10 -0
  61. package/dist/commands/package/install.js +337 -0
  62. package/dist/commands/package/package.d.ts +18 -0
  63. package/dist/commands/package/package.js +236 -0
  64. package/dist/commands/package/result.d.ts +90 -0
  65. package/dist/commands/package/result.js +1 -0
  66. package/dist/commands/package/uninstall.d.ts +6 -0
  67. package/dist/commands/package/uninstall.js +70 -0
  68. package/dist/commands/rename.js +3 -3
  69. package/dist/commands/reveal.js +5 -5
  70. package/dist/commands/roll/roll.js +11 -9
  71. package/dist/commands/roll/tables.js +1 -1
  72. package/dist/commands/rules.d.ts +2 -2
  73. package/dist/commands/rules.js +3 -3
  74. package/dist/commands/save.d.ts +1 -1
  75. package/dist/commands/save.js +2 -2
  76. package/dist/commands/scene/close.d.ts +18 -0
  77. package/dist/commands/scene/close.js +179 -0
  78. package/dist/commands/scene/members.d.ts +14 -0
  79. package/dist/commands/scene/members.js +32 -0
  80. package/dist/commands/scene/open.d.ts +6 -0
  81. package/dist/commands/scene/open.js +298 -0
  82. package/dist/commands/scene/result.d.ts +98 -0
  83. package/dist/commands/scene/result.js +2 -0
  84. package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
  85. package/dist/commands/scene/scene.js +210 -0
  86. package/dist/commands/scene/turns.d.ts +18 -0
  87. package/dist/commands/scene/turns.js +229 -0
  88. package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +5 -3
  89. package/dist/commands/shared/{adventures.js → books/adventures.js} +23 -19
  90. package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
  91. package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
  92. package/dist/commands/shared/{library.js → books/library.js} +9 -9
  93. package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
  94. package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
  95. package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
  96. package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
  97. package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
  98. package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
  99. package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
  100. package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
  101. package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
  102. package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
  103. package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
  104. package/dist/commands/shared/{mode.js → campaign/mode.js} +28 -13
  105. package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
  106. package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
  107. package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
  108. package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
  109. package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
  110. package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
  111. package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +10 -3
  112. package/dist/commands/shared/{parts.js → campaign/parts.js} +26 -3
  113. package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
  114. package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
  115. package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
  116. package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
  117. package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
  118. package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
  119. package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
  120. package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
  121. package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
  122. package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
  123. package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
  124. package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
  125. package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
  126. package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
  127. package/dist/commands/shared/characters/orders.d.ts +4 -0
  128. package/dist/commands/shared/characters/orders.js +10 -0
  129. package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +2 -2
  130. package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +3 -3
  131. package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
  132. package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
  133. package/dist/commands/shared/examples.js +2 -2
  134. package/dist/commands/shared/packages/catalog.js +2 -2
  135. package/dist/commands/shared/packages/code.d.ts +1 -1
  136. package/dist/commands/shared/packages/code.js +8 -8
  137. package/dist/commands/shared/packages/extensions.d.ts +1 -1
  138. package/dist/commands/shared/packages/extensions.js +1 -1
  139. package/dist/commands/shared/packages/hooks.d.ts +1 -1
  140. package/dist/commands/shared/packages/hooks.js +1 -1
  141. package/dist/commands/shared/packages/widgets.d.ts +3 -3
  142. package/dist/commands/shared/packages/widgets.js +3 -3
  143. package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
  144. package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
  145. package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
  146. package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
  147. package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
  148. package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
  149. package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
  150. package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
  151. package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
  152. package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
  153. package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
  154. package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
  155. package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
  156. package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
  157. package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
  158. package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
  159. package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
  160. package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
  161. package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
  162. package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
  163. package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
  164. package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
  165. package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
  166. package/dist/commands/shared/{scene.js → scene/scene.js} +7 -7
  167. package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
  168. package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
  169. package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
  170. package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
  171. package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
  172. package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
  173. package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
  174. package/dist/commands/shared/sheet/effect-values.js +69 -0
  175. package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
  176. package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
  177. package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
  178. package/dist/commands/shared/sheet/formula-problems.js +140 -0
  179. package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
  180. package/dist/commands/shared/sheet/formula-scope.js +235 -0
  181. package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
  182. package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
  183. package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
  184. package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
  185. package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +5 -5
  186. package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
  187. package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
  188. package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
  189. package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
  190. package/dist/commands/shared/sheet/system-fields.js +45 -0
  191. package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
  192. package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
  193. package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
  194. package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
  195. package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
  196. package/dist/commands/shared/sheet/worked-out.js +291 -0
  197. package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
  198. package/dist/commands/shared/sheet/worked-text.js +55 -0
  199. package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
  200. package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
  201. package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
  202. package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
  203. package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
  204. package/dist/commands/shared/{events.js → time/events.js} +10 -13
  205. package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
  206. package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
  207. package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
  208. package/dist/commands/shared/{time.js → time/time.js} +6 -6
  209. package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
  210. package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
  211. package/dist/commands/show.d.ts +4 -1
  212. package/dist/commands/show.js +28 -9
  213. package/dist/commands/status.d.ts +2 -1
  214. package/dist/commands/status.js +34 -23
  215. package/dist/commands/thoughts.js +3 -3
  216. package/dist/commands/trade.js +8 -8
  217. package/dist/commands/translate.d.ts +1 -1
  218. package/dist/commands/translate.js +3 -3
  219. package/dist/commands/travel/open.d.ts +1 -1
  220. package/dist/commands/travel/open.js +2 -2
  221. package/dist/commands/travel/route.js +7 -6
  222. package/dist/commands/travel/travel.d.ts +1 -1
  223. package/dist/commands/travel/travel.js +8 -8
  224. package/dist/commands/validate.js +3 -3
  225. package/dist/commands/view/journal.d.ts +2 -2
  226. package/dist/commands/view/journal.js +2 -2
  227. package/dist/commands/view/map.d.ts +1 -1
  228. package/dist/commands/view/map.js +6 -6
  229. package/dist/commands/view/memory.d.ts +16 -0
  230. package/dist/commands/view/memory.js +90 -0
  231. package/dist/commands/view/page.d.ts +32 -0
  232. package/dist/commands/view/page.js +163 -0
  233. package/dist/commands/view/place.d.ts +7 -2
  234. package/dist/commands/view/place.js +30 -12
  235. package/dist/commands/view/result.d.ts +245 -0
  236. package/dist/commands/view/result.js +1 -0
  237. package/dist/commands/view/saves.d.ts +6 -0
  238. package/dist/commands/view/saves.js +53 -0
  239. package/dist/commands/view/story.d.ts +32 -0
  240. package/dist/commands/view/story.js +227 -0
  241. package/dist/commands/view/view.d.ts +26 -292
  242. package/dist/commands/view/view.js +26 -534
  243. package/dist/commands/view/world.d.ts +1 -1
  244. package/dist/commands/view/world.js +3 -3
  245. package/dist/commands/write/checks.d.ts +42 -0
  246. package/dist/commands/write/checks.js +291 -0
  247. package/dist/commands/write/here.d.ts +1 -1
  248. package/dist/commands/write/here.js +5 -5
  249. package/dist/commands/write/inheritance.d.ts +40 -0
  250. package/dist/commands/write/inheritance.js +189 -0
  251. package/dist/commands/write/input.d.ts +29 -0
  252. package/dist/commands/write/input.js +124 -0
  253. package/dist/commands/write/layer.d.ts +36 -0
  254. package/dist/commands/write/layer.js +48 -0
  255. package/dist/commands/write/notes.d.ts +22 -0
  256. package/dist/commands/write/notes.js +76 -0
  257. package/dist/commands/write/progression.d.ts +27 -0
  258. package/dist/commands/write/progression.js +175 -0
  259. package/dist/commands/write/write.d.ts +2 -1
  260. package/dist/commands/write/write.js +33 -817
  261. package/dist/core/files.d.ts +2 -0
  262. package/dist/core/files.js +7 -0
  263. package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
  264. package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
  265. package/dist/core/session-store.js +3 -3
  266. package/dist/core/store.d.ts +2 -2
  267. package/dist/core/store.js +18 -4
  268. package/dist/dashboard/acts/acts.js +1 -1
  269. package/dist/dashboard/acts/sending.js +110 -0
  270. package/dist/dashboard/acts/sheet.js +2 -2
  271. package/dist/dashboard/acts/strip.js +1 -1
  272. package/dist/dashboard/address.js +6 -0
  273. package/dist/dashboard/api.js +1 -1
  274. package/dist/dashboard/app.js +47 -171
  275. package/dist/dashboard/dice/roller.js +1 -1
  276. package/dist/dashboard/dice/sets.js +2 -2
  277. package/dist/dashboard/dice/stage.js +1 -1
  278. package/dist/dashboard/dice/tray.js +6 -6
  279. package/dist/dashboard/guide/ar.md +9 -4
  280. package/dist/dashboard/guide/cs.md +10 -5
  281. package/dist/dashboard/guide/da.md +9 -4
  282. package/dist/dashboard/guide/de.md +9 -4
  283. package/dist/dashboard/guide/el.md +10 -5
  284. package/dist/dashboard/guide/en.md +7 -2
  285. package/dist/dashboard/guide/es.md +9 -4
  286. package/dist/dashboard/guide/fi.md +9 -4
  287. package/dist/dashboard/guide/fr.md +9 -4
  288. package/dist/dashboard/guide/he.md +9 -4
  289. package/dist/dashboard/guide/hi.md +10 -5
  290. package/dist/dashboard/guide/hu.md +10 -5
  291. package/dist/dashboard/guide/is.md +9 -4
  292. package/dist/dashboard/guide/it.md +9 -4
  293. package/dist/dashboard/guide/ja.md +12 -7
  294. package/dist/dashboard/guide/ko.md +11 -6
  295. package/dist/dashboard/guide/nb.md +9 -4
  296. package/dist/dashboard/guide/nl.md +10 -5
  297. package/dist/dashboard/guide/pl.md +9 -4
  298. package/dist/dashboard/guide/pt.md +9 -4
  299. package/dist/dashboard/guide/ro.md +9 -4
  300. package/dist/dashboard/guide/ru.md +9 -4
  301. package/dist/dashboard/guide/sv.md +9 -4
  302. package/dist/dashboard/guide/tr.md +11 -6
  303. package/dist/dashboard/guide/uk.md +9 -4
  304. package/dist/dashboard/guide/zh.md +9 -4
  305. package/dist/dashboard/help/help.js +3 -3
  306. package/dist/dashboard/i18n/ar.json +20 -0
  307. package/dist/dashboard/i18n/cs.json +20 -0
  308. package/dist/dashboard/i18n/da.json +20 -0
  309. package/dist/dashboard/i18n/de.json +20 -0
  310. package/dist/dashboard/i18n/el.json +20 -0
  311. package/dist/dashboard/i18n/es.json +20 -0
  312. package/dist/dashboard/i18n/fi.json +20 -0
  313. package/dist/dashboard/i18n/fr.json +20 -0
  314. package/dist/dashboard/i18n/he.json +20 -0
  315. package/dist/dashboard/i18n/hi.json +20 -0
  316. package/dist/dashboard/i18n/hu.json +20 -0
  317. package/dist/dashboard/i18n/is.json +20 -0
  318. package/dist/dashboard/i18n/it.json +20 -0
  319. package/dist/dashboard/i18n/ja.json +21 -1
  320. package/dist/dashboard/i18n/ko.json +20 -0
  321. package/dist/dashboard/i18n/nb.json +20 -0
  322. package/dist/dashboard/i18n/nl.json +20 -0
  323. package/dist/dashboard/i18n/pl.json +20 -0
  324. package/dist/dashboard/i18n/pt.json +20 -0
  325. package/dist/dashboard/i18n/ro.json +20 -0
  326. package/dist/dashboard/i18n/ru.json +20 -0
  327. package/dist/dashboard/i18n/sv.json +20 -0
  328. package/dist/dashboard/i18n/tr.json +20 -0
  329. package/dist/dashboard/i18n/uk.json +20 -0
  330. package/dist/dashboard/i18n/zh.json +20 -0
  331. package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
  332. package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
  333. package/dist/dashboard/kit.js +3 -3
  334. package/dist/dashboard/packages/ask-card.js +3 -3
  335. package/dist/dashboard/packages/catalog.js +196 -0
  336. package/dist/dashboard/packages/engine.js +87 -0
  337. package/dist/dashboard/packages/installed.js +53 -0
  338. package/dist/dashboard/packages/library.js +97 -0
  339. package/dist/dashboard/packages/outcomes.js +45 -0
  340. package/dist/dashboard/packages/packages.js +20 -576
  341. package/dist/dashboard/packages/page-code.js +15 -2
  342. package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
  343. package/dist/dashboard/packages/rows.js +84 -0
  344. package/dist/dashboard/packages/share.js +44 -0
  345. package/dist/dashboard/packages/widgets.js +3 -3
  346. package/dist/dashboard/{card.js → parts/card.js} +1 -1
  347. package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
  348. package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
  349. package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
  350. package/dist/dashboard/{labels.js → parts/labels.js} +8 -1
  351. package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
  352. package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
  353. package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
  354. package/dist/dashboard/{refusals.js → parts/refusals.js} +1 -1
  355. package/dist/dashboard/{status.js → parts/status.js} +4 -4
  356. package/dist/dashboard/{widgets.js → parts/widgets.js} +2 -2
  357. package/dist/dashboard/place/key.js +24 -0
  358. package/dist/dashboard/place/paper.js +67 -0
  359. package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
  360. package/dist/dashboard/place/things.js +129 -0
  361. package/dist/dashboard/place/tokens.js +93 -0
  362. package/dist/dashboard/place/view.js +124 -0
  363. package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
  364. package/dist/dashboard/{asked.js → play/asked.js} +10 -10
  365. package/dist/dashboard/{choices.js → play/choices.js} +9 -9
  366. package/dist/dashboard/{requested.js → play/requested.js} +1 -1
  367. package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
  368. package/dist/dashboard/{scene.js → play/scene.js} +14 -14
  369. package/dist/dashboard/{turns.js → play/turns.js} +12 -12
  370. package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
  371. package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
  372. package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
  373. package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
  374. package/dist/dashboard/{setup.js → settings/setup.js} +6 -6
  375. package/dist/dashboard/{party.js → sheet/party.js} +8 -8
  376. package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
  377. package/dist/dashboard/{sheet.js → sheet/sheet.js} +17 -17
  378. package/dist/dashboard/{story.js → sheet/story.js} +3 -3
  379. package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
  380. package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
  381. package/dist/dashboard/{master.js → shell/master.js} +2 -2
  382. package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
  383. package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
  384. package/dist/dashboard/shell/shown.js +37 -0
  385. package/dist/dashboard/{table.js → shell/table.js} +2 -2
  386. package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
  387. package/dist/dashboard/{top.js → shell/top.js} +7 -7
  388. package/dist/dashboard/style.css +90 -9
  389. package/dist/dashboard/world/calendar.js +4 -4
  390. package/dist/dashboard/world/drawing.js +92 -0
  391. package/dist/dashboard/world/key.js +21 -0
  392. package/dist/dashboard/world/lore.js +5 -5
  393. package/dist/dashboard/world/map-card.js +186 -0
  394. package/dist/dashboard/world/place-card.js +39 -0
  395. package/dist/dashboard/world/places.js +29 -0
  396. package/dist/dashboard/world/world.js +9 -341
  397. package/dist/extensions/extension.d.ts +1 -1
  398. package/dist/extensions/extension.js +1 -1
  399. package/dist/images/images.js +12 -9
  400. package/dist/index.d.ts +1 -1
  401. package/dist/languages/index.d.ts +1 -1
  402. package/dist/languages/index.js +1 -1
  403. package/dist/library/books.js +2 -0
  404. package/dist/packages/npm.js +1 -1
  405. package/dist/page.d.ts +2 -2
  406. package/dist/page.js +1 -1
  407. package/dist/pages/check.js +23 -1
  408. package/dist/pages/containers.d.ts +1 -1
  409. package/dist/pages/containers.js +1 -1
  410. package/dist/pages/index.d.ts +4 -2
  411. package/dist/pages/index.js +4 -2
  412. package/dist/pages/inheritance.d.ts +2 -2
  413. package/dist/pages/layers.d.ts +50 -0
  414. package/dist/pages/layers.js +97 -0
  415. package/dist/pages/rename-page.js +1 -1
  416. package/dist/pages/stacks/writes.js +48 -22
  417. package/dist/pages/standard-fields.d.ts +1 -1
  418. package/dist/pages/system-pages.d.ts +5 -3
  419. package/dist/pages/system-pages.js +16 -7
  420. package/dist/pages/world.d.ts +8 -1
  421. package/dist/pages/world.js +16 -4
  422. package/dist/pages/write-layer.d.ts +18 -0
  423. package/dist/pages/write-layer.js +108 -0
  424. package/dist/pages/write-page.d.ts +2 -2
  425. package/dist/pages/write-page.js +2 -2
  426. package/dist/rules/index.d.ts +1 -1
  427. package/dist/rules/index.js +1 -1
  428. package/dist/rules/search.d.ts +1 -1
  429. package/dist/rules/shown.d.ts +1 -1
  430. package/dist/server/dashboard/choices.js +3 -3
  431. package/dist/server/dashboard/files.js +5 -5
  432. package/dist/server/dashboard/index.d.ts +2 -2
  433. package/dist/server/dashboard/index.js +2 -2
  434. package/dist/server/dashboard/news.js +4 -3
  435. package/dist/server/dashboard/player.js +1 -1
  436. package/dist/server/dashboard/writes.js +10 -8
  437. package/dist/server/mcp.js +28 -13
  438. package/dist/systems/campaign-data.d.ts +15 -0
  439. package/dist/systems/campaign-data.js +85 -0
  440. package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
  441. package/dist/systems/{system-code.js → code.js} +2 -2
  442. package/dist/systems/game-system.d.ts +7 -61
  443. package/dist/systems/game-system.js +1 -984
  444. package/dist/systems/index.d.ts +6 -3
  445. package/dist/systems/index.js +6 -3
  446. package/dist/systems/installed.d.ts +31 -0
  447. package/dist/systems/installed.js +89 -0
  448. package/dist/systems/maps.d.ts +3 -0
  449. package/dist/systems/maps.js +9 -0
  450. package/dist/systems/read.d.ts +3 -0
  451. package/dist/systems/read.js +471 -0
  452. package/dist/systems/schema.d.ts +289 -0
  453. package/dist/systems/schema.js +243 -0
  454. package/dist/systems/settings.d.ts +19 -0
  455. package/dist/systems/settings.js +78 -0
  456. package/dist/systems/versions.d.ts +12 -0
  457. package/dist/systems/versions.js +52 -0
  458. package/dist/testing/index.js +1 -1
  459. package/instructions/import.md +1 -1
  460. package/instructions/length-a-few-sessions.md +1 -0
  461. package/instructions/length-one-evening.md +1 -0
  462. package/instructions/play.md +1 -1
  463. package/instructions/session-zero.md +1 -1
  464. package/instructions/setup.md +1 -1
  465. package/package.json +1 -1
  466. package/dist/commands/config.js +0 -917
  467. package/dist/commands/package.d.ts +0 -143
  468. package/dist/commands/package.js +0 -785
  469. package/dist/commands/scene.js +0 -894
  470. package/dist/commands/shared/worked-out.js +0 -805
  471. package/dist/dashboard/place/map-view.js +0 -417
  472. /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
  473. /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
  474. /package/dist/core/{package-api.js → packages/api.js} +0 -0
  475. /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
  476. /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
  477. /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
  478. /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
  479. /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
  480. /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
  481. /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
  482. /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
  483. /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
  484. /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
  485. /package/dist/languages/{language-pack.js → pack.js} +0 -0
  486. /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
  487. /package/dist/pages/{page-file.js → file.js} +0 -0
  488. /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
  489. /package/dist/pages/{page-types.js → types.js} +0 -0
  490. /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
  491. /package/dist/rules/{rule-book.js → book.js} +0 -0
  492. /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
  493. /package/dist/systems/{system-folders.js → folders.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { appendLogEntry, readLog } from "../../core/log.js";
2
2
  import { comparableText } from "../../core/text.js";
3
3
  import { addDuration, formatGameDate, minutesBetween, readDuration, readGameDate } from "../../time/index.js";
4
- import { newDatedLogEntry, readPresent } from "../shared/time.js";
4
+ import { newDatedLogEntry, readPresent } from "../shared/time/time.js";
5
5
  const appliedType = "recipe-applied";
6
6
  /** Why a page gains nothing from a recipe it had too recently (RST-1), as "Ettore had a long rest at day 2, 08:00: …"; undefined when it may have it. */
7
7
  export function tooSoonNote(root, recipe, page) {
@@ -0,0 +1,58 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import { type World } from "../../pages/index.ts";
3
+ import { type StepOutcome } from "./holder.ts";
4
+ /**
5
+ * What a recipe did to a page: the effects it ended, the steps it wrote, what it leaves to the player or, for a companion, to the master (D-206), and the
6
+ * counters it leaves to the master.
7
+ */
8
+ export interface RecipeOutcome {
9
+ page: string;
10
+ pc: boolean;
11
+ ended: string[];
12
+ steps: StepOutcome[];
13
+ choices: string[];
14
+ /** The dice the recipe lets the page spend that would give something, as hit-dice-d8 2/3, which the player chooses for the player character (ASK-14). */
15
+ spendable: string[];
16
+ notBroughtBack: string[];
17
+ kept: string[];
18
+ /** The effects without an end still on the page, which a rest may ask something of (EFF-15). */
19
+ resting: string;
20
+ /** Whether the recipe gave the page nothing, at 0 of what it needs or too soon after the last (RST-1). */
21
+ barred: boolean;
22
+ }
23
+ /**
24
+ * A recipe of the game system applied to a page, or to the living player characters and the companions with them (DAT-4). Every page is checked before any
25
+ * is written.
26
+ */
27
+ export declare function recipeResult(root: string, context: Context, world: World, input: {
28
+ page?: string;
29
+ field?: string;
30
+ by?: unknown;
31
+ spend?: unknown;
32
+ to?: unknown;
33
+ why?: string;
34
+ recipe: string;
35
+ values?: number[];
36
+ }): {
37
+ recipe: string;
38
+ system: string;
39
+ outcomes: RecipeOutcome[];
40
+ rules: string[];
41
+ lasts?: string;
42
+ buttons?: boolean;
43
+ physical?: boolean;
44
+ spent?: string;
45
+ };
46
+ /**
47
+ * "Long rest (a recipe of the system 5e):", then for each page what ended and changed, as in "Ennio: Prosciugato ended; hp 8/12 → 12/12. Not brought back:
48
+ * hit-dice 1/3.", with the thresholds it touched; the rules for the rest; the game date, which a recipe does not move.
49
+ */
50
+ export declare function recipeText(result: {
51
+ recipe: string;
52
+ system: string;
53
+ outcomes: RecipeOutcome[];
54
+ rules: string[];
55
+ lasts?: string;
56
+ buttons?: boolean;
57
+ physical?: boolean;
58
+ }): string;
@@ -0,0 +1,179 @@
1
+ // A recipe of the game system applied to pages, and its text
2
+ import { readSettings } from "../../campaign/index.js";
3
+ import { appendLogEntry } from "../../core/log.js";
4
+ import { comparableText, valueNamed } from "../../core/text.js";
5
+ import { readCounter } from "../../counters/index.js";
6
+ import { findPage, withPage } from "../../pages/index.js";
7
+ import { campaignSystem } from "../shared/campaign/world.js";
8
+ import { restExample } from "../shared/examples.js";
9
+ import { checkEffectsReadable, saveEffects } from "../shared/scene/effects.js";
10
+ import { restingEffectsNote } from "../shared/scene/reminders.js";
11
+ import { keptRolls } from "../shared/sheet/counters.js";
12
+ import { effectiveFields } from "../shared/sheet/effect-layer.js";
13
+ import { spendableDice, spendDice } from "../shared/time/dice-pool.js";
14
+ import { effectsAtRecipe, notBroughtBack, partyPages, recipeChoices, recipeNamed, recipeTargets } from "../shared/time/recipes.js";
15
+ import { newDatedLogEntry } from "../shared/time/time.js";
16
+ import { counterStep } from "./amounts.js";
17
+ import { applyStep, holderNamed, pageHolder, stepNotes } from "./holder.js";
18
+ import { logRecipeApplied, tooSoonNote } from "./recipe-pace.js";
19
+ /**
20
+ * A recipe of the game system applied to a page, or to the living player characters and the companions with them (DAT-4). Every page is checked before any
21
+ * is written.
22
+ */
23
+ export function recipeResult(root, context, world, input) {
24
+ const named = campaignSystem(root, context);
25
+ const page = input.page?.trim() === "" ? undefined : input.page;
26
+ checkQuotedRecipe(named, input.recipe, [page, input.field]);
27
+ // Dice the rest lets one spend, as hit dice in a short rest (D-449).
28
+ if (input.field !== undefined && input.spend !== undefined && input.by === undefined && input.to === undefined && page !== undefined) {
29
+ const { system, recipe } = recipeNamed(named, input.recipe);
30
+ const why = input.why === undefined || input.why.trim() === "" ? recipe.name : input.why;
31
+ return { recipe: recipe.name, system: system.name, outcomes: [], rules: [], spent: spendDice(root, context, world, { system, recipe }, page, input.field, input.spend, { why, values: input.values }).text };
32
+ }
33
+ if (input.field !== undefined || input.by !== undefined || input.spend !== undefined || input.to !== undefined || input.values !== undefined) {
34
+ throw new Error(`A recipe changes by itself the fields it names: give it with the page, or alone for the player character and the companions with them, such as recipe "${restExample(named)}". Nothing changed.`);
35
+ }
36
+ const { system, recipe } = recipeNamed(named, input.recipe);
37
+ const pages = page === undefined ? partyPages(world) : [recipePage(root, world, page)];
38
+ if (pages.length === 0) {
39
+ throw new Error("There is no living player character, so a recipe without a page goes to no one: give the page. Nothing changed.");
40
+ }
41
+ // A page given was checked when it was found; each must still be the only one of its name, and its effects must read.
42
+ for (const candidate of pages) {
43
+ findPage(world, candidate.name);
44
+ checkEffectsReadable(candidate);
45
+ }
46
+ const why = input.why === undefined || input.why.trim() === "" ? recipe.name : input.why;
47
+ let current = world;
48
+ const outcomes = pages.map((candidate) => {
49
+ const applied = recipeOn(root, context, current, system, recipe, candidate.name, why);
50
+ current = applied.world;
51
+ return applied.outcome;
52
+ });
53
+ // Where the dashboard serves a page, the player spends their dice there with ask (ASK-14); with physical dice, they roll their own (ASK-8).
54
+ const physical = readSettings(root).dice === "physical";
55
+ return { recipe: recipe.name, system: system.name, outcomes, rules: recipe.rules, lasts: recipe.lasts, buttons: context.page?.spendDice !== undefined, physical };
56
+ }
57
+ /**
58
+ * A recipe applied to one page (DAT-4): the effects that last until one of its occasions end first (DAT-5), then each field it names goes to its maximum or to
59
+ * its value, as change sets it.
60
+ */
61
+ function recipeOn(root, context, world, system, recipe, name, why) {
62
+ let current = world;
63
+ const start = pageHolder(current, pageCalled(current, name));
64
+ const { ending, remaining } = effectsAtRecipe(start.page, recipe);
65
+ if (ending.length > 0) {
66
+ const written = saveEffects(root, context, current, { page: start.page, copy: false }, remaining);
67
+ for (const effect of ending) {
68
+ appendLogEntry(root, newDatedLogEntry(root, context, "effect-ended", start.visibility, { page: name, effect: effect.name, why }));
69
+ }
70
+ current = written === undefined ? current : withPage(current, start.page, written);
71
+ }
72
+ const steps = [];
73
+ // A rest that needs a counter above 0, as a long rest hit points, gives nothing to who has none when it begins (D-449).
74
+ const needed = recipe.needs === undefined ? undefined : readCounter(valueNamed(effectiveFields(current, pageCalled(current, name)), recipe.needs));
75
+ const atZero = needed !== undefined && needed.value <= 0;
76
+ // Nor to who had one too recently, as a second long rest within 24 hours (RST-1).
77
+ const tooSoon = atZero ? undefined : tooSoonNote(root, recipe, name);
78
+ const barred = atZero || tooSoon !== undefined;
79
+ for (const { field, target } of barred ? [] : recipeTargets(current, recipe, pageCalled(current, name))) {
80
+ const holder = pageHolder(current, pageCalled(current, name));
81
+ const step = counterStep({ to: target }, effectiveFields(current, holder.page)[field], name, field, undefined);
82
+ if (String(step.after) !== String(step.before)) {
83
+ const applied = applyStep(root, context, current, holder, field, step, why, system);
84
+ steps.push(applied.outcome);
85
+ current = applied.world;
86
+ }
87
+ }
88
+ const outcome = {
89
+ page: name,
90
+ pc: pageCalled(current, name).fields.role === "pc",
91
+ ended: ending.map((effect) => effect.name),
92
+ steps,
93
+ choices: recipeChoices(current, recipe, pageCalled(current, name)),
94
+ spendable: barred ? [] : spendableDice(current, recipe, pageCalled(current, name)),
95
+ notBroughtBack: notBroughtBack(current, system, recipe, pageCalled(current, name)),
96
+ kept: keptRolls(current, pageCalled(current, name)).map(([field, values]) => `${field} ${values.join(", ")}`),
97
+ barred,
98
+ resting: [atZero ? `At 0 ${recipe.needs ?? ""} when it began, ${name} gains nothing from it.` : tooSoon ?? "", restingEffectsNote(pageCalled(current, name))].filter((note) => note !== "").join(" "),
99
+ };
100
+ if (!barred) {
101
+ logRecipeApplied(root, context, recipe, name, start.visibility);
102
+ }
103
+ return { outcome, world: current };
104
+ }
105
+ /** The page with this name, which a recipe has just checked or written. */
106
+ function pageCalled(world, name) {
107
+ const page = findPage(world, name);
108
+ if (page === undefined) {
109
+ throw new Error(`There is no page named ${name}. Look for it with the find command.`);
110
+ }
111
+ return page;
112
+ }
113
+ /** "--recipe long rest" without quotes reads rest as the page or the field: refused, with the quotes to give. */
114
+ function checkQuotedRecipe(system, recipe, rest) {
115
+ const known = (name) => (system?.recipes ?? []).some((candidate) => comparableText(candidate.name) === comparableText(name));
116
+ const words = rest.filter((word) => word !== undefined);
117
+ const joined = [...words.map((word) => `${recipe} ${word}`), [recipe, ...words].join(" ")].find(known);
118
+ if (!known(recipe) && joined !== undefined) {
119
+ throw new Error(`Put the recipe's name in quotes, such as recipe "${joined}". Nothing changed.`);
120
+ }
121
+ }
122
+ /** The page a recipe goes to: a page of the campaign, never a copy in the scene. */
123
+ function recipePage(root, world, name) {
124
+ const holder = holderNamed(root, world, name);
125
+ if (holder.kind === "copy") {
126
+ throw new Error(`${holder.page.name} is a copy in the scene: a recipe goes to pages, such as the characters who rest. Nothing changed.`);
127
+ }
128
+ return holder.page;
129
+ }
130
+ /**
131
+ * "Long rest (a recipe of the system 5e):", then for each page what ended and changed, as in "Ennio: Prosciugato ended; hp 8/12 → 12/12. Not brought back:
132
+ * hit-dice 1/3.", with the thresholds it touched; the rules for the rest; the game date, which a recipe does not move.
133
+ */
134
+ export function recipeText(result) {
135
+ const notes = result.outcomes.flatMap((outcome) => outcome.steps.flatMap(stepNotes));
136
+ const lines = result.outcomes.flatMap((outcome) => {
137
+ const done = [...outcome.ended.map((effect) => `${effect} ended`), ...outcome.steps.map(stepText)];
138
+ const left = outcome.notBroughtBack.length === 0 ? "" : ` Not brought back: ${outcome.notBroughtBack.join(", ")}.`;
139
+ // The player chooses and rolls for the player character, the master for a companion (D-206, D-213).
140
+ const chosen = [...outcome.choices.map((choice) => ` ${outcome.pc ? "Ask the player" : `Choose for ${outcome.page}`}: ${choice}.`), spendText(outcome, result)].join("");
141
+ // Rolls kept for later: if this rest brings them back, they are rolled again (KEP-4).
142
+ const roller = outcome.pc ? "the player rolls" : "roll";
143
+ const kept = outcome.kept.length === 0 ? "" : ` ${outcome.page} keeps ${outcome.kept.join("; ")}: if this rest brings them back, ${roller} them again, with roll and keep.`;
144
+ const resting = outcome.resting === "" ? "" : ` ${outcome.resting}`;
145
+ return [`${outcome.page}: ${done.length === 0 ? "nothing changed" : done.join("; ")}.${chosen}${left}${kept}${resting}`, ...outcome.steps.flatMap(stepNotes).filter((note) => !note.includes("\n"))];
146
+ });
147
+ const rules = result.rules.length === 0 ? "" : `For the rest, read ${result.rules.map((rule) => `rules "${rule}"`).join(" and ")}.`;
148
+ const title = `${result.recipe.charAt(0).toUpperCase()}${result.recipe.slice(1)} (a recipe of the system ${result.system}):`;
149
+ // A refused rest has no hours to advance (D-500).
150
+ const hours = result.outcomes.every((outcome) => outcome.barred)
151
+ ? ""
152
+ : `The game date did not move: apply a rest once its hours${result.lasts === undefined ? "" : ` (${result.lasts})`} have passed; if they have not yet, advance them now.`;
153
+ const text = [title, ...lines, rules, hours].filter((line) => line !== "").join("\n");
154
+ return [text, ...notes.filter((note) => note.includes("\n"))].join("\n\n");
155
+ }
156
+ /**
157
+ * The dice a rest lets a page spend, left to who chooses them (ASK-14): the player for the player character, with ask's buttons where they are, the master for
158
+ * a companion.
159
+ */
160
+ function spendText(outcome, result) {
161
+ if (outcome.spendable.length === 0) {
162
+ return "";
163
+ }
164
+ const dice = outcome.spendable.join(", ");
165
+ const spend = `change with spend and recipe "${result.recipe}"`;
166
+ if (!outcome.pc) {
167
+ return ` Choose whether ${outcome.page} spends ${dice}: ${spend}.`;
168
+ }
169
+ if (result.physical === true) {
170
+ return ` Ask the player how many of ${dice} they spend and roll with their own dice, then ${spend} and values, the faces they tell.`;
171
+ }
172
+ return result.buttons === true ? ` The player spends ${dice} on the page, one die at a time: ask with recipe "${result.recipe}", even when they already said how many.` : ` Ask the player how many of ${dice} they spend, then ${spend}.`;
173
+ }
174
+ /** "hp 20/34 → 34/34 (in Forma d'orso)": a step of a recipe, with the effect it changed on or the base the page reads again. */
175
+ function stepText(step) {
176
+ // A value an effect gives never goes back to a base: one of the two at most.
177
+ const where = step.effect !== undefined ? ` (in ${step.effect})` : step.again !== undefined ? ` (again as ${step.again})` : "";
178
+ return `${step.field} ${step.before} → ${step.after}${where}`;
179
+ }
@@ -6,10 +6,10 @@ import { comparableText, linkTargetName } from "../core/text.js";
6
6
  import { parseNotation } from "../dice/index.js";
7
7
  import { findPage, isPartyMember, playerCharacters } from "../pages/index.js";
8
8
  import { readOption } from "./ask.js";
9
+ import { situationPart } from "./shared/campaign/parts.js";
10
+ import { campaignWorld } from "./shared/campaign/world.js";
9
11
  import { textList, textsOf } from "./shared/inputs.js";
10
- import { situationPart } from "./shared/parts.js";
11
- import { newDatedLogEntry } from "./shared/time.js";
12
- import { campaignWorld } from "./shared/world.js";
12
+ import { newDatedLogEntry } from "./shared/time/time.js";
13
13
  // How many choices a set holds, and how many options a choice: the whole list the rules allow, such as every spell a class may learn.
14
14
  const mostItems = 8;
15
15
  const mostOptions = 200;
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ export declare const config: import("../../core/registry.ts").Command<z.ZodObject<{
3
+ setting: z.ZodOptional<z.ZodString>;
4
+ value: z.ZodOptional<z.ZodString>;
5
+ add: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
+ computer: z.ZodOptional<z.ZodBoolean>;
8
+ }, z.core.$strip>, ConfigResult>;
9
+ interface ConfigResult {
10
+ settings: Record<string, unknown>;
11
+ note: string;
12
+ replaced: string[];
13
+ part?: string;
14
+ }
15
+ export {};
@@ -0,0 +1,355 @@
1
+ // The config command: shows a setting, checks it and writes it
2
+ import { z } from "zod";
3
+ import { changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, clearSetting, customLevel, customSettings, entrySettingNames, listSettingNames, mapSettingNames, readSettings, readTextSetting, refreshHostFiles, rememberChoice, requireCampaign, settingDescription, settingNames, startingLevels, writeEffortFiles, } from "../../campaign/index.js";
4
+ import { appendLogEntry } from "../../core/log.js";
5
+ import { defineCommand } from "../../core/registry.js";
6
+ import { comparableText } from "../../core/text.js";
7
+ import { hostInstructions } from "../../instructions/index.js";
8
+ import { coinList, readAmount, readCoins } from "../../money/index.js";
9
+ import { declaredKind } from "../../pages/index.js";
10
+ import { campaignDataNames, rulesetSetting } from "../../systems/index.js";
11
+ import { readBetweenSessions, readCalendar, readCalendarStart } from "../../time/index.js";
12
+ import { checkLibraryRemovals, libraryAdditions, libraryRemovals, startLibraryReading } from "../shared/books/library.js";
13
+ import { campaignMode, campaignNote } from "../shared/campaign/mode.js";
14
+ import { campaignCoins } from "../shared/campaign/money.js";
15
+ import { askedBy, heldSystemSettings, offerRefusal, playedEngineSetting, unofferedLines, valuePart } from "../shared/campaign/offers.js";
16
+ import { lengthPart, mentorPart, stylePart } from "../shared/campaign/parts.js";
17
+ import { campaignSystem, campaignWorld, installedSystemName, playersOfTheGame, systemSetting, valuesText } from "../shared/campaign/world.js";
18
+ import { loadNewSystemCode } from "../shared/packages/code.js";
19
+ import { checkWidgetSpots } from "../shared/packages/widgets.js";
20
+ import { readOpenScene } from "../shared/scene/scene.js";
21
+ import { campaignCalendar, newDatedLogEntry } from "../shared/time/time.js";
22
+ import { customEntries, customOf } from "./custom-levels.js";
23
+ import { checkAdditions, counterShape, entriesOf, formatValue, replacedEntries, yamlValue } from "./entries.js";
24
+ import { offeredShown, shownValue, systemShownValue } from "./shown.js";
25
+ import { styleSettingNames, wordsOf } from "./words.js";
26
+ // A use whose maximum reads what gives it, in quotes for its commas (CAM-1).
27
+ const counterExample = 'bulwark-dice: {max: "4 * has(features, Bulwark)", refill: {{rest}}}';
28
+ export const config = defineCommand({
29
+ name: "config",
30
+ description: "Show or change the campaign settings. "
31
+ + "Without a setting it shows them all and which are missing; with a setting alone, that one with what it is and its values; with a value it changes it. "
32
+ + "Use it in the setup, for each setting status says is missing, and whenever the player changes one. "
33
+ + "system is fixed once there is a player character. lines and veils change with add and remove, or value none when the player wants none. "
34
+ + "orders: the player's standing orders to the companions, kept until they withdraw one. "
35
+ + "effort and ruleset are the player's: change them only when they ask. "
36
+ + "library: the player's own books, folders or files by their full path, added once to this computer with the player's yes in a window of their computer, "
37
+ + "then turned on in each campaign with add and off with remove; remove with computer takes one off this computer. "
38
+ + "precedents: each ruling you made without the text, the rule's name in the system's language first, such as 'Poisoned: …'. learned: the mechanics you explained, by name. "
39
+ + "table: what you promised the player about how you play, in the words you said. "
40
+ + 'coins, when the system gives none: each coin with its value in the smallest coin, other names after a slash, "rare" for one never given as change. '
41
+ + "widgets: where the dashboard shows an extension's widget, such as value 'weather.today: side'; remove gives it back its place. "
42
+ + "difficulty and rigor custom: each item at its own level, which custom-difficulty and custom-rigor take by item, such as value 'food: rules, load: smooth'; "
43
+ + "custom starts from the level played until then, and remove gives an item the default. "
44
+ + "fields, tables, computed, counters and recipes add to the game system what it lacks, or change it as a house rule: entries by name, written as in system.yaml, "
45
+ + "each replacing the system's one of that name (a recipe adds to the system's); remove takes their names. status-line adds fields to the player character's line. "
46
+ + "A formula with commas goes in quotes; a use's max reads what gives it, so that only who has it has it. "
47
+ + `Example: setting language, value it; or setting lines, add "spiders"; or setting counters, value '${counterExample}'.`,
48
+ group: "campaign",
49
+ positionals: ["setting", "value"],
50
+ input: z.object({
51
+ setting: z.string().optional().describe(`setting to show or change: ${settingNames.join(", ")}, or one the game system adds`),
52
+ value: z.string().optional().describe("new value of the setting"),
53
+ add: z.array(z.string()).optional().describe(`items to add to a list setting (${listSettingNames.join(", ")}), repeatable`),
54
+ remove: z.array(z.string()).optional().describe(`items to remove from a list setting (${listSettingNames.join(", ")}), repeatable`),
55
+ computer: z.boolean().optional().describe("with library and remove: off this computer too, out of every campaign, its books' text deleted"),
56
+ }),
57
+ run(given, context) {
58
+ const input = { ...given, setting: given.setting?.trim() };
59
+ if (input.computer !== undefined && (input.setting !== "library" || input.remove === undefined)) {
60
+ throw new Error("computer goes only with setting library and remove: it takes those folders off this computer. Nothing changed.");
61
+ }
62
+ // What the library holds is checked, and an addition allowed by the player, before it is written (LIB-1).
63
+ if (input.setting === "library" && (input.add !== undefined || input.remove !== undefined)) {
64
+ return changeLibrary(input, context);
65
+ }
66
+ const result = configure(input, context);
67
+ // A system installed in this chat, as in the setup, brings its code once the campaign plays it (D-513 (1)).
68
+ return input.setting === "system" && input.value !== undefined ? loadNewSystemCode(context).then(() => result) : result;
69
+ },
70
+ format(result) {
71
+ const lines = Object.entries(result.settings).map(([name, value]) => `${name}: ${formatValue(value)}`);
72
+ return [[...lines, ...result.replaced].join("\n"), result.note, result.part ?? ""].filter((block) => block !== "").join("\n\n");
73
+ },
74
+ });
75
+ /**
76
+ * The library changed (LIB-1, LIB-3): additions as full paths, added to this computer first, from the chat with the player's yes; removals by any spelling of
77
+ * their path, off this computer too with computer; then the new books read apart.
78
+ */
79
+ async function changeLibrary(input, context) {
80
+ const root = requireCampaign(context.folder);
81
+ // A removal refused writes nothing: checked before an addition reaches this computer's library.
82
+ if (input.remove !== undefined) {
83
+ checkLibraryRemovals(root, context, input.remove, input.computer === true);
84
+ }
85
+ const add = input.add === undefined ? undefined : await libraryAdditions(root, context, input.add);
86
+ const remove = input.remove === undefined ? undefined : libraryRemovals(root, context, input.remove, input.computer === true);
87
+ // Taken off the computer only: the campaign did not use it.
88
+ const result = configure(add === undefined && remove?.length === 0 ? { setting: "library" } : { ...input, add, remove }, context);
89
+ startLibraryReading(context);
90
+ return result;
91
+ }
92
+ function configure(input, context) {
93
+ const root = requireCampaign(context.folder);
94
+ const listChange = input.add !== undefined || input.remove !== undefined;
95
+ const own = input.setting === undefined ? undefined : systemSetting(root, context, input.setting);
96
+ // One a value asks holds only with that value (DAT-17).
97
+ if (own !== undefined && !heldSystemSettings(root, context).some((setting) => setting.name === own.name)) {
98
+ throw new Error(`${own.name} holds only with ${askedBy(root, context, own.name)}: change that first, if the player wants it. Nothing changed.`);
99
+ }
100
+ // A setting the game system adds, with one of its values (DAT-10).
101
+ if (own !== undefined) {
102
+ return systemSettingResult(root, context, own, input);
103
+ }
104
+ if (input.setting !== undefined && !settingNames.includes(input.setting.trim())) {
105
+ const added = (campaignSystem(root, context)?.settings ?? []).map((setting) => setting.name);
106
+ throw new Error(`There is no setting "${input.setting}". The settings are: ${[...settingNames, ...added].join(", ")}.`);
107
+ }
108
+ if (input.add !== undefined && input.setting !== undefined && entrySettingNames.includes(checkSettingName(input.setting))) {
109
+ throw new Error(`"${input.setting}" takes entries by name as the value, such as setting counters, value '${counterShape}'; remove takes their names.`);
110
+ }
111
+ if (listChange && (input.setting === undefined || (input.value !== undefined && !entrySettingNames.includes(checkSettingName(input.setting))))) {
112
+ throw new Error('Give add or remove with a list setting and no value, such as setting lines, add "spiders".');
113
+ }
114
+ // The master's effort is the player's to choose, in their terminal or on the dashboard, never the master's own (D-462).
115
+ if (input.setting?.trim() === "effort" && input.value !== undefined && context.terminal !== true && context.actor !== "player") {
116
+ throw new Error("effort is the player's to choose, never yours: tell them they can set it on the dashboard's Settings, or in their terminal with rpg config effort and low, medium, high or app. Nothing changed.");
117
+ }
118
+ // app, or none, takes the effort away: each app keeps its own again (D-462).
119
+ if (input.setting?.trim() === "effort" && ["app", "none"].includes(input.value?.trim().toLowerCase() ?? "")) {
120
+ if (clearSetting(root, "effort")) {
121
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: "effort", value: "app" }));
122
+ }
123
+ const unwritten = writeEffortFiles(root, context.platform, true);
124
+ return { settings: { effort: shownValue(root, context, readSettings(root), "effort") }, note: "", replaced: ["Taken away for Claude Code and Codex: from the next chat each keeps its own.", ...unwritten], part: "" };
125
+ }
126
+ if (input.setting?.trim() === "system" && input.value !== undefined) {
127
+ checkSystemOpen(root, context, input.value);
128
+ }
129
+ // An engine's setting the game offers only some values of (DAT-16).
130
+ const refused = input.setting === undefined || input.value === undefined ? undefined : offerRefusal(root, context, input.setting.trim(), input.value);
131
+ if (refused !== undefined) {
132
+ throw new Error(refused);
133
+ }
134
+ const shown = input.setting === undefined ? settingNames : [checkSettingName(input.setting)];
135
+ const mapped = input.setting !== undefined && mapSettingNames.includes(checkSettingName(input.setting));
136
+ let replaced = [];
137
+ // A custom difficulty or rigor starts from the preset played until then, each item not yet written at its level (T-132).
138
+ const leveledName = input.setting === "difficulty" || input.setting === "rigor" ? input.setting : undefined;
139
+ const startsCustom = leveledName !== undefined && input.value?.trim().toLowerCase() === customLevel;
140
+ const preset = leveledName === undefined ? undefined : readSettings(root)[leveledName];
141
+ const custom = customOf(input.setting ?? "");
142
+ // The items of a custom difficulty or rigor, each at a level it takes (T-132).
143
+ if (custom !== undefined && (input.value !== undefined || input.remove !== undefined)) {
144
+ const name = customSettings[custom];
145
+ if (changeMapSetting(root, name, { set: input.value === undefined ? undefined : customEntries(custom, input.value), remove: input.remove })) {
146
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: name, value: input.value, remove: input.remove }));
147
+ }
148
+ // Kept for when it is chosen, but played only then.
149
+ if (playedEngineSetting(root, context, custom) !== customLevel) {
150
+ replaced = [...replaced, `${name} plays only while ${custom} is custom.`];
151
+ }
152
+ }
153
+ else if (input.setting?.trim() === "widgets" && (input.value !== undefined || input.remove !== undefined)) {
154
+ const set = input.value === undefined ? undefined : entriesOf("widgets", input.value);
155
+ checkWidgetSpots(root, context, set ?? {});
156
+ if (changeMapSetting(root, "widgets", { set, remove: input.remove })) {
157
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: "widgets", value: input.value, remove: input.remove }));
158
+ }
159
+ }
160
+ else if (mapped && input.setting !== undefined && (input.value !== undefined || input.remove !== undefined)) {
161
+ // What the campaign adds to its game system, checked with the system before it is written (CAM-1, CAM-3).
162
+ const change = { set: input.value === undefined ? undefined : entriesOf(input.setting, input.value), remove: input.remove };
163
+ checkAdditions(root, context, input.setting, change);
164
+ replaced = replacedEntries(root, context, input.setting, Object.keys(change.set ?? {}));
165
+ if (changeMapSetting(root, input.setting, change)) {
166
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, value: input.value, remove: input.remove }));
167
+ }
168
+ }
169
+ else if (input.setting !== undefined && listChange && changeListSetting(root, input.setting, { add: input.add, remove: input.remove })) {
170
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, add: input.add, remove: input.remove }));
171
+ }
172
+ else if (input.setting !== undefined && input.value?.trim().toLowerCase() === "none" && listSettingNames.includes(checkSettingName(input.setting))) {
173
+ // A list answered with none still answers the setup (MOD-3).
174
+ if (changeListSettingToNone(root, input.setting)) {
175
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, value: "none" }));
176
+ }
177
+ }
178
+ else if (input.setting !== undefined && input.value?.trim().toLowerCase() === "none" && freeSettingNames.includes(checkSettingName(input.setting))) {
179
+ if (clearSetting(root, input.setting)) {
180
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, value: "none" }));
181
+ }
182
+ }
183
+ else if (input.setting !== undefined && input.value !== undefined && changeSetting(root, input.setting, settingValue(root, input.setting, input.value, context))) {
184
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, value: input.value }));
185
+ // What the next campaign's setup suggests; a custom difficulty or rigor is this campaign's own (T-134).
186
+ const chosen = readSettings(root)[input.setting];
187
+ if (chosen !== customLevel) {
188
+ rememberChoice(context.home, input.setting, chosen);
189
+ }
190
+ }
191
+ if (startsCustom && leveledName !== undefined && readSettings(root)[leveledName] === customLevel) {
192
+ const written = readSettings(root)[customSettings[leveledName]] ?? {};
193
+ const unwritten = Object.entries(startingLevels(leveledName, preset)).filter(([item]) => !Object.hasOwn(written, item));
194
+ if (unwritten.length > 0) {
195
+ changeMapSetting(root, customSettings[leveledName], { set: Object.fromEntries(unwritten) });
196
+ }
197
+ }
198
+ // The effort written where each app reads it in the campaign's folder (D-462).
199
+ if (input.setting?.trim() === "effort" && input.value !== undefined) {
200
+ const unwritten = writeEffortFiles(root, context.platform);
201
+ const written = "Written for Claude Code and Codex: it applies from the next chat; in Codex only in a folder it trusts; an effort picked in the app for one chat wins there.";
202
+ replaced = [...replaced, ...(unwritten.length === 0 ? [written] : unwritten)];
203
+ }
204
+ // The character agent written or taken away at once, not when the server starts again (D-490).
205
+ if (input.setting?.trim() === "voices" && input.value !== undefined) {
206
+ refreshHostFiles(root, hostInstructions(), context.platform);
207
+ replaced = [...replaced, "Claude Code finds the character agent, or finds it gone, from the next chat."];
208
+ }
209
+ // New months may leave the day the story starts on without its month (TIM-8): said at once, not at the next date.
210
+ if (input.setting?.trim() === "calendar" && input.value !== undefined) {
211
+ replaced = [...replaced, ...campaignCalendar(root, context).problems.map((problem) => `${problem.message.replace(/\.$/, "")}: ${problem.fix ?? "fix it"}.`)];
212
+ }
213
+ // A standing order kept, with what binds it, before the master plays by it (D-563).
214
+ if (input.setting?.trim() === "orders" && input.add !== undefined) {
215
+ replaced = [...replaced, ordersKept];
216
+ }
217
+ // A setting asked alone comes with what it is and its values, which the description leaves to it (T-64).
218
+ const about = input.setting !== undefined && input.value === undefined && !listChange ? settingDescription(checkSettingName(input.setting)) : undefined;
219
+ if (about !== undefined) {
220
+ replaced = [...replaced, `${checkSettingName(input.setting ?? "")}: ${about}.`];
221
+ }
222
+ const settings = readSettings(root);
223
+ // Listed all together, what the campaign adds to its system only when it adds something.
224
+ const added = (name) => campaignDataNames.includes(name);
225
+ const listed = input.setting === undefined ? shown.filter((name) => !(added(name) || name === "calendar" || name === "widgets" || customOf(name) !== undefined) || settings[name] !== undefined) : shown;
226
+ const system = input.setting === undefined ? heldSystemSettings(root, context) : [];
227
+ // The master's own change of the mentor brings its part, once in the chat; the player's comes with the news of the dashboard (D-347).
228
+ const changed = input.value !== undefined && context.actor !== "player" ? input.setting?.trim() : undefined;
229
+ // And of how the master writes, the parts as they are now (D-395).
230
+ const style = styleSettingNames.includes(changed ?? "") ? stylePart(root, context) : "";
231
+ // And of the length, past the setup, how to size the adventures now (D-558); entering play gives it otherwise.
232
+ const sized = changed === "length" && campaignMode(root, campaignWorld(root, context)) !== "setup";
233
+ const length = !sized ? "" : settings.length === "open" ? "The campaign is open now: the adventures take the size the story asks, one after another." : lengthPart(root, context);
234
+ // An author or the player's words taken away: what holds now, as the dashboard's news says it.
235
+ const cleared = changed !== undefined && input.value?.trim().toLowerCase() === "none" ? wordsOf(changed)?.cleared : undefined;
236
+ const part = changed === "mentor"
237
+ ? mentorPart(root, context, settings.mentor)
238
+ : [cleared === undefined ? "" : `${cleared.charAt(0).toUpperCase()}${cleared.slice(1)}.`, style, length].filter((text) => text !== "").join("\n\n");
239
+ return {
240
+ settings: {
241
+ ...Object.fromEntries(listed.map((name) => [name, offeredShown(root, context, name, shownValue(root, context, settings, name))])),
242
+ ...Object.fromEntries(system.map((setting) => [setting.name, systemShownValue(root, context, setting)])),
243
+ },
244
+ note: campaignNote(root, context, true),
245
+ replaced,
246
+ part,
247
+ };
248
+ }
249
+ const ordersKept = "Kept until the player lifts it; the lines and veils still come first. An order for this scene only stays in the scene; when unsure, ask in one bracket.";
250
+ // The settings of free words the player may leave unset again, with the value none, and all those of how the master writes (D-395).
251
+ const freeSettingNames = ["author", "style", "calendar"];
252
+ /** A setting the game system adds, shown, or changed to one of its values (DAT-10); refused with them for any other. */
253
+ function systemSettingResult(root, context, setting, input) {
254
+ if (input.add !== undefined || input.remove !== undefined) {
255
+ throw new Error(`${setting.name} takes one value, ${valuesText(setting)}, such as setting ${setting.name}, value ${setting.values[0].value}. Nothing changed.`);
256
+ }
257
+ if (input.value !== undefined) {
258
+ const given = input.value.trim();
259
+ const value = setting.values.find((candidate) => comparableText(candidate.value) === comparableText(given));
260
+ if (value === undefined) {
261
+ throw new Error(`"${given}" is not a value of ${setting.name}, which takes ${setting.values.map((candidate) => `${candidate.value} (${candidate.means})`).join("; or ")}. Nothing changed.`);
262
+ }
263
+ const before = campaignSystem(root, context)?.version?.name;
264
+ if (changeOtherSetting(root, setting.name, value.value)) {
265
+ appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: setting.name, value: value.value }));
266
+ }
267
+ // Another version of the rules holds from the next read; what is written stays (VER-4).
268
+ if (setting.name === rulesetSetting && before !== undefined && comparableText(before) !== comparableText(value.value)) {
269
+ return {
270
+ settings: { [setting.name]: systemShownValue(root, context, setting) },
271
+ note: campaignNote(root, context, true),
272
+ replaced: [`From now on the campaign plays the rules ${value.value}, in place of ${before}: the pages already written stay as they are.`, ...unofferedLines(root, context)],
273
+ };
274
+ }
275
+ // The master's own change of a value brings its part, as the player's does with the dashboard's news (DAT-18).
276
+ const part = context.actor === "player" || campaignMode(root, campaignWorld(root, context)) !== "play" ? undefined : valuePart(root, context, setting.name, value.value);
277
+ return {
278
+ settings: { [setting.name]: systemShownValue(root, context, setting) },
279
+ note: campaignNote(root, context, true),
280
+ replaced: unofferedLines(root, context),
281
+ ...(part === undefined ? {} : { part }),
282
+ };
283
+ }
284
+ return { settings: { [setting.name]: systemShownValue(root, context, setting) }, note: campaignNote(root, context, true), replaced: [] };
285
+ }
286
+ /** A setting's value as config writes it: an installed system by the name it is installed under (D-167), the coins read and checked (MON-1), anything else as given. */
287
+ function settingValue(root, setting, value, context) {
288
+ if (setting === "calendar") {
289
+ const read = yamlValue(value, "the calendar", "months: [{name: January, days: 31, season: winter}, ...]");
290
+ try {
291
+ return readCalendar(read);
292
+ }
293
+ catch (error) {
294
+ throw new Error(`${error instanceof Error ? error.message : String(error)} Nothing changed.`);
295
+ }
296
+ }
297
+ if (setting === "calendar-start") {
298
+ return calendarStartValue(root, context, value);
299
+ }
300
+ // The game time between sessions (D-133): it stops, or runs at a rate of game time to real time.
301
+ if (setting === "between-sessions") {
302
+ if (readBetweenSessions(value) === undefined) {
303
+ throw new Error(`"${value}" is no between-sessions: give stops, or the game time that passes for a real time, such as 1d per 7d. Nothing changed.`);
304
+ }
305
+ return value.trim().replace(/\s+/g, " ");
306
+ }
307
+ return setting === "coins" ? newCoins(root, value, context) : setting === "system" ? installedSystemName(value, context, "config") : value;
308
+ }
309
+ /**
310
+ * The system stays once the campaign has a player character, whose sheet is written in it, whatever the mode (D-519): another installed one, or none, is
311
+ * refused, with a new campaign as the way; the same one, by any case, is no change.
312
+ */
313
+ function checkSystemOpen(root, context, value) {
314
+ const current = readTextSetting(root, "system");
315
+ // A name that is no installed system is said as such first; none takes the system away.
316
+ const asked = value.trim().toLowerCase() === "none" ? value : installedSystemName(value, context, "config");
317
+ if (current === undefined || comparableText(current) === comparableText(asked)) {
318
+ return;
319
+ }
320
+ const players = playersOfTheGame(root, context);
321
+ if (players.length > 0) {
322
+ const name = readSettings(root).name;
323
+ throw new Error(`The system of ${name} is ${current}, and the game has begun with ${players.join(", ")}: a campaign keeps its system. To play another, start a new campaign with init. Nothing changed.`);
324
+ }
325
+ }
326
+ /** When the story starts, day 1 or a day of the campaign's calendar (TIM-8), checked and written as given. */
327
+ function calendarStartValue(root, context, value) {
328
+ try {
329
+ readCalendarStart(value, campaignCalendar(root, context).calendar);
330
+ }
331
+ catch (error) {
332
+ throw new Error(`${error instanceof Error ? error.message : String(error)} Nothing changed.`);
333
+ }
334
+ return value.trim().replace(/\s+/g, " ");
335
+ }
336
+ /** The coins given to config, refused when money already written in the world would no longer read as money with them (MON-1). */
337
+ function newCoins(root, text, context) {
338
+ const coins = readCoins(text);
339
+ const before = campaignCoins(root, context).coins;
340
+ if (before === undefined) {
341
+ return coins;
342
+ }
343
+ const after = coinList(coins);
344
+ const scene = readOpenScene(root).scene;
345
+ const world = campaignWorld(root, context);
346
+ const holders = [...world.pages.map((page) => ({ name: page.name, fields: page.fields })), ...Object.entries(scene?.copies ?? {}).map(([name, copy]) => ({ name, fields: copy }))];
347
+ // A field the game system declares is never money (SYS-8).
348
+ const lost = holders.flatMap((holder) => Object.entries(holder.fields).filter(([field, value]) => declaredKind(world, field) === undefined && readAmount(value, before) !== undefined && readAmount(value, after) === undefined)
349
+ .map(([field, value]) => `${holder.name}: ${field} ${String(value)}`));
350
+ if (lost.length > 0) {
351
+ const more = lost.length > 5 ? `, and ${lost.length - 5} more` : "";
352
+ throw new Error(`With these coins, money already written would no longer be money: ${lost.slice(0, 5).join("; ")}${more}. Keep their coins in the list (another name works too, such as gp/mo), or change those first. Nothing changed.`);
353
+ }
354
+ return coins;
355
+ }