rpg-engine 0.15.0 → 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 (486) hide show
  1. package/dist/campaign/index.d.ts +1 -1
  2. package/dist/campaign/index.js +1 -1
  3. package/dist/campaign/settings.d.ts +6 -0
  4. package/dist/campaign/settings.js +22 -1
  5. package/dist/cli/cli.js +1 -1
  6. package/dist/cli/command-line.js +1 -1
  7. package/dist/commands/advance.d.ts +1 -1
  8. package/dist/commands/advance.js +6 -6
  9. package/dist/commands/ask.js +7 -7
  10. package/dist/commands/change/amounts.d.ts +32 -0
  11. package/dist/commands/change/amounts.js +150 -0
  12. package/dist/commands/change/change.d.ts +4 -54
  13. package/dist/commands/change/change.js +19 -749
  14. package/dist/commands/change/damage.d.ts +30 -0
  15. package/dist/commands/change/damage.js +73 -2
  16. package/dist/commands/change/dice.d.ts +34 -0
  17. package/dist/commands/change/dice.js +59 -0
  18. package/dist/commands/change/fields.d.ts +37 -0
  19. package/dist/commands/change/fields.js +156 -0
  20. package/dist/commands/change/holder.d.ts +48 -0
  21. package/dist/commands/change/holder.js +162 -0
  22. package/dist/commands/change/recipe-pace.js +1 -1
  23. package/dist/commands/change/recipe.d.ts +58 -0
  24. package/dist/commands/change/recipe.js +179 -0
  25. package/dist/commands/choices.js +3 -3
  26. package/dist/commands/config/config.d.ts +15 -0
  27. package/dist/commands/config/config.js +355 -0
  28. package/dist/commands/config/custom-levels.d.ts +7 -0
  29. package/dist/commands/config/custom-levels.js +32 -0
  30. package/dist/commands/{config.d.ts → config/dashboard.d.ts} +2 -24
  31. package/dist/commands/config/dashboard.js +171 -0
  32. package/dist/commands/config/entries.d.ts +17 -0
  33. package/dist/commands/config/entries.js +76 -0
  34. package/dist/commands/config/news.d.ts +7 -0
  35. package/dist/commands/config/news.js +88 -0
  36. package/dist/commands/config/shown.d.ts +9 -0
  37. package/dist/commands/config/shown.js +80 -0
  38. package/dist/commands/config/words.d.ts +27 -0
  39. package/dist/commands/config/words.js +204 -0
  40. package/dist/commands/effect.js +9 -9
  41. package/dist/commands/find.js +1 -1
  42. package/dist/commands/image.js +6 -6
  43. package/dist/commands/import/import.d.ts +0 -2
  44. package/dist/commands/import/import.js +45 -44
  45. package/dist/commands/import/run.js +1 -1
  46. package/dist/commands/index.js +3 -3
  47. package/dist/commands/init.js +2 -2
  48. package/dist/commands/install.js +1 -1
  49. package/dist/commands/instructions.js +6 -6
  50. package/dist/commands/mode.d.ts +2 -2
  51. package/dist/commands/mode.js +8 -8
  52. package/dist/commands/mood.js +4 -4
  53. package/dist/commands/move.js +10 -10
  54. package/dist/commands/package/consent.d.ts +11 -0
  55. package/dist/commands/package/consent.js +52 -0
  56. package/dist/commands/package/here.d.ts +51 -0
  57. package/dist/commands/package/here.js +128 -0
  58. package/dist/commands/package/install.d.ts +10 -0
  59. package/dist/commands/package/install.js +337 -0
  60. package/dist/commands/package/package.d.ts +18 -0
  61. package/dist/commands/package/package.js +236 -0
  62. package/dist/commands/package/result.d.ts +90 -0
  63. package/dist/commands/package/result.js +1 -0
  64. package/dist/commands/package/uninstall.d.ts +6 -0
  65. package/dist/commands/package/uninstall.js +70 -0
  66. package/dist/commands/rename.js +3 -3
  67. package/dist/commands/reveal.js +5 -5
  68. package/dist/commands/roll/roll.js +11 -9
  69. package/dist/commands/roll/tables.js +1 -1
  70. package/dist/commands/rules.d.ts +2 -2
  71. package/dist/commands/rules.js +3 -3
  72. package/dist/commands/save.d.ts +1 -1
  73. package/dist/commands/save.js +2 -2
  74. package/dist/commands/scene/close.d.ts +18 -0
  75. package/dist/commands/scene/close.js +179 -0
  76. package/dist/commands/scene/members.d.ts +14 -0
  77. package/dist/commands/scene/members.js +32 -0
  78. package/dist/commands/scene/open.d.ts +6 -0
  79. package/dist/commands/scene/open.js +298 -0
  80. package/dist/commands/scene/result.d.ts +98 -0
  81. package/dist/commands/scene/result.js +2 -0
  82. package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
  83. package/dist/commands/scene/scene.js +210 -0
  84. package/dist/commands/scene/turns.d.ts +18 -0
  85. package/dist/commands/scene/turns.js +229 -0
  86. package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +5 -3
  87. package/dist/commands/shared/{adventures.js → books/adventures.js} +23 -19
  88. package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
  89. package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
  90. package/dist/commands/shared/{library.js → books/library.js} +9 -9
  91. package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
  92. package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
  93. package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
  94. package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
  95. package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
  96. package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
  97. package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
  98. package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
  99. package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
  100. package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
  101. package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
  102. package/dist/commands/shared/{mode.js → campaign/mode.js} +24 -13
  103. package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
  104. package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
  105. package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
  106. package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
  107. package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
  108. package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
  109. package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +3 -3
  110. package/dist/commands/shared/{parts.js → campaign/parts.js} +3 -3
  111. package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
  112. package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
  113. package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
  114. package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
  115. package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
  116. package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
  117. package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
  118. package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
  119. package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
  120. package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
  121. package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
  122. package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
  123. package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
  124. package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
  125. package/dist/commands/shared/characters/orders.d.ts +4 -0
  126. package/dist/commands/shared/characters/orders.js +10 -0
  127. package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +2 -2
  128. package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +3 -3
  129. package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
  130. package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
  131. package/dist/commands/shared/examples.js +2 -2
  132. package/dist/commands/shared/packages/catalog.js +2 -2
  133. package/dist/commands/shared/packages/code.d.ts +1 -1
  134. package/dist/commands/shared/packages/code.js +8 -8
  135. package/dist/commands/shared/packages/extensions.d.ts +1 -1
  136. package/dist/commands/shared/packages/extensions.js +1 -1
  137. package/dist/commands/shared/packages/hooks.d.ts +1 -1
  138. package/dist/commands/shared/packages/hooks.js +1 -1
  139. package/dist/commands/shared/packages/widgets.d.ts +3 -3
  140. package/dist/commands/shared/packages/widgets.js +3 -3
  141. package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
  142. package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
  143. package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
  144. package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
  145. package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
  146. package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
  147. package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
  148. package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
  149. package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
  150. package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
  151. package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
  152. package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
  153. package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
  154. package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
  155. package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
  156. package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
  157. package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
  158. package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
  159. package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
  160. package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
  161. package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
  162. package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
  163. package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
  164. package/dist/commands/shared/{scene.js → scene/scene.js} +7 -7
  165. package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
  166. package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
  167. package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
  168. package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
  169. package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
  170. package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
  171. package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
  172. package/dist/commands/shared/sheet/effect-values.js +69 -0
  173. package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
  174. package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
  175. package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
  176. package/dist/commands/shared/sheet/formula-problems.js +140 -0
  177. package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
  178. package/dist/commands/shared/sheet/formula-scope.js +235 -0
  179. package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
  180. package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
  181. package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
  182. package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
  183. package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +5 -5
  184. package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
  185. package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
  186. package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
  187. package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
  188. package/dist/commands/shared/sheet/system-fields.js +45 -0
  189. package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
  190. package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
  191. package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
  192. package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
  193. package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
  194. package/dist/commands/shared/sheet/worked-out.js +291 -0
  195. package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
  196. package/dist/commands/shared/sheet/worked-text.js +55 -0
  197. package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
  198. package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
  199. package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
  200. package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
  201. package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
  202. package/dist/commands/shared/{events.js → time/events.js} +10 -13
  203. package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
  204. package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
  205. package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
  206. package/dist/commands/shared/{time.js → time/time.js} +6 -6
  207. package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
  208. package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
  209. package/dist/commands/show.d.ts +3 -0
  210. package/dist/commands/show.js +28 -9
  211. package/dist/commands/status.d.ts +2 -1
  212. package/dist/commands/status.js +28 -22
  213. package/dist/commands/thoughts.js +3 -3
  214. package/dist/commands/trade.js +8 -8
  215. package/dist/commands/translate.d.ts +1 -1
  216. package/dist/commands/translate.js +3 -3
  217. package/dist/commands/travel/open.d.ts +1 -1
  218. package/dist/commands/travel/open.js +2 -2
  219. package/dist/commands/travel/route.js +7 -6
  220. package/dist/commands/travel/travel.d.ts +1 -1
  221. package/dist/commands/travel/travel.js +8 -8
  222. package/dist/commands/validate.js +3 -3
  223. package/dist/commands/view/journal.d.ts +2 -2
  224. package/dist/commands/view/journal.js +2 -2
  225. package/dist/commands/view/map.d.ts +1 -1
  226. package/dist/commands/view/map.js +6 -6
  227. package/dist/commands/view/memory.d.ts +16 -0
  228. package/dist/commands/view/memory.js +90 -0
  229. package/dist/commands/view/page.d.ts +32 -0
  230. package/dist/commands/view/page.js +163 -0
  231. package/dist/commands/view/place.d.ts +7 -2
  232. package/dist/commands/view/place.js +30 -12
  233. package/dist/commands/view/result.d.ts +245 -0
  234. package/dist/commands/view/result.js +1 -0
  235. package/dist/commands/view/saves.d.ts +6 -0
  236. package/dist/commands/view/saves.js +53 -0
  237. package/dist/commands/view/story.d.ts +32 -0
  238. package/dist/commands/view/story.js +227 -0
  239. package/dist/commands/view/view.d.ts +26 -292
  240. package/dist/commands/view/view.js +26 -534
  241. package/dist/commands/view/world.d.ts +1 -1
  242. package/dist/commands/view/world.js +3 -3
  243. package/dist/commands/write/checks.d.ts +42 -0
  244. package/dist/commands/write/checks.js +291 -0
  245. package/dist/commands/write/here.d.ts +1 -1
  246. package/dist/commands/write/here.js +5 -5
  247. package/dist/commands/write/inheritance.d.ts +40 -0
  248. package/dist/commands/write/inheritance.js +189 -0
  249. package/dist/commands/write/input.d.ts +29 -0
  250. package/dist/commands/write/input.js +124 -0
  251. package/dist/commands/write/layer.d.ts +36 -0
  252. package/dist/commands/write/layer.js +48 -0
  253. package/dist/commands/write/notes.d.ts +22 -0
  254. package/dist/commands/write/notes.js +76 -0
  255. package/dist/commands/write/progression.d.ts +27 -0
  256. package/dist/commands/write/progression.js +175 -0
  257. package/dist/commands/write/write.d.ts +1 -0
  258. package/dist/commands/write/write.js +32 -816
  259. package/dist/core/files.d.ts +2 -0
  260. package/dist/core/files.js +7 -0
  261. package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
  262. package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
  263. package/dist/core/session-store.js +3 -3
  264. package/dist/core/store.d.ts +2 -2
  265. package/dist/core/store.js +18 -4
  266. package/dist/dashboard/acts/acts.js +1 -1
  267. package/dist/dashboard/acts/sending.js +110 -0
  268. package/dist/dashboard/acts/sheet.js +2 -2
  269. package/dist/dashboard/acts/strip.js +1 -1
  270. package/dist/dashboard/address.js +6 -0
  271. package/dist/dashboard/api.js +1 -1
  272. package/dist/dashboard/app.js +47 -171
  273. package/dist/dashboard/dice/roller.js +1 -1
  274. package/dist/dashboard/dice/sets.js +2 -2
  275. package/dist/dashboard/dice/stage.js +1 -1
  276. package/dist/dashboard/dice/tray.js +6 -6
  277. package/dist/dashboard/guide/ar.md +5 -3
  278. package/dist/dashboard/guide/cs.md +5 -3
  279. package/dist/dashboard/guide/da.md +5 -3
  280. package/dist/dashboard/guide/de.md +5 -3
  281. package/dist/dashboard/guide/el.md +5 -3
  282. package/dist/dashboard/guide/en.md +2 -0
  283. package/dist/dashboard/guide/es.md +4 -2
  284. package/dist/dashboard/guide/fi.md +5 -3
  285. package/dist/dashboard/guide/fr.md +4 -2
  286. package/dist/dashboard/guide/he.md +4 -2
  287. package/dist/dashboard/guide/hi.md +6 -4
  288. package/dist/dashboard/guide/hu.md +4 -2
  289. package/dist/dashboard/guide/is.md +5 -3
  290. package/dist/dashboard/guide/it.md +3 -1
  291. package/dist/dashboard/guide/ja.md +7 -5
  292. package/dist/dashboard/guide/ko.md +6 -4
  293. package/dist/dashboard/guide/nb.md +4 -2
  294. package/dist/dashboard/guide/nl.md +5 -3
  295. package/dist/dashboard/guide/pl.md +4 -2
  296. package/dist/dashboard/guide/pt.md +4 -2
  297. package/dist/dashboard/guide/ro.md +5 -3
  298. package/dist/dashboard/guide/ru.md +5 -3
  299. package/dist/dashboard/guide/sv.md +5 -3
  300. package/dist/dashboard/guide/tr.md +6 -4
  301. package/dist/dashboard/guide/uk.md +4 -2
  302. package/dist/dashboard/guide/zh.md +5 -3
  303. package/dist/dashboard/help/help.js +3 -3
  304. package/dist/dashboard/i18n/ar.json +4 -0
  305. package/dist/dashboard/i18n/cs.json +4 -0
  306. package/dist/dashboard/i18n/da.json +4 -0
  307. package/dist/dashboard/i18n/de.json +4 -0
  308. package/dist/dashboard/i18n/el.json +4 -0
  309. package/dist/dashboard/i18n/es.json +4 -0
  310. package/dist/dashboard/i18n/fi.json +4 -0
  311. package/dist/dashboard/i18n/fr.json +4 -0
  312. package/dist/dashboard/i18n/he.json +4 -0
  313. package/dist/dashboard/i18n/hi.json +4 -0
  314. package/dist/dashboard/i18n/hu.json +4 -0
  315. package/dist/dashboard/i18n/is.json +4 -0
  316. package/dist/dashboard/i18n/it.json +4 -0
  317. package/dist/dashboard/i18n/ja.json +5 -1
  318. package/dist/dashboard/i18n/ko.json +4 -0
  319. package/dist/dashboard/i18n/nb.json +4 -0
  320. package/dist/dashboard/i18n/nl.json +4 -0
  321. package/dist/dashboard/i18n/pl.json +4 -0
  322. package/dist/dashboard/i18n/pt.json +4 -0
  323. package/dist/dashboard/i18n/ro.json +4 -0
  324. package/dist/dashboard/i18n/ru.json +4 -0
  325. package/dist/dashboard/i18n/sv.json +4 -0
  326. package/dist/dashboard/i18n/tr.json +4 -0
  327. package/dist/dashboard/i18n/uk.json +4 -0
  328. package/dist/dashboard/i18n/zh.json +4 -0
  329. package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
  330. package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
  331. package/dist/dashboard/kit.js +3 -3
  332. package/dist/dashboard/packages/ask-card.js +3 -3
  333. package/dist/dashboard/packages/catalog.js +196 -0
  334. package/dist/dashboard/packages/engine.js +87 -0
  335. package/dist/dashboard/packages/installed.js +53 -0
  336. package/dist/dashboard/packages/library.js +97 -0
  337. package/dist/dashboard/packages/outcomes.js +45 -0
  338. package/dist/dashboard/packages/packages.js +20 -576
  339. package/dist/dashboard/packages/page-code.js +15 -2
  340. package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
  341. package/dist/dashboard/packages/rows.js +84 -0
  342. package/dist/dashboard/packages/share.js +44 -0
  343. package/dist/dashboard/packages/widgets.js +3 -3
  344. package/dist/dashboard/{card.js → parts/card.js} +1 -1
  345. package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
  346. package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
  347. package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
  348. package/dist/dashboard/{labels.js → parts/labels.js} +2 -1
  349. package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
  350. package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
  351. package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
  352. package/dist/dashboard/{refusals.js → parts/refusals.js} +1 -1
  353. package/dist/dashboard/{status.js → parts/status.js} +4 -4
  354. package/dist/dashboard/{widgets.js → parts/widgets.js} +2 -2
  355. package/dist/dashboard/place/key.js +24 -0
  356. package/dist/dashboard/place/paper.js +67 -0
  357. package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
  358. package/dist/dashboard/place/things.js +129 -0
  359. package/dist/dashboard/place/tokens.js +93 -0
  360. package/dist/dashboard/place/view.js +124 -0
  361. package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
  362. package/dist/dashboard/{asked.js → play/asked.js} +10 -10
  363. package/dist/dashboard/{choices.js → play/choices.js} +9 -9
  364. package/dist/dashboard/{requested.js → play/requested.js} +1 -1
  365. package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
  366. package/dist/dashboard/{scene.js → play/scene.js} +14 -14
  367. package/dist/dashboard/{turns.js → play/turns.js} +12 -12
  368. package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
  369. package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
  370. package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
  371. package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
  372. package/dist/dashboard/{setup.js → settings/setup.js} +5 -5
  373. package/dist/dashboard/{party.js → sheet/party.js} +8 -8
  374. package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
  375. package/dist/dashboard/{sheet.js → sheet/sheet.js} +17 -17
  376. package/dist/dashboard/{story.js → sheet/story.js} +3 -3
  377. package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
  378. package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
  379. package/dist/dashboard/{master.js → shell/master.js} +2 -2
  380. package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
  381. package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
  382. package/dist/dashboard/shell/shown.js +37 -0
  383. package/dist/dashboard/{table.js → shell/table.js} +2 -2
  384. package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
  385. package/dist/dashboard/{top.js → shell/top.js} +7 -7
  386. package/dist/dashboard/style.css +74 -3
  387. package/dist/dashboard/world/calendar.js +4 -4
  388. package/dist/dashboard/world/drawing.js +92 -0
  389. package/dist/dashboard/world/key.js +21 -0
  390. package/dist/dashboard/world/lore.js +5 -5
  391. package/dist/dashboard/world/map-card.js +186 -0
  392. package/dist/dashboard/world/place-card.js +39 -0
  393. package/dist/dashboard/world/places.js +29 -0
  394. package/dist/dashboard/world/world.js +9 -341
  395. package/dist/extensions/extension.d.ts +1 -1
  396. package/dist/extensions/extension.js +1 -1
  397. package/dist/images/images.js +12 -9
  398. package/dist/index.d.ts +1 -1
  399. package/dist/languages/index.d.ts +1 -1
  400. package/dist/languages/index.js +1 -1
  401. package/dist/packages/npm.js +1 -1
  402. package/dist/page.d.ts +2 -2
  403. package/dist/page.js +1 -1
  404. package/dist/pages/check.js +23 -1
  405. package/dist/pages/containers.d.ts +1 -1
  406. package/dist/pages/containers.js +1 -1
  407. package/dist/pages/index.d.ts +4 -2
  408. package/dist/pages/index.js +4 -2
  409. package/dist/pages/inheritance.d.ts +2 -2
  410. package/dist/pages/layers.d.ts +50 -0
  411. package/dist/pages/layers.js +97 -0
  412. package/dist/pages/rename-page.js +1 -1
  413. package/dist/pages/stacks/writes.js +48 -22
  414. package/dist/pages/standard-fields.d.ts +1 -1
  415. package/dist/pages/system-pages.d.ts +5 -3
  416. package/dist/pages/system-pages.js +16 -7
  417. package/dist/pages/world.d.ts +8 -1
  418. package/dist/pages/world.js +16 -4
  419. package/dist/pages/write-layer.d.ts +18 -0
  420. package/dist/pages/write-layer.js +108 -0
  421. package/dist/pages/write-page.d.ts +2 -2
  422. package/dist/pages/write-page.js +2 -2
  423. package/dist/rules/index.d.ts +1 -1
  424. package/dist/rules/index.js +1 -1
  425. package/dist/rules/search.d.ts +1 -1
  426. package/dist/rules/shown.d.ts +1 -1
  427. package/dist/server/dashboard/choices.js +3 -3
  428. package/dist/server/dashboard/files.js +5 -5
  429. package/dist/server/dashboard/index.d.ts +2 -2
  430. package/dist/server/dashboard/index.js +2 -2
  431. package/dist/server/dashboard/news.js +4 -3
  432. package/dist/server/dashboard/player.js +1 -1
  433. package/dist/server/dashboard/writes.js +9 -7
  434. package/dist/server/mcp.js +28 -13
  435. package/dist/systems/campaign-data.d.ts +15 -0
  436. package/dist/systems/campaign-data.js +85 -0
  437. package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
  438. package/dist/systems/{system-code.js → code.js} +2 -2
  439. package/dist/systems/game-system.d.ts +7 -61
  440. package/dist/systems/game-system.js +1 -984
  441. package/dist/systems/index.d.ts +6 -3
  442. package/dist/systems/index.js +6 -3
  443. package/dist/systems/installed.d.ts +31 -0
  444. package/dist/systems/installed.js +89 -0
  445. package/dist/systems/maps.d.ts +3 -0
  446. package/dist/systems/maps.js +9 -0
  447. package/dist/systems/read.d.ts +3 -0
  448. package/dist/systems/read.js +471 -0
  449. package/dist/systems/schema.d.ts +289 -0
  450. package/dist/systems/schema.js +243 -0
  451. package/dist/systems/settings.d.ts +19 -0
  452. package/dist/systems/settings.js +78 -0
  453. package/dist/systems/versions.d.ts +12 -0
  454. package/dist/systems/versions.js +52 -0
  455. package/dist/testing/index.js +1 -1
  456. package/instructions/import.md +1 -1
  457. package/instructions/play.md +1 -1
  458. package/package.json +1 -1
  459. package/dist/commands/config.js +0 -948
  460. package/dist/commands/package.d.ts +0 -143
  461. package/dist/commands/package.js +0 -785
  462. package/dist/commands/scene.js +0 -894
  463. package/dist/commands/shared/worked-out.js +0 -805
  464. package/dist/dashboard/place/map-view.js +0 -417
  465. /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
  466. /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
  467. /package/dist/core/{package-api.js → packages/api.js} +0 -0
  468. /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
  469. /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
  470. /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
  471. /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
  472. /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
  473. /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
  474. /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
  475. /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
  476. /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
  477. /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
  478. /package/dist/languages/{language-pack.js → pack.js} +0 -0
  479. /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
  480. /package/dist/pages/{page-file.js → file.js} +0 -0
  481. /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
  482. /package/dist/pages/{page-types.js → types.js} +0 -0
  483. /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
  484. /package/dist/rules/{rule-book.js → book.js} +0 -0
  485. /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
  486. /package/dist/systems/{system-folders.js → folders.js} +0 -0
@@ -0,0 +1,42 @@
1
+ import { type Coin } from "../../money/index.ts";
2
+ import { type FieldChange, type Page, type PageType, type World } from "../../pages/index.ts";
3
+ import type { GameSystem } from "../../systems/index.ts";
4
+ import { type readOpenScene } from "../shared/scene/scene.ts";
5
+ /**
6
+ * The checks of write on what it is about to write on a page, new or not, and on its fields (D-435, D-514): their names and values, the lists the sheet
7
+ * closes, a creature's copies in the open scene, counters, uses, the base, bonds, limits and an event's fields. It throws what is wrong, with how to fix it.
8
+ */
9
+ export declare function checkFieldWrite(world: World, system: GameSystem | undefined, open: ReturnType<typeof readOpenScene>, coins: Coin[] | undefined, target: {
10
+ existing: Page | undefined;
11
+ name: string;
12
+ type: PageType | undefined;
13
+ }, fields: FieldChange): void;
14
+ /**
15
+ * The checks of write on the fields of the campaign's layer over a page of its game system (SYS-11): their names and values, the lists the system closes, and no copies of
16
+ * the page in the open scene (INH-10). A counter takes its new value here, as the system's page would be written: the layer is the master's work on the world, not play.
17
+ */
18
+ export declare function checkLayerFieldWrite(world: World, system: GameSystem | undefined, open: ReturnType<typeof readOpenScene>, page: Page, fields: FieldChange): void;
19
+ /** Effects change only with the effect command, which works out when they end and says what they change (EFF-6). */
20
+ export declare function checkNoEffects(change: FieldChange, page: Page | undefined): void;
21
+ /** A counter written as current/max changes only with change, which keeps its limits and logs why (D-92, INH-11). A value that is not a counter makes it something else: on a page that holds it alone, only after unset. */
22
+ export declare function checkCounters(world: World, page: Page, set: Record<string, unknown> | undefined, coins: Coin[] | undefined): void;
23
+ /**
24
+ * A value that changes only with change, as it is compared: a current/max counter (D-92), a number the game system declares a counter with no maximum (CNT-7, D-266), or money
25
+ * (MON-6); undefined for any other.
26
+ */
27
+ export declare function guarded(value: unknown, coins: Coin[] | undefined, declared: boolean): {
28
+ kind: "counter" | "money";
29
+ text: string;
30
+ } | undefined;
31
+ /**
32
+ * Removing a counter that a base also holds as current/max would bring back the base's value with no line in the log: change does it, and logs it (INH-11).
33
+ * `change` names the fields as the page writes them. The same field written twice in another case may lose one of the two: validate asks for it.
34
+ */
35
+ export declare function checkClearedCounters(world: World, page: Page, change: FieldChange, coins: Coin[] | undefined): void;
36
+ /** A field is given a value: an empty one would count as missing (INH-6), and removing a field is unset, which checks what it would bring back. */
37
+ export declare function checkValues(change: FieldChange): void;
38
+ /** Items are added to or removed from a list: one that the page reads as something else, itself or from a base, is set whole first (INH-7). */
39
+ export declare function checkLists(world: World, page: Page, change: FieldChange): void;
40
+ export declare function changedFieldNames(change: FieldChange): string[];
41
+ /** The fields the system's sheet asks of every character, its optional ones left out, as names are compared. */
42
+ export declare function askedFields(system: GameSystem | undefined): Set<string>;
@@ -0,0 +1,291 @@
1
+ // The checks before anything is written; each one throws what is wrong and how to fix it
2
+ import { comparableText, sameName, valueNamed, withArticle } from "../../core/text.js";
3
+ import { formatCounter, readCounter } from "../../counters/index.js";
4
+ import { readEffects } from "../../effects/index.js";
5
+ import { formatAmount, readAmount } from "../../money/index.js";
6
+ import { baseFieldOf, baseValue, changedEnvironment, changedFields, checkFieldChange, environmentAt, findPage, formatEnvironmentEntry, holdsField, inheritedFields, isCounterField, isDeclaredUncounted, isEmptyField, isNeverInherited, isStandardField, linksIn, misspelledFieldProblem, newBaseProblem, newPageFields, ownFieldChange, readEnvironment, systemKnowsReason, systemLabel, systemPageNamed, } from "../../pages/index.js";
7
+ import { checkNotCopied } from "../shared/scene/scene.js";
8
+ import { checkBonds } from "../shared/sheet/bonds.js";
9
+ import { effectiveFields, effectsField } from "../shared/sheet/effect-layer.js";
10
+ import { checkLimits } from "../shared/sheet/limits.js";
11
+ import { checkListValues } from "../shared/sheet/sheet.js";
12
+ import { hasSheet, isUse, startingAtZero } from "../shared/sheet/system-fields.js";
13
+ import { counterLimits, maximumHint, maximumSources } from "../shared/sheet/worked-out.js";
14
+ import { eventFieldsProblem, plannedEventDateProblem } from "../shared/time/events.js";
15
+ /**
16
+ * The checks of write on what it is about to write on a page, new or not, and on its fields (D-435, D-514): their names and values, the lists the sheet
17
+ * closes, a creature's copies in the open scene, counters, uses, the base, bonds, limits and an event's fields. It throws what is wrong, with how to fix it.
18
+ */
19
+ export function checkFieldWrite(world, system, open, coins, target, fields) {
20
+ const { existing, name, type } = target;
21
+ conditionsAsList(existing, fields);
22
+ checkFieldNames(type, fields);
23
+ checkFieldChange(type, fields);
24
+ environmentAsSet(world, existing, type, name, fields);
25
+ checkValues(fields);
26
+ // A page that keeps the sheet, as it will be written, takes only the names the sheet closes (D-435).
27
+ const asWritten = { name, path: existing?.path ?? "", body: existing?.body ?? "", ...(type === undefined ? {} : { type }), fields: { ...existing?.fields, ...fields.set } };
28
+ const onSheet = hasSheet(world, asWritten);
29
+ checkListValues(system, fields.set ?? {}, onSheet);
30
+ checkListValues(system, fields.add ?? {}, onSheet);
31
+ checkKnows(world, fields);
32
+ if (existing !== undefined) {
33
+ if (changedFieldNames(fields).some(passesOn)) {
34
+ checkNotCopied(world, open, existing);
35
+ }
36
+ checkCounters(world, existing, fields.set, coins);
37
+ checkUses(world, system, existing, fields.set);
38
+ checkClearedCounters(world, existing, ownFieldChange(world, existing, fields), coins);
39
+ checkLists(world, existing, fields);
40
+ }
41
+ checkBase(world, existing?.name ?? name, type, fields.set);
42
+ checkBonds(world, system, existing, existing?.name ?? name, fields);
43
+ checkLimits(world, system, existing, existing?.name ?? name, fields);
44
+ checkEventFields(world, existing, type, fields);
45
+ }
46
+ /**
47
+ * The checks of write on the fields of the campaign's layer over a page of its game system (SYS-11): their names and values, the lists the system closes, and no copies of
48
+ * the page in the open scene (INH-10). A counter takes its new value here, as the system's page would be written: the layer is the master's work on the world, not play.
49
+ */
50
+ export function checkLayerFieldWrite(world, system, open, page, fields) {
51
+ checkFieldNames(page.type, fields);
52
+ checkFieldChange(page.type, fields);
53
+ checkValues(fields);
54
+ checkListValues(system, fields.set ?? {});
55
+ checkListValues(system, fields.add ?? {});
56
+ checkLists(world, page, fields);
57
+ if (changedFieldNames(fields).length > 0) {
58
+ checkNotCopied(world, open, page);
59
+ }
60
+ }
61
+ /** Effects change only with the effect command, which works out when they end and says what they change (EFF-6). */
62
+ export function checkNoEffects(change, page) {
63
+ // Effects that do not read can only be removed by hand, or with unset: effect will not write over them (EFF-12).
64
+ const unreadable = page !== undefined && "problem" in readEffects(effectsField(page));
65
+ const onlyUnset = Object.keys(change.set ?? {}).every((name) => comparableText(name) !== "effects") && [change.add, change.remove].every((items) => Object.keys(items ?? {}).every((name) => comparableText(name) !== "effects"));
66
+ if (unreadable && onlyUnset) {
67
+ return;
68
+ }
69
+ if (changedFieldNames(change).some((name) => comparableText(name) === "effects")) {
70
+ throw new Error('effects change only with the effect command: action add with a name, for how long and the values it gives, such as name "Protezione", for 10m, set bonus-armor=2; action end to take one away. Nothing changed.');
71
+ }
72
+ }
73
+ /** A standard field written in another case, such as Status, would be a field the engine does not read: refused before any other check. */
74
+ function checkFieldNames(type, change) {
75
+ const names = [...Object.keys(change.set ?? {}), ...Object.keys(change.add ?? {}), ...Object.keys(change.remove ?? {})];
76
+ const problem = names.map((name) => misspelledFieldProblem(type, name)).find((found) => found !== undefined);
77
+ if (problem !== undefined) {
78
+ throw new Error(problem);
79
+ }
80
+ }
81
+ /** A counter written as current/max changes only with change, which keeps its limits and logs why (D-92, INH-11). A value that is not a counter makes it something else: on a page that holds it alone, only after unset. */
82
+ export function checkCounters(world, page, set, coins) {
83
+ const fields = inheritedFields(world, page);
84
+ for (const [field, value] of Object.entries(set ?? {}).filter(([, candidate]) => !isEmptyField(candidate))) {
85
+ const name = sameName(Object.keys(fields), field);
86
+ const declared = name !== undefined && startingAtZero(world, name) !== undefined;
87
+ const current = name === undefined || (isStandardField(page.type, name) && !isCounterField(page.type, name)) || isDeclaredUncounted(world, name) ? undefined : guarded(fields[name], coins, declared);
88
+ const next = current === undefined ? undefined : sameKind(current.kind, value, coins);
89
+ const base = baseValue(world, page, field);
90
+ if (name === undefined || current === undefined || next === current.text || (next === undefined && base !== undefined)) {
91
+ continue;
92
+ }
93
+ const hint = current.kind === "counter" ? maximumHint(world, effectiveFields(world, page), name) : undefined;
94
+ throw new Error(hint === undefined ? guardedMessage(page, name, current.kind, next, holdsField(page, name) ? undefined : base?.base, base !== undefined) : workedCounterMessage(page, name, hint));
95
+ }
96
+ }
97
+ /**
98
+ * A use of the system that the character does not get, as a warlock's spell-slots on a wizard or slots on a warlock, is never written by hand (DAT-9): only on who
99
+ * keeps the sheet and has the system's lists, and never for one the sheet asks to write, as hp.
100
+ */
101
+ function checkUses(world, system, page, set) {
102
+ const list = world.system?.progression?.list;
103
+ const after = { ...page, fields: { ...page.fields, ...set } };
104
+ const fields = inheritedFields(world, after);
105
+ const classes = list === undefined ? undefined : valueNamed(fields, list);
106
+ if (list === undefined || isEmptyField(classes) || !hasSheet(world, after)) {
107
+ return;
108
+ }
109
+ const asked = askedFields(system);
110
+ for (const field of Object.keys(set ?? {}).filter((name) => isUse(world, name) && !asked.has(comparableText(name)))) {
111
+ const counted = Object.keys(world.system?.formulas?.counters ?? {}).some((name) => comparableText(name) === comparableText(field));
112
+ const { max } = counterLimits(world, fields, field);
113
+ if (counted && (max === undefined || max <= 0)) {
114
+ const sources = maximumSources(world, field, fields);
115
+ const whence = sources.length === 0 ? `the tables of its ${list}` : sources.join(", ");
116
+ throw new Error(`${field} is a use the system ${world.system?.name ?? ""} gives from ${whence}, and ${page.name} has none of it: it is not written by hand. Nothing changed.`);
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * A value that changes only with change, as it is compared: a current/max counter (D-92), a number the game system declares a counter with no maximum (CNT-7, D-266), or money
122
+ * (MON-6); undefined for any other.
123
+ */
124
+ export function guarded(value, coins, declared) {
125
+ const counter = readCounter(value);
126
+ if (counter !== undefined && (counter.max !== undefined || declared)) {
127
+ return { kind: "counter", text: String(formatCounter(counter)) };
128
+ }
129
+ const purse = coins === undefined ? undefined : readAmount(value, coins);
130
+ return purse === undefined || coins === undefined ? undefined : { kind: "money", text: formatAmount(purse, coins) };
131
+ }
132
+ /** A new value read as the kind it would replace: any counter for a counter, coins for money; undefined when it is something else. */
133
+ function sameKind(kind, value, coins) {
134
+ const counter = kind === "counter" ? readCounter(value) : undefined;
135
+ const purse = kind === "money" && coins !== undefined ? readAmount(value, coins) : undefined;
136
+ return counter !== undefined ? String(formatCounter(counter)) : purse !== undefined && coins !== undefined ? formatAmount(purse, coins) : undefined;
137
+ }
138
+ /** "hp is a counter whose maximum the game system works out": what to change instead, the current value with change and the maximum through what it comes from (D-226). */
139
+ function workedCounterMessage(page, field, hint) {
140
+ const raise = hint.raise === undefined ? "" : `; to raise the maximum, write ${hint.raise}`;
141
+ return `${field} is a counter whose maximum the game system works out: ${hint.made}. Change its current value with change, page "${page.name}", field ${field}${raise}. Nothing changed.`;
142
+ }
143
+ function guardedMessage(page, field, kind, next, readFrom, hasBase) {
144
+ const what = kind === "counter" ? "a counter" : "money";
145
+ const other = hasBase ? `To make it something else, set a value that is not ${what}.` : "To make it something else, unset it, then set it.";
146
+ if (kind === "money") {
147
+ const from = readFrom === undefined ? "" : `, which it reads from ${readFrom.name},`;
148
+ const purse = next === undefined ? "sets the purse" : `"${next}" sets the purse`;
149
+ return `${page.name}'s ${field}${from} changes only with change, page "${page.name}", field ${field}: spend pays, by adds coins, to ${purse}${readFrom === undefined ? "" : `, on ${page.name} only`}. ${other}`;
150
+ }
151
+ const use = `use change, page "${page.name}", field ${field}, to ${next ?? "a value"} (or by an amount)`;
152
+ return readFrom === undefined ? `${field} is ${what}: ${use}. ${other}` : `${field} is ${what} that ${page.name} reads from ${readFrom.name}: ${use}, which writes it on ${page.name} only. ${other}`;
153
+ }
154
+ /**
155
+ * Removing a counter that a base also holds as current/max would bring back the base's value with no line in the log: change does it, and logs it (INH-11).
156
+ * `change` names the fields as the page writes them. The same field written twice in another case may lose one of the two: validate asks for it.
157
+ */
158
+ export function checkClearedCounters(world, page, change, coins) {
159
+ for (const own of (change.unset ?? []).filter((field) => Object.hasOwn(page.fields, field))) {
160
+ const current = isStandardField(page.type, own) || isDeclaredUncounted(world, own) ? undefined : guarded(page.fields[own], coins, false);
161
+ const base = baseValue(world, page, own);
162
+ const fromBase = base === undefined ? undefined : guarded(base.value, coins, false);
163
+ const alsoHeld = Object.keys(page.fields).some((other) => other !== own && comparableText(other) === comparableText(own) && !isEmptyField(page.fields[other]));
164
+ if (!alsoHeld && base !== undefined && current !== undefined && fromBase?.kind === current.kind) {
165
+ const value = current.kind === "counter" ? fromBase.text : `"${fromBase.text}"`;
166
+ const start = current.kind === "counter" ? `${own} on ${page.name} is a counter: without it,` : `Without ${own},`;
167
+ throw new Error(`${start} ${page.name} would read ${fromBase.text} from ${base.base.name}, with no line in the log. Use change, page "${page.name}", field ${own}, to ${value}: it takes the field off, and ${page.name} follows ${base.base.name} again.`);
168
+ }
169
+ }
170
+ }
171
+ /** knows lists pages and secrets of the campaign: a page of the game system, which anyone may know, never (SYS-2). */
172
+ function checkKnows(world, change) {
173
+ const known = [...linksIn(change.set?.knows), ...linksIn(change.add?.knows)].map((name) => systemPageNamed(world, name)).find((page) => page !== undefined && findPage(world, page.name) === page);
174
+ if (known !== undefined) {
175
+ throw new Error(`${known.name} is ${systemLabel(known)}, ${systemKnowsReason(known)}: knows lists pages and secrets of the campaign. Nothing changed.`);
176
+ }
177
+ }
178
+ /** A character or creature derives only from a creature, an item only from an item, never in a loop (INH-2, INH-3). */
179
+ function checkBase(world, name, type, set) {
180
+ const field = baseFieldOf(type);
181
+ const link = field === undefined ? undefined : set?.[field];
182
+ const problem = typeof link === "string" ? newBaseProblem(world, { name, type }, link) : undefined;
183
+ if (problem !== undefined) {
184
+ throw new Error(`${problem} Nothing changed.`);
185
+ }
186
+ }
187
+ /**
188
+ * A planned event comes due at its date, so a write that sets its date or status cannot leave a date the engine does not read (D-100);
189
+ * nor a clock or conditions that do not read (EVT-10).
190
+ */
191
+ function checkEventFields(world, page, type, change) {
192
+ const changed = changedFieldNames(change);
193
+ if (type !== "event" || !["date", "status", "clock", "when"].some((field) => changed.includes(field))) {
194
+ return;
195
+ }
196
+ const fields = changedFields(page?.fields ?? newPageFields(type), change);
197
+ const date = changed.includes("date") || changed.includes("status") ? plannedEventDateProblem(type, fields) : undefined;
198
+ const problem = date ?? eventFieldsProblem(world, fields, changed);
199
+ if (problem !== undefined) {
200
+ throw new Error(problem);
201
+ }
202
+ }
203
+ /**
204
+ * A place's environment changes entry by entry (ENV-4): add puts a line in, or in place of the one with its name; remove takes one out by name; set gives them all,
205
+ * each read as a line. The lines it ends with are set whole, or the field goes when none is left.
206
+ */
207
+ function environmentAsSet(world, page, type, name, change) {
208
+ const add = change.add?.environment;
209
+ const remove = change.remove?.environment;
210
+ // On a character or an item environment would hold for nothing (ENV-6); taking it away is always allowed.
211
+ if ((type === "character" || type === "item") && (change.set?.environment !== undefined || add !== undefined)) {
212
+ throw new Error(`${name} is ${withArticle(type)}: an environment holds only on a place, for all it contains. What a thing does around itself, such as a lantern's light, is a field or an effect of its own.`);
213
+ }
214
+ if (type !== "place") {
215
+ return;
216
+ }
217
+ if (change.set?.environment !== undefined) {
218
+ const read = readEnvironment(change.set.environment);
219
+ if ("problem" in read) {
220
+ throw new Error(read.problem);
221
+ }
222
+ // Written back as lines, which Obsidian edits, whatever way they were given.
223
+ change.set.environment = read.entries.map(formatEnvironmentEntry);
224
+ }
225
+ if (add === undefined && remove === undefined) {
226
+ return;
227
+ }
228
+ checkOwnEntries(world, page, name, remove ?? []);
229
+ const lines = changedEnvironment(page?.fields.environment, add ?? [], remove ?? [], page?.name ?? name);
230
+ delete change.add?.environment;
231
+ delete change.remove?.environment;
232
+ if (lines.length > 0) {
233
+ change.set = { ...change.set, environment: lines };
234
+ }
235
+ else if (page !== undefined && Object.hasOwn(page.fields, "environment")) {
236
+ change.unset = [...(change.unset ?? []), "environment"];
237
+ }
238
+ }
239
+ /** An entry to remove that the place does not write but reads from a place around it: removing it there would change it for all that place holds. */
240
+ function checkOwnEntries(world, page, name, remove) {
241
+ const own = page === undefined ? [] : readEnvironmentNames(page.fields.environment);
242
+ for (const entry of remove.map((item) => String(item).split(":")[0].trim())) {
243
+ const outer = page === undefined || own.some((other) => comparableText(other) === comparableText(entry)) ? undefined : environmentAt(world, page).find((found) => comparableText(found.entry.name) === comparableText(entry));
244
+ if (outer !== undefined) {
245
+ throw new Error(`${entry} holds in ${name} from ${outer.place.name}: to change it in ${name} only, add environment="${outer.entry.name}: …" on ${name}; to remove it everywhere ${outer.place.name} holds, write ${outer.place.name}, remove environment=${outer.entry.name}.`);
246
+ }
247
+ }
248
+ }
249
+ /** The names a place's environment writes, as far as its lines read. */
250
+ function readEnvironmentNames(value) {
251
+ const read = readEnvironment(value);
252
+ return "entries" in read ? read.entries.map((entry) => entry.name) : [];
253
+ }
254
+ /** Adding a condition to an event that has one makes a list of the two, of which one is enough (EVT-3). */
255
+ function conditionsAsList(page, change) {
256
+ const current = page?.type === "event" ? page.fields.when : undefined;
257
+ if (change.add?.when !== undefined && typeof current === "string" && current.trim() !== "" && change.set?.when === undefined) {
258
+ change.set = { ...change.set, when: [current, ...change.add.when] };
259
+ delete change.add.when;
260
+ }
261
+ }
262
+ /** A field is given a value: an empty one would count as missing (INH-6), and removing a field is unset, which checks what it would bring back. */
263
+ export function checkValues(change) {
264
+ const [empty] = Object.entries(change.set ?? {}).filter(([, value]) => isEmptyField(value));
265
+ if (empty !== undefined) {
266
+ throw new Error(`Give ${empty[0]} a value. To remove a field, use unset.`);
267
+ }
268
+ }
269
+ /** Items are added to or removed from a list: one that the page reads as something else, itself or from a base, is set whole first (INH-7). */
270
+ export function checkLists(world, page, change) {
271
+ const fields = inheritedFields(world, page);
272
+ for (const field of [...Object.keys(change.add ?? {}), ...Object.keys(change.remove ?? {})].filter((name) => !Object.hasOwn(change.set ?? {}, name))) {
273
+ const [name, value] = Object.entries(fields).find(([key]) => comparableText(key) === comparableText(field)) ?? [];
274
+ if (name !== undefined && !Array.isArray(value)) {
275
+ const base = holdsField(page, name) ? undefined : baseValue(world, page, name)?.base;
276
+ const from = base === undefined ? "" : `, which ${page.name} reads from ${base.name}`;
277
+ throw new Error(`${name} on ${page.name} is ${JSON.stringify(value)}${from}, not a list: items cannot be added to it or removed from it. To make it a list, set it whole, such as set ${name}=[a, b].`);
278
+ }
279
+ }
280
+ }
281
+ /** Whether changing a field reaches the pages and copies deriving from a page: a field they inherit, or the creature or item it derives from. */
282
+ function passesOn(field) {
283
+ return !isNeverInherited(field) || comparableText(field) === "creature" || comparableText(field) === "item";
284
+ }
285
+ export function changedFieldNames(change) {
286
+ return [...Object.keys(change.set ?? {}), ...(change.unset ?? []), ...Object.keys(change.add ?? {}), ...Object.keys(change.remove ?? {})];
287
+ }
288
+ /** The fields the system's sheet asks of every character, its optional ones left out, as names are compared. */
289
+ export function askedFields(system) {
290
+ return new Set((system?.sheet ?? []).flatMap((group) => group.entries.filter((entry) => !entry.optional).map((entry) => comparableText(entry.field))));
291
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Context } from "../../core/context.ts";
2
2
  import { type FieldChange, type Page, type Position, type World } from "../../pages/index.ts";
3
- import { type Journey, type OnRoad } from "../shared/journey.ts";
3
+ import { type Journey, type OnRoad } from "../shared/places/journey.ts";
4
4
  /** Where a place written `here` goes (TRV-14): on a road at the point its journey stopped, or at a point in the open; with the journey and who travels. */
5
5
  export interface Here {
6
6
  journey: Journey;
@@ -1,11 +1,11 @@
1
1
  import { appendLogEntry } from "../../core/log.js";
2
2
  import { comparableText } from "../../core/text.js";
3
3
  import { formatPosition, pagesWithName, readStops, withPage, writePage } from "../../pages/index.js";
4
- import { journeyPoint, journeyStart, moversMap, moversNamed, readJourney, saveJourney } from "../shared/journey.js";
5
- import { movePages } from "../shared/moves.js";
6
- import { positionFromWrite, regionAt } from "../shared/positions.js";
7
- import { lengthText, roadsOf } from "../shared/roads.js";
8
- import { newDatedLogEntry } from "../shared/time.js";
4
+ import { journeyPoint, journeyStart, moversMap, moversNamed, readJourney, saveJourney } from "../shared/places/journey.js";
5
+ import { movePages } from "../shared/places/moves.js";
6
+ import { positionFromWrite, regionAt } from "../shared/places/positions.js";
7
+ import { lengthText, roadsOf } from "../shared/places/roads.js";
8
+ import { newDatedLogEntry } from "../shared/time/time.js";
9
9
  /**
10
10
  * Where the journey stopped, for a place written `here` (TRV-14): refused for a page that exists or is not a place, with a position given too, or without a
11
11
  * journey stopped between two places, with how to write a place inside another.
@@ -0,0 +1,40 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import { type Coin } from "../../money/index.ts";
3
+ import { type FieldChange, type Page, type World } from "../../pages/index.ts";
4
+ import type { GameSystem } from "../../systems/index.ts";
5
+ /**
6
+ * The pages that change with a page a write changed (INH-11): all those deriving from it when it is new or derives from another creature now;
7
+ * else those that read a field it changed, or show the section it wrote.
8
+ */
9
+ export declare function followersOfWrite(now: World, before: Page | undefined, after: Page): {
10
+ pages: Page[];
11
+ why: string;
12
+ };
13
+ /**
14
+ * One public line for each counter that a write changed through inheritance on a page that concerns the player: a page that follows the base written,
15
+ * or the page itself when its creature changes. Its name, the field, before and after (INH-10, INH-11). Each page comes as it was and as it is.
16
+ */
17
+ export declare function logCounterChanges(root: string, context: Context, world: World, now: World, pages: [Page, Page][], coins: Coin[] | undefined): void;
18
+ /**
19
+ * A list written whole that leaves out items the page read from a base, as an elf's Perception from its race: said, since the page no longer reads them (INH-7).
20
+ */
21
+ export declare function droppedFromBaseNotes(now: World, page: Page, set: Record<string, unknown> | undefined): string[];
22
+ /** What a new page is told of its base; a weight is asked only of an item with no base to look for, which would give one (LOAD-1). */
23
+ export declare function baseNotesOrWeight(system: GameSystem | undefined, now: World, page: Page): string[];
24
+ /** "Not changed, since they hold their own fiuto: Grigio (fiuto 2)": for each field a write changed on a base, the pages deriving from it that keep their own value. */
25
+ export declare function keepersNotes(now: World, before: Page, after: Page): string[];
26
+ /** After its creature changes, the values a page keeps that its new bases give otherwise: they may belong to the old one (D-125). */
27
+ export declare function ownValuesNote(now: World, before: Page, after: Page, coins: Coin[] | undefined): string[];
28
+ /** The fields whose value a write changed on a page. */
29
+ export declare function changedNames(before: Page, after: Page): string[];
30
+ /**
31
+ * The names of the fields a write changed, as the page writes them (INH-5). A value equal to the base's is not written (D-125): it is no change, unless the page
32
+ * held another, which it holds no more ("ac again as Lupo").
33
+ */
34
+ export declare function writtenNames(world: World, page: Page | undefined, change: FieldChange, after: Page): {
35
+ set: string[];
36
+ again: string[];
37
+ unset: string[];
38
+ add: string[];
39
+ remove: string[];
40
+ };
@@ -0,0 +1,189 @@
1
+ import { listItemNames } from "../../core/formula.js";
2
+ import { appendLogEntry } from "../../core/log.js";
3
+ import { comparableText, valueNamed, withArticle } from "../../core/text.js";
4
+ import { formatCounter, readCounter } from "../../counters/index.js";
5
+ import { formatAmount, readAmount } from "../../money/index.js";
6
+ import { baseFieldOf, baseValue, concernsPlayer, declaredKind, derivedPages, followersOf, inheritedFields, introductionFollowersOf, introductionText, isDeclaredUncounted, isEmptyField, isNeverInherited, isStandardField, keepersOf, linksIn, removedFieldName, sectionFollowersOf, systemPageNamed, textParts, withPage, writtenFieldName, } from "../../pages/index.js";
7
+ import { systemBaseHint } from "../shared/campaign/world.js";
8
+ import { keepersNote } from "../shared/notes.js";
9
+ import { weightlessNote } from "../shared/sheet/sheet.js";
10
+ import { newDatedLogEntry } from "../shared/time/time.js";
11
+ import { guarded } from "./checks.js";
12
+ /**
13
+ * The pages that change with a page a write changed (INH-11): all those deriving from it when it is new or derives from another creature now;
14
+ * else those that read a field it changed, or show the section it wrote.
15
+ */
16
+ export function followersOfWrite(now, before, after) {
17
+ if (!isBaseType(after.type)) {
18
+ return { pages: [], why: "" };
19
+ }
20
+ const changed = before === undefined ? [] : changedNames(before, after);
21
+ if (before === undefined || changed.some((field) => comparableText(field) === baseFieldOf(after.type))) {
22
+ return { pages: derivedPages(now, after), why: `since they derive from ${after.name}` };
23
+ }
24
+ const byField = changed.map((field) => ({ name: field, pages: followersOf(now, after, field) }));
25
+ const bySection = changedParts(before.body, after.body).map((part) => ({ name: part === "" ? "a secret without a name" : `#${part}`, pages: part === "" ? derivedPages(now, after) : sectionFollowersOf(now, after, part) }));
26
+ const byIntroduction = introductionText(before.body) === introductionText(after.body) ? [] : [{ name: "the introduction", pages: introductionFollowersOf(now, after) }];
27
+ const reasons = [...byField, ...bySection, ...byIntroduction].filter((reason) => reason.pages.length > 0);
28
+ const pages = new Set(reasons.flatMap((reason) => reason.pages));
29
+ return { pages: now.pages.filter((page) => pages.has(page)), why: `since they read ${reasons.map((reason) => reason.name).join(", ")} from ${after.name}` };
30
+ }
31
+ /** The names of the sections and secrets that a text has with another text, gained or no longer has; "" when its secrets without a name changed, which every derived page shows. */
32
+ function changedParts(before, after) {
33
+ const texts = (body) => new Map(textParts(body).filter((part) => part.name !== "").map((part) => [comparableText(part.name), part.text]));
34
+ const unnamed = (body) => textParts(body).filter((part) => part.name === "").map((part) => part.text).join("\n");
35
+ const old = texts(before);
36
+ const now = texts(after);
37
+ const names = new Map(textParts(`${before}\n\n${after}`).filter((part) => part.name !== "").map((part) => [comparableText(part.name), part.name]));
38
+ const named = [...names].filter(([key]) => old.get(key) !== now.get(key)).map(([, name]) => name);
39
+ return unnamed(before) === unnamed(after) ? named : [...named, ""];
40
+ }
41
+ /**
42
+ * One public line for each counter that a write changed through inheritance on a page that concerns the player: a page that follows the base written,
43
+ * or the page itself when its creature changes. Its name, the field, before and after (INH-10, INH-11). Each page comes as it was and as it is.
44
+ */
45
+ export function logCounterChanges(root, context, world, now, pages, coins) {
46
+ for (const [before, after] of pages.filter(([, page]) => concernsPlayer(now, page))) {
47
+ const old = inheritedFields(world, before);
48
+ for (const [field, value] of Object.entries(inheritedFields(now, after)).filter(([name]) => !isStandardField(after.type, name) && !isDeclaredUncounted(now, name))) {
49
+ const was = countedText(valueNamed(old, field), coins);
50
+ const is = countedText(value, coins);
51
+ if (was !== undefined && is !== undefined && was !== is) {
52
+ appendLogEntry(root, newDatedLogEntry(root, context, "counter-changed", "public", { page: after.name, field, before: was, after: is }));
53
+ }
54
+ }
55
+ }
56
+ }
57
+ /** A counter or money as the log writes it; undefined for any other value. */
58
+ function countedText(value, coins) {
59
+ const purse = coins === undefined ? undefined : readAmount(value, coins);
60
+ const counter = readCounter(value);
61
+ return purse !== undefined && coins !== undefined ? formatAmount(purse, coins) : counter === undefined ? undefined : formatCounter(counter);
62
+ }
63
+ /**
64
+ * A list written whole that leaves out items the page read from a base, as an elf's Perception from its race: said, since the page no longer reads them (INH-7).
65
+ */
66
+ export function droppedFromBaseNotes(now, page, set) {
67
+ return Object.entries(set ?? {}).filter(([, value]) => Array.isArray(value)).flatMap(([field, value]) => {
68
+ const base = baseValue(now, page, field);
69
+ if (base === undefined || !Array.isArray(base.value)) {
70
+ return [];
71
+ }
72
+ const held = new Set(listItemNames(value).map(comparableText));
73
+ const missing = listItemNames(base.value).filter((name) => !held.has(comparableText(name)));
74
+ const them = missing.length === 1 ? "it" : "them";
75
+ return missing.length === 0 ? [] : [`${field} on ${page.name} leaves out ${missing.join(", ")}, which it read from ${base.base.name}: if the character keeps ${them}, add ${them}, such as add ${field}=${missing[0]}.`];
76
+ });
77
+ }
78
+ /** What a new page is told of its base; a weight is asked only of an item with no base to look for, which would give one (LOAD-1). */
79
+ export function baseNotesOrWeight(system, now, page) {
80
+ const notes = [...derivesFromNothingNote(now, page), ...noBaseNote(now, page)];
81
+ return notes.length > 0 ? notes : weightlessNote(system, now, page);
82
+ }
83
+ /** A page created with a name that other pages give as their creature or item, though it is not one: they derive from nothing (INH-2). */
84
+ function derivesFromNothingNote(now, page) {
85
+ return ["creature", "item"].filter((field) => field !== page.type).flatMap((field) => {
86
+ const linking = now.pages.filter((other) => baseFieldOf(other.type) === field && linksIn(other.fields[field]).some((name) => comparableText(name) === comparableText(page.name)));
87
+ return linking.length === 0
88
+ ? []
89
+ : [`${linking.map((other) => other.name).join(", ")} name ${page.name} as their ${field}, but it is ${withArticle(page.type ?? "free page")}: they derive from nothing until ${field} links to ${withArticle(field)}.`];
90
+ });
91
+ }
92
+ /**
93
+ * For a creature or an item created without a base, when the game system has pages of its type: it may be a kind of one of them (D-165, SYS-7).
94
+ * When another field already links to one, the field to use instead.
95
+ */
96
+ function noBaseNote(now, page) {
97
+ const field = baseFieldOf(page.type);
98
+ if (page.type === "character" || field === undefined || !isEmptyField(page.fields[field])) {
99
+ return [];
100
+ }
101
+ // Only a free field links to its base by mistake: a field the system declares, such as magic, links to something else (D-164).
102
+ const free = Object.entries(page.fields).filter(([name]) => declaredKind(now, name) === undefined);
103
+ const elsewhere = free.flatMap(([name, value]) => linksIn(value).map((link) => ({ name, page: systemPageNamed(now, link) }))).find((link) => link.page?.type === field);
104
+ if (elsewhere?.page !== undefined) {
105
+ const linked = elsewhere.page;
106
+ const system = linked.system ?? "";
107
+ return [
108
+ `${page.name} links to ${linked.name}, ${withArticle(field)} of the system ${system}, in ${elsewhere.name}: if it is a kind of it, the field is ${field}, `
109
+ + `such as write "${page.name}", set ${field}=[[${linked.name}]], unset ${elsewhere.name}.`,
110
+ ];
111
+ }
112
+ // A story item, such as a letter, writes no field of the system: it is no kind of one of its items.
113
+ if (page.type === "item" && !Object.keys(page.fields).some((name) => declaredKind(now, name) !== undefined)) {
114
+ return [];
115
+ }
116
+ const hint = systemBaseHint(now, field, field);
117
+ return hint === "" ? [] : [`${page.name} derives from no ${field}:${hint.replace(" If it", " if it")}`];
118
+ }
119
+ /** "Not changed, since they hold their own fiuto: Grigio (fiuto 2)": for each field a write changed on a base, the pages deriving from it that keep their own value. */
120
+ export function keepersNotes(now, before, after) {
121
+ if (!isBaseType(after.type)) {
122
+ return [];
123
+ }
124
+ return changedNames(before, after).flatMap((field) => {
125
+ const keepers = keepersOf(now, after, field).map((keeper) => `${keeper.name} (${field} ${valueText(valueNamed(inheritedFields(now, keeper), field))})`);
126
+ const note = keepersNote(keepers, field);
127
+ return note === "" ? [] : [note];
128
+ });
129
+ }
130
+ /** After its creature changes, the values a page keeps that its new bases give otherwise: they may belong to the old one (D-125). */
131
+ export function ownValuesNote(now, before, after, coins) {
132
+ const field = baseFieldOf(after.type);
133
+ if (field === undefined || !changedNames(before, after).some((name) => comparableText(name) === field)) {
134
+ return [];
135
+ }
136
+ const kept = Object.entries(after.fields).filter(([name, value]) => !isEmptyField(value) && !isNeverInherited(name)).flatMap(([name, value]) => {
137
+ const base = baseValue(now, after, name);
138
+ return base === undefined || JSON.stringify(base.value) === JSON.stringify(value) ? [] : [{ field: name, value, base }];
139
+ });
140
+ if (kept.length === 0) {
141
+ return [];
142
+ }
143
+ // A current/max counter or money goes back to the base's value with change; anything else is removed.
144
+ const back = kept.map(({ field, value, base }) => {
145
+ const mine = guarded(value, coins, false);
146
+ const theirs = guarded(base.value, coins, false);
147
+ return mine !== undefined && mine.kind === theirs?.kind ? `change ${field} to ${mine.kind === "money" ? `"${theirs.text}"` : theirs.text}` : `unset ${field}`;
148
+ });
149
+ const listed = kept.map(({ field, value, base }) => `${field} ${valueText(value)} (${base.base.name} gives ${valueText(base.value)})`);
150
+ return [`${after.name} keeps its own ${listed.join(", ")}. If they came from its old ${field}: ${back.join(", ")}.`];
151
+ }
152
+ /** The fields whose value a write changed on a page. */
153
+ export function changedNames(before, after) {
154
+ return [...new Set([...Object.keys(before.fields), ...Object.keys(after.fields)])].filter((field) => JSON.stringify(before.fields[field]) !== JSON.stringify(after.fields[field]));
155
+ }
156
+ /** A value as the outputs show it: a list as its items, anything else as written. */
157
+ function valueText(value) {
158
+ return Array.isArray(value) ? value.map(String).join(", ") : typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
159
+ }
160
+ /** Whether pages of this type can be bases: creatures and items (INH-1). */
161
+ function isBaseType(type) {
162
+ return type === "creature" || type === "item";
163
+ }
164
+ /**
165
+ * The names of the fields a write changed, as the page writes them (INH-5). A value equal to the base's is not written (D-125): it is no change, unless the page
166
+ * held another, which it holds no more ("ac again as Lupo").
167
+ */
168
+ export function writtenNames(world, page, change, after) {
169
+ const names = (fields) => fields.map((field) => (page === undefined ? field : writtenFieldName(world, page, field)));
170
+ const removed = (change.unset ?? []).map((field) => (page === undefined ? field : removedFieldName(page, field)));
171
+ const [set, add, remove] = [Object.keys(change.set ?? {}), Object.keys(change.add ?? {}), Object.keys(change.remove ?? {})].map(names);
172
+ const now = withPage(world, page, after);
173
+ const base = (field) => baseValue(now, after, field)?.base.name;
174
+ // What the page held and holds no more, without being removed: it reads it from a base again. What it was given and does not hold: it reads it from a base all the same.
175
+ const gone = page === undefined ? [] : Object.keys(page.fields).filter((field) => !isEmptyField(page.fields[field]) && !Object.hasOwn(after.fields, field) && !removed.includes(field) && base(field) !== undefined);
176
+ const asBase = [...set, ...add, ...remove].filter((field, index, all) => all.indexOf(field) === index && !gone.includes(field) && !Object.hasOwn(after.fields, field) && base(field) !== undefined);
177
+ const shown = (field) => !gone.includes(field) && !asBase.includes(field);
178
+ return {
179
+ set: set.filter((field) => shown(field) && JSON.stringify(page?.fields[field]) !== JSON.stringify(after.fields[field])),
180
+ again: [...byBase(gone, base, "again as"), ...byBase(asBase, base, "as")],
181
+ unset: removed,
182
+ add: add.filter(shown),
183
+ remove: remove.filter(shown),
184
+ };
185
+ }
186
+ /** "hp, ac again as Wolf": fields grouped by the base they are read from. */
187
+ function byBase(fields, base, how) {
188
+ return [...new Set(fields.map(base))].map((name) => `${fields.filter((field) => base(field) === name).join(", ")} ${how} ${name ?? ""}`);
189
+ }
@@ -0,0 +1,29 @@
1
+ import type { Problem } from "../../core/problem.ts";
2
+ import { type Coin } from "../../money/index.ts";
3
+ import { type Page, type PageType, type World } from "../../pages/index.ts";
4
+ /** 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. */
5
+ export declare function readFields(fields: string[] | Record<string, unknown>): Record<string, unknown>;
6
+ /** Items for list fields: each value gives one item, or several when it is a list; the same field may come more than once. */
7
+ export declare function readListItems(fields: string[] | Record<string, unknown>): Record<string, unknown[]>;
8
+ /**
9
+ * 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;
10
+ * 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).
11
+ */
12
+ export declare function oneItemLists(world: World, set: Record<string, unknown>, type: PageType | undefined): Record<string, unknown>;
13
+ /**
14
+ * 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
15
+ * the same write included (FOR-7), with a note that gives the values the system works out and what they come from.
16
+ */
17
+ export declare function withoutComputed(world: World, target: Page | undefined, set: Record<string, unknown>, name: string, type: PageType | undefined): {
18
+ set: Record<string, unknown>;
19
+ note?: string;
20
+ };
21
+ /** 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. */
22
+ export declare function listsWithoutComputed(world: World, target: Page | undefined, lists: Record<string, unknown[]> | undefined): {
23
+ lists?: Record<string, unknown[]>;
24
+ note?: string;
25
+ };
26
+ /** 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). */
27
+ export declare function asAmounts(world: World, set: Record<string, unknown>, coins: Coin[] | undefined): Record<string, unknown>;
28
+ /** 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). */
29
+ export declare function moneyNotesOf(world: World, page: string, set: Record<string, unknown> | undefined, coins: Coin[] | undefined, problem: Problem | undefined): string[];