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
@@ -0,0 +1,124 @@
1
+ // Reads what set, add and remove give: assignments, lists, money, and leaves out fields the system works out
2
+ import { numberOf } from "../../core/formula.js";
3
+ import { comparableText } from "../../core/text.js";
4
+ import { formatAmount, namesCoins, readAmount } from "../../money/index.js";
5
+ import { declaredKind, linkListItems, listFieldNames, readFieldValue } from "../../pages/index.js";
6
+ import { effectiveFields } from "../shared/sheet/effect-layer.js";
7
+ import { computedField, directBonuses } from "../shared/sheet/worked-out.js";
8
+ import { signedText } from "../shared/sheet/worked-text.js";
9
+ /** Fields from field=value pairs, each value read as a link, links, a number, true or false, a list or text; or from an object, as they are. */
10
+ export function readFields(fields) {
11
+ if (!Array.isArray(fields)) {
12
+ return Object.fromEntries(Object.entries(fields).map(([name, value]) => [name, listFromText(name, value)]));
13
+ }
14
+ // The same name twice would be lost in one object; the same field in another case is refused later, with the other changes.
15
+ const entries = fields.map(readAssignment);
16
+ const repeated = entries.find(([name], index) => entries.findIndex(([other]) => other === name) !== index);
17
+ if (repeated !== undefined) {
18
+ throw new Error(`The field ${repeated[0]} is given twice: give each field once.`);
19
+ }
20
+ return Object.fromEntries(entries);
21
+ }
22
+ /** Items for list fields: each value gives one item, or several when it is a list; the same field may come more than once. */
23
+ export function readListItems(fields) {
24
+ // No prototype: a field named constructor or toString is a field like any other.
25
+ const items = Object.create(null);
26
+ for (const [name, given] of Array.isArray(fields) ? fields.map(readAssignment) : Object.entries(fields)) {
27
+ const value = listFromText(name, given);
28
+ items[name] = [...(items[name] ?? []), ...(Array.isArray(value) ? value : [value])];
29
+ }
30
+ return items;
31
+ }
32
+ function readAssignment(assignment) {
33
+ const separator = assignment.indexOf("=");
34
+ const value = assignment.slice(separator + 1).trim();
35
+ if (separator <= 0 || value === "") {
36
+ throw new Error(`Write a field as field=value, not "${assignment}". To remove a field, use unset.`);
37
+ }
38
+ return [assignment.slice(0, separator).trim(), readFieldValue(value)];
39
+ }
40
+ /**
41
+ * Text given through MCP to a field that is always a list, such as "[[A]], [[B]]", or written as a list, such as "[dex, int]", read as the command line reads it
42
+ * (D-136); any other value as it is.
43
+ */
44
+ function listFromText(name, value) {
45
+ if (typeof value !== "string") {
46
+ return value;
47
+ }
48
+ // Links separated by commas are a list, as on the command line, for a list of the game system too, such as spells (T-167).
49
+ const writtenAsList = /^\[(?!\[).*\]$/s.test(value.trim()) || linkListItems(value) !== undefined;
50
+ return writtenAsList || listFieldNames.some((field) => comparableText(field) === comparableText(name)) ? readFieldValue(value) : value;
51
+ }
52
+ /**
53
+ * A field that is always a list, or that the game system declares one, given one item, such as contains=[[Locanda]] or tags=boss, holds a list of that one item;
54
+ * text with commas is left to the checks that ask for a list, but a road's stops, links and lengths taking turns, which are split at the commas (ROA-6).
55
+ */
56
+ export function oneItemLists(world, set, type) {
57
+ const isList = (name) => listFieldNames.some((field) => comparableText(field) === comparableText(name)) || declaredKind(world, name) === "list";
58
+ const listOf = (name, value) => {
59
+ if (typeof value !== "string" || !isList(name) || value.trim() === "") {
60
+ return value;
61
+ }
62
+ return comparableText(name) === "stops" && type === "place" ? value.split(",").map((item) => item.trim()) : value.includes(",") ? value : [value];
63
+ };
64
+ return Object.fromEntries(Object.entries(set).map(([name, value]) => [name, listOf(name, value)]));
65
+ }
66
+ /**
67
+ * The fields given to set without those the game system works out on the page as the write leaves it, a copy in the open scene or a page that gets its base in
68
+ * the same write included (FOR-7), with a note that gives the values the system works out and what they come from.
69
+ */
70
+ export function withoutComputed(world, target, set, name, type) {
71
+ const after = { ...(target ?? { name, path: "", body: "" }), type: type ?? target?.type, fields: { ...(target?.fields ?? {}), ...set } };
72
+ const fields = effectiveFields(world, after);
73
+ const computed = Object.entries(set).flatMap(([field, given]) => {
74
+ const found = computedField(world, field, fields);
75
+ return found === undefined ? [] : [{ ...found, given }];
76
+ });
77
+ if (computed.length === 0) {
78
+ return { set };
79
+ }
80
+ const kept = Object.fromEntries(Object.entries(set).filter(([field]) => !computed.some((found) => comparableText(found.name) === comparableText(field))));
81
+ const values = computed.map((found) => {
82
+ const value = signedText(world, found.name, found.value);
83
+ return `${found.name} ${value}${numberOf(found.given) === found.value ? ", as you gave it" : ` (you gave ${String(found.given)})`}`;
84
+ });
85
+ const sources = [...new Set(computed.flatMap((found) => found.from))];
86
+ const bonuses = [...new Set(computed.flatMap((found) => directBonuses(world, found)))];
87
+ const bonus = bonuses.length === 0 ? "" : ` A bonus such as ${bonuses[0]} comes from an effect, for what gives one, such as a magic item.`;
88
+ const note = `Not written, the system ${world.system?.name ?? ""} works ${computed.length === 1 ? "it" : "them"} out: ${values.join("; ")}. They come from ${sources.join(", ")}.${bonus}`;
89
+ return { set: kept, note };
90
+ }
91
+ /** The items given to add or remove without the fields the game system works out on the page, which no list change writes (FOR-7, D-200), with a note. */
92
+ export function listsWithoutComputed(world, target, lists) {
93
+ if (lists === undefined || target === undefined) {
94
+ return { lists };
95
+ }
96
+ const fields = effectiveFields(world, target);
97
+ const computed = Object.keys(lists).flatMap((field) => computedField(world, field, fields) ?? []);
98
+ if (computed.length === 0) {
99
+ return { lists };
100
+ }
101
+ const kept = Object.fromEntries(Object.entries(lists).filter(([field]) => !computed.some((found) => comparableText(found.name) === comparableText(field))));
102
+ const values = computed.map((found) => `${found.name} ${signedText(world, found.name, found.value)}`).join("; ");
103
+ const sources = [...new Set(computed.flatMap((found) => found.from))].join(", ");
104
+ return {
105
+ lists: Object.keys(kept).length === 0 ? undefined : kept,
106
+ note: `Not written, the system ${world.system?.name ?? ""} works ${computed.length === 1 ? "it" : "them"} out: ${values}. ${computed.length === 1 ? "It comes" : "They come"} from ${sources}.`,
107
+ };
108
+ }
109
+ /** Money given to set, written as the engine writes it (MON-2): from the coin worth most, by first names. A field the game system declares is never money (SYS-8). */
110
+ export function asAmounts(world, set, coins) {
111
+ return Object.fromEntries(Object.entries(set).map(([field, value]) => {
112
+ const purse = coins === undefined || declaredKind(world, field) !== undefined ? undefined : readAmount(value, coins);
113
+ return [field, purse === undefined || coins === undefined ? value : formatAmount(purse, coins)];
114
+ }));
115
+ }
116
+ /** What a write should say about money: a value that names coins but does not read as money, and coins that cannot be read (MON-2, MON-8). */
117
+ export function moneyNotesOf(world, page, set, coins, problem) {
118
+ // A field the game system declares is never money (SYS-8).
119
+ const texts = Object.entries(set ?? {}).filter(([field, value]) => typeof value === "string" && declaredKind(world, field) === undefined);
120
+ const unread = coins === undefined ? [] : texts.filter(([, value]) => readAmount(value, coins) === undefined && namesCoins(value, coins));
121
+ const notes = unread.map(([field, value]) => `${field} on ${page} is "${value}", which is not money: write the coins one after the other, such as ${field}=12 ${coins?.[0].name ?? ""}, to count them.`);
122
+ const looksLikeMoney = texts.some(([, value]) => /\d+\s*\p{L}/u.test(value));
123
+ return problem !== undefined && looksLikeMoney ? [...notes, `The campaign's coins cannot be read, so no money is counted: ${problem.message} To fix it, ${problem.fix}.`] : notes;
124
+ }
@@ -0,0 +1,36 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import type { Coin } from "../../money/index.ts";
3
+ import { type FieldChange, type Page, type TextMode, type World } from "../../pages/index.ts";
4
+ import type { readOpenScene } from "../shared/scene/scene.ts";
5
+ /** What a write did to a layer, as write says it. */
6
+ export interface LayerResult {
7
+ page: string;
8
+ type?: Page["type"];
9
+ path: string;
10
+ changed: boolean;
11
+ set: string[];
12
+ again: string[];
13
+ unset: string[];
14
+ section?: string;
15
+ mode?: TextMode;
16
+ followers: string[];
17
+ followersWhy: string;
18
+ notes: string[];
19
+ }
20
+ /** What write with layer is given, beside the fields. */
21
+ interface LayerInput {
22
+ name: string;
23
+ type?: string;
24
+ text?: string;
25
+ section?: string;
26
+ append?: boolean;
27
+ secret?: boolean;
28
+ why?: string;
29
+ copy?: string;
30
+ }
31
+ /**
32
+ * Writes the campaign's layer over a page of its game system (SYS-11): refused on a page of the campaign, a copy, a new type, and while copies of the page are in the
33
+ * open scene (INH-10). One hidden line in the log; a public one for each counter of the player's party that changes with it (INH-11).
34
+ */
35
+ export declare function writeCampaignLayer(root: string, context: Context, world: World, open: ReturnType<typeof readOpenScene>, input: LayerInput, fields: FieldChange, coins: Coin[] | undefined): LayerResult;
36
+ export {};
@@ -0,0 +1,48 @@
1
+ import { appendLogEntry } from "../../core/log.js";
2
+ import { findPage, pageWithPath, systemLabel, writeLayer } from "../../pages/index.js";
3
+ import { campaignSystem, campaignWorld } from "../shared/campaign/world.js";
4
+ import { newDatedLogEntry } from "../shared/time/time.js";
5
+ import { checkLayerFieldWrite } from "./checks.js";
6
+ import { followersOfWrite, logCounterChanges } from "./inheritance.js";
7
+ /**
8
+ * Writes the campaign's layer over a page of its game system (SYS-11): refused on a page of the campaign, a copy, a new type, and while copies of the page are in the
9
+ * open scene (INH-10). One hidden line in the log; a public one for each counter of the player's party that changes with it (INH-11).
10
+ */
11
+ export function writeCampaignLayer(root, context, world, open, input, fields, coins) {
12
+ if (input.copy !== undefined) {
13
+ throw new Error(`${input.copy} is a copy in the open scene: a layer changes a page of the game system for the whole campaign. Write the copy without layer. Nothing changed.`);
14
+ }
15
+ const page = findPage(world, input.name);
16
+ if (page === undefined) {
17
+ throw new Error(`There is no page named ${input.name}: a layer changes a page of the game system that exists, by its name. Nothing changed.`);
18
+ }
19
+ if (page.system === undefined) {
20
+ throw new Error(`${page.name} is a page of the campaign: write it without layer, which is only for a page of the game system, to change it for the whole campaign. Nothing changed.`);
21
+ }
22
+ if (input.type !== undefined) {
23
+ throw new Error(`A layer changes neither the type nor the name of ${page.name}, ${page.type ?? "a page"} of the system ${page.system}: leave type out. Nothing changed.`);
24
+ }
25
+ checkLayerFieldWrite(world, campaignSystem(root, context), open, page, fields);
26
+ const written = writeLayer(world, page, { ...fields, text: input.text, section: input.section, append: input.append, secret: input.secret });
27
+ const mode = textMode(input);
28
+ const result = { page: page.name, type: page.type, path: written.path, section: input.section, mode, set: written.set, again: written.again.map((field) => `${field} again as the system's`), unset: written.unset };
29
+ if (!written.changed) {
30
+ return { ...result, changed: false, followers: [], followersWhy: "", notes: [] };
31
+ }
32
+ appendLogEntry(root, newDatedLogEntry(root, context, "page-updated", "hidden", { page: page.name, layer: written.path, ...fields, section: input.section, text: input.text, mode, why: input.why }));
33
+ const now = campaignWorld(root, context);
34
+ const after = findPage(now, page.name) ?? page;
35
+ const followers = followersOfWrite(now, page, after);
36
+ logCounterChanges(root, context, world, now, followers.pages.map((follower) => [pageWithPath(world, follower.path) ?? follower, follower]), coins);
37
+ const note = written.removed
38
+ ? `The campaign's layer over ${page.name} is empty now, and its file is gone: ${page.name} reads as the system ${page.system} writes it again.`
39
+ : `${page.name} stays ${systemLabel(page)}, with the campaign's layer ${written.path} over it: show ${page.name} says what it changes.`;
40
+ return { ...result, changed: true, followers: followers.pages.map((follower) => follower.name), followersWhy: followers.why, notes: [note] };
41
+ }
42
+ /** How a write writes its text: added at the end, in place of the old text, or, empty for a section, removing it. */
43
+ function textMode(input) {
44
+ if (input.text === undefined) {
45
+ return undefined;
46
+ }
47
+ return input.append === true ? "append" : input.section !== undefined && input.text.trim() === "" ? "remove" : "replace";
48
+ }
@@ -0,0 +1,22 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import { type FieldChange, type Page, type World } from "../../pages/index.ts";
3
+ import type { GameSystem } from "../../systems/index.ts";
4
+ /**
5
+ * What the write set off in the story: the events it made due or that wait for the date it gave them (EVT-4, EVT-5), conditions on pages that do not exist yet,
6
+ * and the planned events and quests linked to what changed (D-117, EVT-7).
7
+ */
8
+ export declare function storyNotes(root: string, context: Context, before: World, after: World, existing: Page | undefined, page: Page): string[];
9
+ /** The part quest-ends when a quest is done or failed, such as the experience the story gives (D-233), once in a chat (D-97). */
10
+ export declare function questEndNotes(context: Context, system: GameSystem | undefined, existing: Page | undefined, page: Page): string[];
11
+ /** Whether this write ends a quest: done or failed now, and not before. */
12
+ export declare function questEnds(existing: Page | undefined, page: Page): boolean;
13
+ /**
14
+ * What a write should say of the links it gave in fields the game system declares, such as spells (D-216): those to pages that do not exist yet, which the world
15
+ * gets with write, and those to a page that shares its name with another, as Shield the item beside Shield (spell). A campaign played in another language is
16
+ * told the system's. The core's fields, as contains or knows, link ahead to pages still to write.
17
+ */
18
+ export declare function linkNotes(world: World, change: FieldChange): string[];
19
+ /** "torce 7" written in an inventory: a count inside a text, which nothing counts, and how goods are counted instead (STK-10). */
20
+ export declare function countedTextNotes(existing: Page | undefined, page: Page): string[];
21
+ /** The thresholds the fields a write gives touch on the player character or a companion, as change says them (DAT-3): exhaustion written with write shows its rule. */
22
+ export declare function writtenThresholdNotes(root: string, system: GameSystem | undefined, before: World, after: World, existing: Page | undefined, page: Page, set: Record<string, unknown>): string[];
@@ -0,0 +1,76 @@
1
+ import { comparableText, valueNamed, withArticle } from "../../core/text.js";
2
+ import { containerFieldOf, countedText as countInText, declaredKind, linksIn, namesakes, pagesWithName, readEntry, systemLabel, systemPageNamed, textsIn } from "../../pages/index.js";
3
+ import { situationPart } from "../shared/campaign/parts.js";
4
+ import { foreignSystemLanguage } from "../shared/campaign/world.js";
5
+ import { effectiveFields } from "../shared/sheet/effect-layer.js";
6
+ import { thresholdNotes } from "../shared/sheet/thresholds.js";
7
+ import { conditionNotes, consequencesNotes, fireEvents, heldNote, nowDueNote } from "../shared/time/events.js";
8
+ import { readPresent } from "../shared/time/time.js";
9
+ /**
10
+ * What the write set off in the story: the events it made due or that wait for the date it gave them (EVT-4, EVT-5), conditions on pages that do not exist yet,
11
+ * and the planned events and quests linked to what changed (D-117, EVT-7).
12
+ */
13
+ export function storyNotes(root, context, before, after, existing, page) {
14
+ const present = readPresent(root).date;
15
+ const fired = fireEvents(root, context, before, after, present);
16
+ const written = fired.world.pages.find((candidate) => candidate.path === page.path) ?? page;
17
+ const conditions = page.type === "event" && JSON.stringify(existing?.fields.when) !== JSON.stringify(page.fields.when) ? conditionNotes(fired.world, page.fields.when) : [];
18
+ const consequences = consequencesNotes(fired.world, existing, written, fired.due.map((event) => event.name), present);
19
+ return [nowDueNote(fired.due), heldNote(fired.held), ...conditions, ...consequences].filter((note) => note !== "");
20
+ }
21
+ /** The part quest-ends when a quest is done or failed, such as the experience the story gives (D-233), once in a chat (D-97). */
22
+ export function questEndNotes(context, system, existing, page) {
23
+ if (!questEnds(existing, page)) {
24
+ return [];
25
+ }
26
+ const part = situationPart("quest-ends", context, system);
27
+ return part === "" ? [] : [`${page.name} is ${String(page.fields.status)}. ${part}`];
28
+ }
29
+ /** Whether this write ends a quest: done or failed now, and not before. */
30
+ export function questEnds(existing, page) {
31
+ const ended = (candidate) => ["done", "failed"].includes(String(candidate?.fields.status));
32
+ return page.type === "quest" && ended(page) && !ended(existing);
33
+ }
34
+ /**
35
+ * What a write should say of the links it gave in fields the game system declares, such as spells (D-216): those to pages that do not exist yet, which the world
36
+ * gets with write, and those to a page that shares its name with another, as Shield the item beside Shield (spell). A campaign played in another language is
37
+ * told the system's. The core's fields, as contains or knows, link ahead to pages still to write.
38
+ */
39
+ export function linkNotes(world, change) {
40
+ // The base a creature or an item derives from too, as item=[[Spada lunga]] for Longsword.
41
+ const told = (field) => declaredKind(world, field) !== undefined || ["creature", "item"].includes(comparableText(field));
42
+ const given = [...Object.entries(change.set ?? {}), ...Object.entries(change.add ?? {})].filter(([field]) => told(field)).flatMap(([, value]) => linksIn(value));
43
+ const names = [...new Set(given)];
44
+ const exists = (name) => pagesWithName(world, name)[0] ?? systemPageNamed(world, name);
45
+ const missing = names.filter((name) => exists(name) === undefined);
46
+ const system = world.system;
47
+ const foreign = foreignSystemLanguage(world);
48
+ const language = system === undefined || foreign === undefined ? "" : ` The system ${system.name} names its pages in ${foreign}: find looks them up.`;
49
+ const absent = missing.length === 0
50
+ ? []
51
+ : [`No page for ${missing.map((name) => `[[${name}]]`).join(", ")} yet: create ${missing.length === 1 ? "it" : "them"} with write if ${missing.length === 1 ? "it belongs" : "they belong"} to this world, or link a page that exists.${language}`];
52
+ const twins = names.flatMap((name) => {
53
+ const page = exists(name);
54
+ const others = page === undefined ? [] : namesakes(world, page);
55
+ return page === undefined || others.length === 0 ? [] : [`[[${name}]] is ${page.system === undefined ? withArticle(page.type ?? "page") : systemLabel(page)}; there is also ${others.map((other) => other.name).join(", ")}.`];
56
+ });
57
+ return [...absent, ...twins];
58
+ }
59
+ /** "torce 7" written in an inventory: a count inside a text, which nothing counts, and how goods are counted instead (STK-10). */
60
+ export function countedTextNotes(existing, page) {
61
+ const field = containerFieldOf(page.type);
62
+ const before = field === undefined ? [] : textsIn(existing?.fields[field]).map((entry) => entry.trim());
63
+ const added = field === undefined ? [] : textsIn(page.fields[field]).filter((entry) => !before.includes(entry.trim()));
64
+ return added.filter((entry) => readEntry(entry).shape === "text" && countInText(entry) !== undefined).map((entry) => `"${entry}" is a count inside a text, which nothing counts: goods are a stack, a kind and how many. The system's kinds go by their English names, as find shows them: `
65
+ + `write the one it has with your word as its label, such as [[Torch|torcia]] 3; only what the system lacks becomes a kind of the campaign, made first with write "<name>", type item.`);
66
+ }
67
+ /** The thresholds the fields a write gives touch on the player character or a companion, as change says them (DAT-3): exhaustion written with write shows its rule. */
68
+ export function writtenThresholdNotes(root, system, before, after, existing, page, set) {
69
+ const read = (fields, field) => valueNamed(fields, field);
70
+ const was = existing === undefined ? {} : effectiveFields(before, existing);
71
+ const is = effectiveFields(after, page);
72
+ return Object.keys(set).flatMap((field) => {
73
+ const [from, to] = [read(was, field), read(is, field)];
74
+ return String(from) === String(to) ? [] : thresholdNotes(root, system, field, { before: from, after: to, amount: {} });
75
+ });
76
+ }
@@ -0,0 +1,27 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import { type Page, type World } from "../../pages/index.ts";
3
+ import type { GameSystem } from "../../systems/index.ts";
4
+ /**
5
+ * What a change of classes gives or takes (PRO-4): the features of the rows it reaches, new, gained again or with a new value, those no longer had, the values of
6
+ * the rows and of the formulas of the classes' pages that change, and, when a class rises, the system's note for a new level (D-226), unless the same write sets
7
+ * a field it names, as hp-base. Nothing when the classes give the same.
8
+ */
9
+ export declare function progressionNotes(context: Context, system: GameSystem | undefined, before: World, after: World, existing: Page, page: Page, set: string[]): string[];
10
+ /** A section of a character with the name of a feature its classes give: show gives it in place of the feature's text (PRO-4). */
11
+ export declare function featureSectionNotes(world: World, page: Page, section: string): string[];
12
+ /** Items written in a list where the parts of the classes already put them, as a domain's spell in prepared: always there, they do not count with the rest (PRO-7). */
13
+ export declare function givenListNotes(world: World, page: Page, changed: string[]): string[];
14
+ /**
15
+ * When the items of a list give a field another formula reads, as two armors in equipped or Unarmored Defense from two classes, the formula reads the first
16
+ * (PRO-5): said when a write makes it so.
17
+ */
18
+ export declare function firstItemNotes(before: World, after: World, existing: Page | undefined, page: Page): string[];
19
+ /**
20
+ * The counters of a page whose written maximum is not what the game system works out from the page without its effects, set to it, and a note (FOR-6). A use
21
+ * that only the lists give and that the page no longer has, with a maximum of 0 or none where it had one, is taken off (DAT-9).
22
+ */
23
+ export declare function workedLimitsChange(system: GameSystem | undefined, before: World, existing: Page | undefined, world: World, page: Page): {
24
+ set: Record<string, unknown>;
25
+ unset: string[];
26
+ notes: string[];
27
+ };
@@ -0,0 +1,175 @@
1
+ import { fieldsRead, listItemNames } from "../../core/formula.js";
2
+ import { comparableText, sameName, valueNamed } from "../../core/text.js";
3
+ import { formatCounter, readCounter } from "../../counters/index.js";
4
+ import { declaredKind, inheritedFields } from "../../pages/index.js";
5
+ import { featureParts, mergedFeatures } from "../../progression/index.js";
6
+ import { partText, situationPart } from "../shared/campaign/parts.js";
7
+ import { effectiveFields } from "../shared/sheet/effect-layer.js";
8
+ import { givenItems, progressionOf } from "../shared/sheet/progression.js";
9
+ import { hasSheet, isUse } from "../shared/sheet/system-fields.js";
10
+ import { counterLimits, itemLines, maximumSources, missingUses, workedMaximum } from "../shared/sheet/worked-out.js";
11
+ import { signedText, workedParts } from "../shared/sheet/worked-text.js";
12
+ import { askedFields } from "./checks.js";
13
+ /**
14
+ * What a change of classes gives or takes (PRO-4): the features of the rows it reaches, new, gained again or with a new value, those no longer had, the values of
15
+ * the rows and of the formulas of the classes' pages that change, and, when a class rises, the system's note for a new level (D-226), unless the same write sets
16
+ * a field it names, as hp-base. Nothing when the classes give the same.
17
+ */
18
+ export function progressionNotes(context, system, before, after, existing, page, set) {
19
+ const was = progressionOf(before, effectiveFields(before, existing));
20
+ const is = progressionOf(after, effectiveFields(after, page));
21
+ const gains = rowGains(was, is);
22
+ const lost = (was?.features ?? []).map((feature) => feature.name).filter((name) => !(is?.features ?? []).some((other) => sameFeature(other.name, name)));
23
+ // The maximum of a use the rows give is said with the counters (FOR-6).
24
+ const counters = Object.keys(after.system?.formulas?.counters ?? {});
25
+ const valueOf = (progression, field) => {
26
+ const found = progression?.values.find((value) => comparableText(value.field) === comparableText(field));
27
+ return found === undefined ? undefined : signedText(after, found.field, found.value);
28
+ };
29
+ const fields = [...new Set([...(was?.values ?? []), ...(is?.values ?? [])].map((value) => value.field))].filter((field) => !counters.some((counter) => comparableText(counter) === comparableText(field)));
30
+ const values = fields.flatMap((field) => {
31
+ const [from, to] = [valueOf(was, field), valueOf(is, field)];
32
+ return from === to ? [] : [`${field} ${from ?? "none"} → ${to ?? "none"}`];
33
+ });
34
+ // What the formulas of the classes' pages give, as the prepared spells of a new level (PRO-5).
35
+ const [then, now] = [effectiveFields(before, existing), effectiveFields(after, page)];
36
+ const formulaValues = (after.system?.itemFormulas?.[after.system.progression?.list ?? ""] ?? []).flatMap((field) => {
37
+ const [from, to] = [valueNamed(then, field), valueNamed(now, field)];
38
+ const text = (value) => (value === undefined ? "none" : typeof value === "number" ? signedText(after, field, value) : String(value));
39
+ return text(from) === text(to) ? [] : [`${field} ${text(from)} → ${text(to)}`];
40
+ });
41
+ const shown = gains.fresh[0] ?? gains.better[0]?.name;
42
+ const parts = [
43
+ gains.fresh.length === 0 ? "" : `${gains.fresh.join(", ")} ${gains.fresh.length === 1 ? "is" : "are"} new`,
44
+ gains.again.length === 0 ? "" : `${gains.again.join(", ")} again`,
45
+ gains.better.map((feature) => feature.text).join(", "),
46
+ lost.length === 0 ? "" : `no longer ${lost.join(", ")}`,
47
+ [...values, ...formulaValues].join(", "),
48
+ ].filter((part) => part !== "");
49
+ const hint = shown === undefined ? "" : ` show ${page.name}#${featureParts(shown).name} gives a feature's text.`;
50
+ const levelUp = partText("level-up", system);
51
+ // A new level is one more in all: a class changed for another of a lower level is none.
52
+ const levels = (progression) => (progression?.from ?? []).reduce((total, item) => total + (item.level ?? 0), 0);
53
+ // Not said when the same write sets a field the note names, as hp-base: it is already done.
54
+ const named = new Set((levelUp?.match(/[\p{L}\p{N}-]+/gu) ?? []).map(comparableText));
55
+ const done = set.some((field) => named.has(comparableText(field)));
56
+ // The part level-up, once in a chat (D-97).
57
+ const risen = levelUp !== undefined && levels(is) > levels(was) && !done ? situationPart("level-up", context, system) : "";
58
+ // A value that ends in a period, such as +10 ft., ends the line.
59
+ const said = parts.length === 0 ? [] : [`What ${page.name}'s ${is?.lists[0] ?? was?.lists[0] ?? "classes"} give: ${parts.join("; ").replace(/\.$/, "")}.${hint}`];
60
+ return [...said, ...(risen === "" ? [] : [risen])];
61
+ }
62
+ /**
63
+ * The features the rows and parts give now that they did not before, each name once (PRO-3): new to the character, gained again, as a later Ability Score
64
+ * Improvement, or with a new value, as "Bardic Inspiration (d6 → d8)".
65
+ */
66
+ function rowGains(was, is) {
67
+ const key = (gain) => `${gain.page.path}|${gain.level}|${comparableText(gain.name)}`;
68
+ const old = new Set((was?.gains ?? []).map(key));
69
+ const had = was?.features ?? [];
70
+ const result = { fresh: [], again: [], better: [] };
71
+ for (const gain of mergedFeatures((is?.gains ?? []).filter((candidate) => !old.has(key(candidate))))) {
72
+ const before = had.find((feature) => sameFeature(feature.name, gain.name))?.name;
73
+ const [then, now] = [featureParts(before ?? "").value, featureParts(gain.name).value];
74
+ if (before === undefined) {
75
+ result.fresh.push(gain.name);
76
+ }
77
+ else if (now !== undefined && then !== undefined && comparableText(now) !== comparableText(then)) {
78
+ result.better.push({ name: gain.name, text: `${featureParts(gain.name).name} (${then.slice(1, -1)} → ${now.slice(1, -1)})` });
79
+ }
80
+ else {
81
+ result.again.push(featureParts(gain.name).name);
82
+ }
83
+ }
84
+ return result;
85
+ }
86
+ /** Whether two names are the same feature, with or without a value in parentheses (PRO-3). */
87
+ function sameFeature(first, second) {
88
+ return comparableText(featureParts(first).name) === comparableText(featureParts(second).name);
89
+ }
90
+ /** A section of a character with the name of a feature its classes give: show gives it in place of the feature's text (PRO-4). */
91
+ export function featureSectionNotes(world, page, section) {
92
+ const feature = progressionOf(world, effectiveFields(world, page))?.features.find((candidate) => sameFeature(candidate.name, section));
93
+ return feature === undefined ? [] : [`show ${page.name}#${section} now gives this section, not the text of the feature ${featureParts(feature.name).name} its classes give.`];
94
+ }
95
+ /** Items written in a list where the parts of the classes already put them, as a domain's spell in prepared: always there, they do not count with the rest (PRO-7). */
96
+ export function givenListNotes(world, page, changed) {
97
+ const progression = progressionOf(world, effectiveFields(world, page));
98
+ return changed.flatMap((field) => {
99
+ const written = listItemNames(valueNamed(page.fields, field));
100
+ const twice = givenItems(progression, field).filter((item) => sameName(written, item.name) !== undefined);
101
+ const pages = [...new Set(twice.map((item) => item.page.name))].join(" and ");
102
+ return twice.length === 0
103
+ ? []
104
+ : [`${twice.map((item) => item.name).join(", ")} ${twice.length === 1 ? "is" : "are"} always in ${field}, from ${pages}, and not counted with the rest: write ${page.name}, remove ${field}=${twice[0].name}, to choose another in its place.`];
105
+ });
106
+ }
107
+ /**
108
+ * When the items of a list give a field another formula reads, as two armors in equipped or Unarmored Defense from two classes, the formula reads the first
109
+ * (PRO-5): said when a write makes it so.
110
+ */
111
+ export function firstItemNotes(before, after, existing, page) {
112
+ const computed = after.system?.formulas?.computed ?? [];
113
+ return Object.entries(after.system?.itemFormulas ?? {}).flatMap(([list, names]) => names.flatMap((field) => {
114
+ const readers = computed.filter(([, formula]) => fieldsRead(formula).some((name) => comparableText(name) === comparableText(field))).map(([name]) => name);
115
+ const giving = (world, fields) => itemLines(world, fields, list, [field]).map((line) => line.item);
116
+ const is = readers.length === 0 ? [] : giving(after, effectiveFields(after, page));
117
+ const was = is.length < 2 || existing === undefined ? [] : giving(before, effectiveFields(before, existing));
118
+ if (is.length < 2 || (was.length === is.length && was.every((name, index) => comparableText(name) === comparableText(is[index])))) {
119
+ return [];
120
+ }
121
+ return [`${readers.join(", ")} ${readers.length === 1 ? "reads" : "read"} ${field} from ${is[0]}, the first in ${page.name}'s ${list} that gives it, not from ${is.slice(1).join(", ")}.`];
122
+ }));
123
+ }
124
+ /**
125
+ * The counters of a page whose written maximum is not what the game system works out from the page without its effects, set to it, and a note (FOR-6). A use
126
+ * that only the lists give and that the page no longer has, with a maximum of 0 or none where it had one, is taken off (DAT-9).
127
+ */
128
+ export function workedLimitsChange(system, before, existing, world, page) {
129
+ const fields = inheritedFields(world, page);
130
+ const old = existing === undefined ? undefined : inheritedFields(before, existing);
131
+ const changes = Object.keys(world.system?.formulas?.counters ?? {}).flatMap((field) => {
132
+ const key = sameName(Object.keys(page.fields), field);
133
+ const counter = key === undefined ? undefined : readCounter(page.fields[key]);
134
+ const { max } = counterLimits(world, fields, field);
135
+ const had = old === undefined || max !== undefined ? undefined : counterLimits(before, old, field).max;
136
+ const limit = max ?? (had === undefined ? undefined : 0);
137
+ if (key === undefined || counter === undefined || limit === undefined || counter.max === limit) {
138
+ return [];
139
+ }
140
+ // Of a use, what was spent stays spent, as a table counts it: a maximum that grows by 3 gives 3 more; one that falls only caps the current, as the SRD does,
141
+ // but for what an effect allows above the written maximum (FOR-6, D-228). Any other counter keeps its current, which reads no higher than the maximum.
142
+ const grows = counter.max !== undefined && limit > counter.max;
143
+ const capped = counter.max !== undefined && counter.value <= counter.max ? Math.max(0, Math.min(counter.value, limit)) : counter.value;
144
+ const value = !isUse(world, key) || counter.max === undefined ? counter.value : grows ? counter.value + limit - counter.max : capped;
145
+ return [{ key, before: counter.max, value: formatCounter({ value, max: limit }), reads: formatCounter({ value: Math.min(value, limit), max: limit }), max: limit, lost: max === undefined }];
146
+ });
147
+ // Only a use that the lists give, such as rages from the classes, never one the sheet asks to write, as hp: it stays at any maximum.
148
+ const asked = askedFields(system);
149
+ // A maximum from a class's row, with no formula, has no sources: the lists give it.
150
+ const givenByLists = (field) => {
151
+ const sources = maximumSources(world, field, fields);
152
+ return !asked.has(comparableText(field)) && (sources.length === 0 || sources.some((name) => declaredKind(world, name) === "list"));
153
+ };
154
+ // A use whose maximum has no value now, where it had one, as the slots of a caster who is one no more, is no longer the character's either.
155
+ const gone = changes.filter((change) => change.max <= 0 && isUse(world, change.key) && !asked.has(comparableText(change.key)) && (change.lost || givenByLists(change.key)));
156
+ const kept = changes.filter((change) => !gone.includes(change));
157
+ // "hp 10/17 (max 10 → 17: hp-base 10, level 2, con-mod +2)": what the maximum comes from, so that a written maximum is not taken for the dice.
158
+ const said = kept.map((change) => {
159
+ const parts = workedParts(world, workedMaximum(world, fields, change.key)?.reads ?? []);
160
+ return `${change.key} ${change.reads} (max ${change.before ?? "none"} → ${change.max}${parts === "" ? "" : `: ${parts}`})`;
161
+ });
162
+ // A use the page gets, such as a new level's channel-divinity, is written full on who keeps the sheet (DAT-9, D-225).
163
+ const added = hasSheet(world, page) ? missingUses(world, fields).map((use) => ({ key: use.field, value: formatCounter({ value: use.max, max: use.max }) })) : [];
164
+ const name = world.system?.name ?? "";
165
+ const notes = [
166
+ said.length === 0 ? "" : `${said.join(", ")}: worked out by the system ${name}.`,
167
+ added.length === 0 ? "" : `${page.name} has ${added.map((use) => `${use.key} ${use.value}`).join(", ")}, full: uses of the system ${name} that come back with a rest.`,
168
+ gone.length === 0 ? "" : `${page.name} no longer has ${gone.map((change) => change.key).join(", ")}: the system ${name} gives no uses of ${gone.length === 1 ? "it" : "them"} now.`,
169
+ ];
170
+ return {
171
+ set: Object.fromEntries([...kept, ...added].map((change) => [change.key, change.value])),
172
+ unset: gone.map((change) => change.key),
173
+ notes: notes.filter((note) => note !== ""),
174
+ };
175
+ }
@@ -30,11 +30,11 @@ interface WriteResult {
30
30
  export declare const write: import("../../core/registry.ts").Command<z.ZodObject<{
31
31
  page: z.ZodString;
32
32
  type: z.ZodOptional<z.ZodEnum<{
33
+ character: "character";
33
34
  place: "place";
34
35
  quest: "quest";
35
36
  creature: "creature";
36
37
  item: "item";
37
- character: "character";
38
38
  faction: "faction";
39
39
  event: "event";
40
40
  topic: "topic";
@@ -48,6 +48,7 @@ export declare const write: import("../../core/registry.ts").Command<z.ZodObject
48
48
  append: z.ZodOptional<z.ZodBoolean>;
49
49
  secret: z.ZodOptional<z.ZodBoolean>;
50
50
  here: z.ZodOptional<z.ZodBoolean>;
51
+ layer: z.ZodOptional<z.ZodBoolean>;
51
52
  why: z.ZodOptional<z.ZodString>;
52
53
  }, z.core.$strip>, WriteResult>;
53
54
  /**