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
@@ -21,3 +21,5 @@ export declare function realPath(path: string): string;
21
21
  * is a link to the folder. Such a package is never verified, whatever its name.
22
22
  */
23
23
  export declare function installedFromFolder(folder: string): boolean;
24
+ /** The name npm installed a package by, as @scope/name from node_modules/@scope/name; undefined for a folder that is no package of npm's own folder. */
25
+ export declare function npmPackageName(folder: string): string | undefined;
@@ -90,6 +90,13 @@ export function installedFromFolder(folder) {
90
90
  return false;
91
91
  }
92
92
  }
93
+ /** The name npm installed a package by, as @scope/name from node_modules/@scope/name; undefined for a folder that is no package of npm's own folder. */
94
+ export function npmPackageName(folder) {
95
+ const parts = resolve(folder).split(sep);
96
+ const name = parts.slice(parts.lastIndexOf("node_modules") + 1);
97
+ const fits = parts.includes("node_modules") && (name.length === 1 || (name.length === 2 && name[0].startsWith("@")));
98
+ return fits ? name.join("/") : undefined;
99
+ }
93
100
  /**
94
101
  * The packages the player installed in a folder of npm's, as the package.json beside it lists them; undefined where there is none, as for the engine's own
95
102
  * systems or a test's folder.
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type CardPage, type FigureSize } from "./package-api.ts";
2
+ import { type CardPage, type FigureSize } from "./api.ts";
3
3
  export type { CardPage, FigureSize };
4
4
  /**
5
5
  * The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
@@ -1,7 +1,7 @@
1
1
  // What every package for rpg-engine declares alike, an extension in extension.yaml and a game system in system.yaml (D-502, D-510, D-514): the version of the
2
2
  // API it is made for, and its icons, widgets and figures, with the same limits.
3
3
  import { z } from "zod";
4
- import { cardPages } from "./package-api.js";
4
+ import { cardPages } from "./api.js";
5
5
  /**
6
6
  * The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
7
7
  * system.yaml may declare. It goes up with every addition an older engine would refuse or misread, and the engine reads a range (D-515, D-549): 2 added the widgets, 3 an extension's
@@ -6,9 +6,9 @@ import { readFile } from "node:fs/promises";
6
6
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
7
7
  import { filesIn, foldersIn } from "./files.js";
8
8
  import { FileStore, isInside, readText, wroteInCall } from "./store.js";
9
- // The folders of a campaign below its own that hold what is kept: its pages, its house rules and its pictures. The campaign's folder holds its settings, state
10
- // and log.
11
- const watchedTrees = ["world", "rules", "images"];
9
+ // The folders of a campaign below its own that hold what is kept: its pages, its layers over the system's (SYS-11), its house rules and its pictures. The
10
+ // campaign's folder holds its settings, state and log.
11
+ const watchedTrees = ["world", "layers", "rules", "images"];
12
12
  // More changes than this between two calls, and a watcher on Linux may have lost some without a word: inotify keeps 16384 by default, then drops the rest.
13
13
  const tooManyChanges = 10_000;
14
14
  /** The files of a session of the MCP server, kept between calls and watched (D-193). */
@@ -35,8 +35,8 @@ export declare class FileStore {
35
35
  isLink(path: string): boolean;
36
36
  /** The links right inside `folder`, as they are now, by name, which entries leaves out; none when there is no such folder. */
37
37
  links(folder: string): string[];
38
- /** A file's bytes as they are now, as a save holds them; undefined when there is no file. */
39
- bytes(path: string): Uint8Array | undefined;
38
+ /** A file's bytes as they are now, as a save holds them, or only its first `length`; undefined when there is no file. */
39
+ bytes(path: string, length?: number): Uint8Array | undefined;
40
40
  /** The text of a file as it is now, for a command about to write it: in a call, the text the call reads; a session checks the disk (D-193). */
41
41
  fresh(path: string): string | undefined;
42
42
  /** Keeps the files of a campaign up to date for later calls: only the store of a session does (D-193). */
@@ -1,7 +1,7 @@
1
1
  // The files as a command sees them (D-137, D-194): each read at most once in a call, kept as its text and as what it reads as, frozen; what the command writes
2
2
  // updates what is kept. A command runs inside its store, and the modules reach it with files(): the MCP server will keep one for a whole session.
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
- import { appendFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
4
+ import { appendFileSync, closeSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
6
6
  import { fileOrder, filesIn } from "./files.js";
7
7
  import { frozen } from "./frozen.js";
@@ -80,9 +80,12 @@ export class FileStore {
80
80
  links(folder) {
81
81
  return existsSync(folder) && statSync(folder).isDirectory() ? readdirSync(folder, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink()).map((entry) => entry.name) : [];
82
82
  }
83
- /** A file's bytes as they are now, as a save holds them; undefined when there is no file. */
84
- bytes(path) {
85
- return existsSync(path) ? new Uint8Array(readFileSync(path)) : undefined;
83
+ /** A file's bytes as they are now, as a save holds them, or only its first `length`; undefined when there is no file. */
84
+ bytes(path, length) {
85
+ if (!existsSync(path)) {
86
+ return undefined;
87
+ }
88
+ return length === undefined ? new Uint8Array(readFileSync(path)) : firstBytes(path, length);
86
89
  }
87
90
  /** The text of a file as it is now, for a command about to write it: in a call, the text the call reads; a session checks the disk (D-193). */
88
91
  fresh(path) {
@@ -256,6 +259,17 @@ function changedSince(path, time) {
256
259
  const stats = statSync(path, { throwIfNoEntry: false });
257
260
  return stats === undefined || stats.mtimeMs >= time;
258
261
  }
262
+ /** The first `length` bytes of a file, or all of a shorter one, read without the rest. */
263
+ function firstBytes(path, length) {
264
+ const handle = openSync(path, "r");
265
+ try {
266
+ const bytes = new Uint8Array(length);
267
+ return bytes.subarray(0, readSync(handle, bytes, 0, length, 0));
268
+ }
269
+ finally {
270
+ closeSync(handle);
271
+ }
272
+ }
259
273
  /** Notes that the running call wrote a file, which a stop before its next write says (D-196). */
260
274
  function markWritten() {
261
275
  const call = running.getStore();
@@ -1,4 +1,4 @@
1
- import { strangerLabel } from "../labels.js";
1
+ import { strangerLabel } from "../parts/labels.js";
2
2
  import { t } from "../text.js";
3
3
  // The system's own verbs, by name, as the overview gives them (D-514).
4
4
  let systemVerbs = {};
@@ -0,0 +1,110 @@
1
+ // The player's sentences to the master (D-495), as the page holds them: the verbs of the sheet, the sentence being written, those said or copied and how the
2
+ // server holds them, sent, taken back, copied and gone from the strip after a while. The page's read() sets the acts and the verbs it reads, by their setters.
3
+ import { useEffect, useState } from "preact/hooks";
4
+ import { answer, readView, sayAct, withdrawAct } from "../api.js";
5
+ import { t } from "../text.js";
6
+ import { saidStates } from "./acts.js";
7
+ // How long a sentence the master heard, or one copied for the chat, stays in the strip (D-495).
8
+ const heardTime = 6000;
9
+ /** The player's sentences to the master and what the page does with them (D-495). */
10
+ export function useActs({ read, live, asked, foreground, version, players, member, several }) {
11
+ // The verbs of the player character's sheet, the sentences said or copied and how the server holds them, and the action the player is writing, with
12
+ // what started it, which has the focus back.
13
+ const [actions, setActions] = useState();
14
+ const [acts, setActs] = useState();
15
+ const [said, setSaid] = useState([]);
16
+ const [actProblem, setActProblem] = useState();
17
+ const [acting, setActing] = useState();
18
+ // Who acts from a sheet acts where they are: the place of one not in the foreground, read for them (VIEW-12).
19
+ const actsElsewhere = acting !== undefined && several && member?.role === "pc" && member.name !== foreground ? member.name : undefined;
20
+ const [actPlace, setActPlace] = useState();
21
+ useEffect(() => {
22
+ if (actsElsewhere === undefined) {
23
+ return;
24
+ }
25
+ let current = true;
26
+ void readView(undefined, 1, actsElsewhere).then((view) => {
27
+ if (current) {
28
+ setActPlace({ who: actsElsewhere, ...(view.kind === "overview" && view.place !== undefined ? { place: view.place } : {}) });
29
+ }
30
+ }, () => undefined);
31
+ return () => {
32
+ current = false;
33
+ };
34
+ }, [actsElsewhere, version]);
35
+ // The game gone, what the master had not heard is lost with the chat: the strip says so, even once the game is back (D-495).
36
+ useEffect(() => {
37
+ if (!live) {
38
+ setSaid((before) => before.map((one) => (acts?.heard.includes(one.id) === true ? one : { ...one, lost: true })));
39
+ }
40
+ }, [live]);
41
+ const strip = saidStates(said, acts, live);
42
+ const leaving = strip.filter((entry) => entry.state === "heard" || entry.state === "copied").map((entry) => entry.act.id).join();
43
+ // A sentence heard, or copied, goes from the strip after a while.
44
+ useEffect(() => {
45
+ if (leaving === "") {
46
+ return;
47
+ }
48
+ const timer = window.setTimeout(() => dismissAct(...leaving.split(",")), heardTime);
49
+ return () => window.clearTimeout(timer);
50
+ }, [leaving]);
51
+ const dismissAct = (...ids) => {
52
+ setSaid((before) => before.filter((one) => !ids.includes(one.id)));
53
+ setActProblem(undefined);
54
+ };
55
+ // With a question of the master's open, the sentence answers it (ASK-10); else it rings the master, or, in a chat that hears nothing by itself, is copied.
56
+ const question = asked !== undefined && asked.spend === undefined && asked.forced !== true ? asked : undefined;
57
+ const reply = question !== undefined ? "answer" : acts?.bell === true ? "tell" : "copy";
58
+ const sendAct = async (text) => {
59
+ setActProblem(undefined);
60
+ if (reply === "answer" && question !== undefined) {
61
+ const taken = await answer(question.id, text).catch(() => false);
62
+ void read();
63
+ return taken ? undefined : t("The answer did not reach the game: try again.");
64
+ }
65
+ if (reply === "copy") {
66
+ return await copyAct(text) ? undefined : t("Copy did not work: select the words and copy them yourself.");
67
+ }
68
+ const result = await sayAct(text);
69
+ if ("error" in result) {
70
+ return result.error;
71
+ }
72
+ setSaid((before) => [...before, { id: result.id, text }]);
73
+ setActs(result.shown);
74
+ return undefined;
75
+ };
76
+ const copyAct = async (text) => {
77
+ try {
78
+ await navigator.clipboard.writeText(text);
79
+ setSaid((before) => [...before.filter((one) => one.copied !== true || one.text !== text), { id: `copied ${Date.now()}`, text, copied: true }]);
80
+ return true;
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ };
86
+ // A sentence copied again from the strip goes from it; one that would not copy says so.
87
+ const copyFromStrip = (id, text) => void copyAct(text).then((done) => (done ? dismissAct(id) : setActProblem(t("Copy did not work: select the words and copy them yourself."))));
88
+ const withdraw = async (id) => {
89
+ const result = await withdrawAct(id);
90
+ if (result === "heard") {
91
+ setActProblem(t("The master has already heard it."));
92
+ void read();
93
+ }
94
+ else if (result === undefined) {
95
+ setActProblem(t("It did not reach the game: try again."));
96
+ }
97
+ else {
98
+ setActs(result);
99
+ dismissAct(id);
100
+ }
101
+ };
102
+ // The sheet closed, the focus goes back to what started the action.
103
+ const closeAct = () => {
104
+ const opener = acting?.opener;
105
+ setActing(undefined);
106
+ requestAnimationFrame(() => opener?.isConnected === true && opener.focus());
107
+ };
108
+ const playerActs = actions === undefined || players.length === 0 ? undefined : { actions, start: (start, opener) => setActing({ start, opener }) };
109
+ return { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct };
110
+ }
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "preact/hooks";
3
- import { Icon } from "../icons.js";
4
- import { PlaceMap } from "../place/map-view.js";
3
+ import { Icon } from "../parts/icons.js";
4
+ import { PlaceMap } from "../place/view.js";
5
5
  import { t } from "../text.js";
6
6
  import { actPeople, actSentence, actTitle, spokenBy, talkSentence, targetMode, verbLabel } from "./acts.js";
7
7
  // How many characters a sentence may have, as the server takes them.
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
2
2
  // The player's sentences after they go (D-495), in words and with a sign: said, with a button to take it back while it waits; called, the doorbell rang;
3
3
  // heard; or never heard, the chat gone, to say again there. A screen reader hears only the change of state.
4
4
  import { useEffect, useRef, useState } from "preact/hooks";
5
- import { Icon } from "../icons.js";
5
+ import { Icon } from "../parts/icons.js";
6
6
  import { t } from "../text.js";
7
7
  export function ActStrip({ entries, problem, onWithdraw, onCopy, onDismiss }) {
8
8
  const before = useRef(new Map());
@@ -46,6 +46,12 @@ export function sectionLabel(section) {
46
46
  };
47
47
  return labels[section];
48
48
  }
49
+ /** Writes the Scene's address over Combat's old one, without a step in the history. */
50
+ export function redirectCombat() {
51
+ if (/^#\/combat(\/|$)/.test(window.location.hash)) {
52
+ history.replaceState(null, "", sectionAddress("scene"));
53
+ }
54
+ }
49
55
  /** A part of an address as written, nothing when it is not well encoded. */
50
56
  function decoded(part) {
51
57
  try {
@@ -1,4 +1,4 @@
1
- import { refusalText } from "./refusals.js";
1
+ import { refusalText } from "./parts/refusals.js";
2
2
  import { t } from "./text.js";
3
3
  /** A picture's address, with when its file last changed, so that it comes again only when it changes. */
4
4
  export function pictureAddress(picture) {
@@ -3,48 +3,50 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
3
3
  // names and the table beside it, the turns of a fight, the followed quest and the rolls (D-279), read again whenever the server says something changed.
4
4
  import { render } from "preact";
5
5
  import { useEffect, useMemo, useRef, useState } from "preact/hooks";
6
- import { saidStates, setSystemVerbs } from "./acts/acts.js";
6
+ import { setSystemVerbs } from "./acts/acts.js";
7
7
  import { PlayerActsContext } from "./acts/names.js";
8
+ import { useActs } from "./acts/sending.js";
8
9
  import { ActSheet } from "./acts/sheet.js";
9
10
  import { ActStrip } from "./acts/strip.js";
10
- import { readAddress, sectionAddress } from "./address.js";
11
- import { answer, closeCard, readActs, readAsked, readChoices, readGameTheme, readModules, readView, readWidgets, sayAct, sendSeen, withdrawAct } from "./api.js";
12
- import { AskedDice } from "./asked-dice.js";
13
- import { AskedBanner } from "./asked.js";
14
- import { useMedia } from "./card.js";
15
- import { choicesOf, ChoicesPage, waits } from "./choices.js";
11
+ import { readAddress, redirectCombat, sectionAddress } from "./address.js";
12
+ import { answer, closeCard, readActs, readAsked, readChoices, readGameTheme, readModules, readView, readWidgets, sendSeen } from "./api.js";
16
13
  import { flies } from "./dice/pool.js";
17
14
  import { DiceTray } from "./dice/tray.js";
18
- import { PageFoot } from "./footer.js";
19
- import { readFree, withFree, writeFree } from "./free-rolls.js";
20
15
  import { Help } from "./help/help.js";
21
- import { Icon } from "./icons.js";
22
- import { FollowedQuests, JournalView, QuestEndings } from "./journal.js";
23
- import { checkOf, systemNameLabel } from "./labels.js";
24
- import { gameNotices, importNotices, Notices } from "./notices.js";
16
+ import { FollowedQuests, JournalView, QuestEndings } from "./journal/journal.js";
25
17
  import { AskCard } from "./packages/ask-card.js";
26
18
  import { inCard, nextPackCard } from "./packages/card.js";
27
- import { PackagePage } from "./packages/package-page.js";
28
19
  import { PackagesPage } from "./packages/packages.js";
29
20
  import { codeOfModule, ModulesContext, ownKey, preloadModules, systemPageStyle, useNavPages } from "./packages/page-code.js";
21
+ import { PackagePage } from "./packages/page.js";
30
22
  import { PeopleContext } from "./packages/people.js";
31
23
  import { WidgetCards, WidgetsContext } from "./packages/widgets.js";
32
- import { About } from "./pages.js";
33
- import { PartyStrip } from "./party.js";
34
- import { rollReaction } from "./reactions.js";
35
- import { requestedOf, RequestedRoll } from "./requested.js";
36
- import { RollLog } from "./rolls.js";
37
- import { SavesView } from "./saves.js";
38
- import { SceneView } from "./scene.js";
39
- import { SettingsView } from "./settings.js";
40
- import { SetupView, useSetup } from "./setup.js";
41
- import { MemberSheet } from "./sheet.js";
42
- import { gameStyleChanged, takeSystemStyle } from "./system-style.js";
43
- import { PlayTable, tableBeside, TableTab, useTableAway } from "./table.js";
24
+ import { useMedia } from "./parts/card.js";
25
+ import { Icon } from "./parts/icons.js";
26
+ import { checkOf, systemNameLabel } from "./parts/labels.js";
27
+ import { AskedDice } from "./play/asked-dice.js";
28
+ import { AskedBanner } from "./play/asked.js";
29
+ import { choicesOf, ChoicesPage, waits } from "./play/choices.js";
30
+ import { readFree, withFree, writeFree } from "./play/free-rolls.js";
31
+ import { rollReaction } from "./play/reactions.js";
32
+ import { requestedOf, RequestedRoll } from "./play/requested.js";
33
+ import { RollLog } from "./play/rolls.js";
34
+ import { SceneView } from "./play/scene.js";
35
+ import { hasTurns, TurnsCard, turnWords } from "./play/turns.js";
36
+ import { SavesView } from "./settings/saves.js";
37
+ import { SettingsView } from "./settings/settings.js";
38
+ import { SetupView, useSetup } from "./settings/setup.js";
39
+ import { PartyStrip } from "./sheet/party.js";
40
+ import { MemberSheet } from "./sheet/sheet.js";
41
+ import { PageFoot } from "./shell/footer.js";
42
+ import { gameNotices, importNotices, Notices } from "./shell/notices.js";
43
+ import { About } from "./shell/pages.js";
44
+ import { calledOf, playerNamed, turnKey, withHeld } from "./shell/shown.js";
45
+ import { gameStyleChanged, takeSystemStyle } from "./shell/system-style.js";
46
+ import { PlayTable, tableBeside, TableTab, useTableAway } from "./shell/table.js";
47
+ import { restoreTheme } from "./shell/theme.js";
48
+ import { SetupCorner, Top } from "./shell/top.js";
44
49
  import { browserLanguage, pageDirection, pageLocale, setLanguage, setSystemWords, t } from "./text.js";
45
- import { restoreTheme } from "./theme.js";
46
- import { SetupCorner, Top } from "./top.js";
47
- import { hasTurns, TurnsCard, turnWords } from "./turns.js";
48
50
  import { WorldView } from "./world/world.js";
49
51
  /** The product's name, as the page writes it: here only (D-276). */
50
52
  const productName = "RPG Engine";
@@ -52,8 +54,6 @@ const productName = "RPG Engine";
52
54
  const firstRolls = 20;
53
55
  // How long at most what a roll from a card or a die of a rest changed waits for its dice, when they never land.
54
56
  const longestHold = 15_000;
55
- // How long a sentence the master heard, or one copied for the chat, stays in the strip (D-495).
56
- const heardTime = 6000;
57
57
  function App() {
58
58
  const [shown, setShown] = useState({ party: [], sheet: [], text: "", rolls: [], rollsTotal: 0, version: 0 });
59
59
  const [live, setLive] = useState(false);
@@ -92,17 +92,12 @@ function App() {
92
92
  // Whether the player has just opened or folded the table, which slides it in and gives the focus to what folds it, or to its tab; at the first reading it
93
93
  // is simply there.
94
94
  const [tableMoved, setTableMoved] = useState(false);
95
- // The player's actions (D-495): the verbs of the player character's sheet, the sentences said or copied for the chat and how the server holds them,
96
- // and the action the player is writing, with what started it, which has the focus back.
97
- const [actions, setActions] = useState();
98
- const [acts, setActs] = useState();
99
- const [said, setSaid] = useState([]);
100
- const [actProblem, setActProblem] = useState();
101
- const [acting, setActing] = useState();
102
95
  // The widgets of the campaign's extensions (D-502), read beside the rest and shown as they come, so that a slow hook never holds the page back; kept as they
103
96
  // were when a reading of them fails, and an answer older than one shown left out.
104
97
  const [widgets, setWidgets] = useState([]);
105
98
  const [modules, setModules] = useState([]);
99
+ // Whether the page modules were read once: before, a package's page cannot yet be told missing.
100
+ const [modulesRead, setModulesRead] = useState(false);
106
101
  // The game's style turned on or off, or changed: every icon it draws anew is drawn again (D-528).
107
102
  const [, setStyled] = useState(0);
108
103
  useEffect(() => {
@@ -151,6 +146,7 @@ function App() {
151
146
  moduleReading.current.shown = modulesAsked;
152
147
  preloadModules(read.map(codeOfModule));
153
148
  setModules((before) => (JSON.stringify(before) === JSON.stringify(read) ? before : read));
149
+ setModulesRead(true);
154
150
  }, () => undefined);
155
151
  try {
156
152
  const [first, askedNow, actsNow, choicesNow] = await Promise.all([
@@ -458,23 +454,17 @@ function App() {
458
454
  // The one in the foreground, whose place the page shows; and whose card is at hand in a fight, the one whose sheet was read.
459
455
  const lead = playerNamed(shown.party, shown.foreground) ?? players[0];
460
456
  const actor = member?.role === "pc" ? member : lead;
461
- // Who acts from a sheet acts where they are: the place of one not in the foreground, read for them (VIEW-12).
462
- const actsElsewhere = acting !== undefined && several && member?.role === "pc" && member.name !== shown.foreground ? member.name : undefined;
463
- const [actPlace, setActPlace] = useState();
464
- useEffect(() => {
465
- if (actsElsewhere === undefined) {
466
- return;
467
- }
468
- let current = true;
469
- void readView(undefined, 1, actsElsewhere).then((view) => {
470
- if (current) {
471
- setActPlace({ who: actsElsewhere, ...(view.kind === "overview" && view.place !== undefined ? { place: view.place } : {}) });
472
- }
473
- }, () => undefined);
474
- return () => {
475
- current = false;
476
- };
477
- }, [actsElsewhere, shown.version]);
457
+ // The player's sentences to the master (D-495); read() sets the acts and the verbs it reads, by setters that never change.
458
+ const { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct } = useActs({
459
+ read,
460
+ live,
461
+ asked: shown.asked,
462
+ foreground: shown.foreground,
463
+ version: shown.version,
464
+ players,
465
+ member,
466
+ several,
467
+ });
478
468
  // A number of a sheet thrown for fun, each a throw of its own (D-280).
479
469
  const throwFromSheet = (roll, label, who) => setSheetThrow((before) => ({ number: (before?.number ?? 0) + 1, roll, label, ...(who === undefined ? {} : { who }) }));
480
470
  // A check answered from its row of the sheet or the tray's dice (D-330): as its button, the engine rolls it; the banner folds away meanwhile.
@@ -511,78 +501,6 @@ function App() {
511
501
  const turnName = several ? turnOf?.name : undefined;
512
502
  // The player character the master's question is for, named on it when there are more (D-480 (7)).
513
503
  const asker = several ? playerNamed(shown.party, shown.asked?.who) : undefined;
514
- // The game gone, what the master had not heard is lost with the chat: the strip says so, even once the game is back (D-495).
515
- useEffect(() => {
516
- if (!live) {
517
- setSaid((before) => before.map((one) => (acts?.heard.includes(one.id) === true ? one : { ...one, lost: true })));
518
- }
519
- }, [live]);
520
- const strip = saidStates(said, acts, live);
521
- const leaving = strip.filter((entry) => entry.state === "heard" || entry.state === "copied").map((entry) => entry.act.id).join();
522
- // A sentence heard, or copied, goes from the strip after a while.
523
- useEffect(() => {
524
- if (leaving === "") {
525
- return;
526
- }
527
- const timer = window.setTimeout(() => dismissAct(...leaving.split(",")), heardTime);
528
- return () => window.clearTimeout(timer);
529
- }, [leaving]);
530
- const dismissAct = (...ids) => {
531
- setSaid((before) => before.filter((one) => !ids.includes(one.id)));
532
- setActProblem(undefined);
533
- };
534
- // With a question of the master's open, the sentence answers it (ASK-10); else it rings the master, or, in a chat that hears nothing by itself, is copied.
535
- const question = shown.asked !== undefined && shown.asked.spend === undefined && shown.asked.forced !== true ? shown.asked : undefined;
536
- const reply = question !== undefined ? "answer" : acts?.bell === true ? "tell" : "copy";
537
- const sendAct = async (text) => {
538
- setActProblem(undefined);
539
- if (reply === "answer" && question !== undefined) {
540
- const taken = await answer(question.id, text).catch(() => false);
541
- void read();
542
- return taken ? undefined : t("The answer did not reach the game: try again.");
543
- }
544
- if (reply === "copy") {
545
- return await copyAct(text) ? undefined : t("Copy did not work: select the words and copy them yourself.");
546
- }
547
- const result = await sayAct(text);
548
- if ("error" in result) {
549
- return result.error;
550
- }
551
- setSaid((before) => [...before, { id: result.id, text }]);
552
- setActs(result.shown);
553
- return undefined;
554
- };
555
- const copyAct = async (text) => {
556
- try {
557
- await navigator.clipboard.writeText(text);
558
- setSaid((before) => [...before.filter((one) => one.copied !== true || one.text !== text), { id: `copied ${Date.now()}`, text, copied: true }]);
559
- return true;
560
- }
561
- catch {
562
- return false;
563
- }
564
- };
565
- const withdraw = async (id) => {
566
- const result = await withdrawAct(id);
567
- if (result === "heard") {
568
- setActProblem(t("The master has already heard it."));
569
- void read();
570
- }
571
- else if (result === undefined) {
572
- setActProblem(t("It did not reach the game: try again."));
573
- }
574
- else {
575
- setActs(result);
576
- dismissAct(id);
577
- }
578
- };
579
- // The sheet closed, the focus goes back to what started the action.
580
- const closeAct = () => {
581
- const opener = acting?.opener;
582
- setActing(undefined);
583
- requestAnimationFrame(() => opener?.isConnected === true && opener.focus());
584
- };
585
- const playerActs = actions === undefined || players.length === 0 ? undefined : { actions, start: (start, opener) => setActing({ start, opener }) };
586
504
  // The tab's title: the campaign's name and the product's; a question that waits marks it, to be seen from another tab (D-455).
587
505
  useEffect(() => {
588
506
  const name = shown.campaign === undefined ? productName : `${shown.campaign} · ${productName}`;
@@ -632,7 +550,7 @@ function App() {
632
550
  cards: shown.cards,
633
551
  version: shown.version,
634
552
  onRoll: throwFromSheet,
635
- } })), address.section === "world" && _jsx(WorldView, { version: shown.version, lead: lead, players: many ? players : undefined, tab: address.tab, item: address.name }), address.section === "settings" && _jsx(SettingsView, { version: shown.version, several: many }), address.section === "saves" && _jsx(SavesView, { version: shown.version, campaign: shown.campaign, several: many }), address.section === "packages" && _jsx(PackagesPage, { version: shown.version, tab: address.tab }), address.section === "pkg" && _jsx(PackagePage, { name: address.tab, page: address.name }), address.section === "choices" && (_jsx(ChoicesPage, { who: address.tab, open: address.name, choices: shown.choices, member: shown.party.find((one) => one.name === address.tab), version: shown.version, flying: thrown !== undefined && thrown.id !== landed ? thrown : undefined, onChanged: (choices) => setShown((before) => ({ ...before, choices })) })), address.section === "journal" && _jsx(JournalView, { version: shown.version, campaign: shown.campaign, tab: address.tab, item: address.name }), address.section === "party" && member && (_jsx(PlayerActsContext.Provider, { value: member.role === "pc" || playerActs === undefined ? playerActs : { ...playerActs, actions: {} }, children: _jsx(MemberSheet, { member: member, headline: shown.headline, sheet: shown.sheet, cards: shown.cards, text: shown.text, knownBy: shown.knownBy, story: shown.story, version: shown.version, onRoll: throwFromSheet, scene: shown.openScene, choices: choicesOf(shown.choices, member.name) }, member.name) }))] }), table
553
+ } })), address.section === "world" && _jsx(WorldView, { version: shown.version, lead: lead, players: many ? players : undefined, tab: address.tab, item: address.name }), address.section === "settings" && _jsx(SettingsView, { version: shown.version, several: many }), address.section === "saves" && _jsx(SavesView, { version: shown.version, campaign: shown.campaign, several: many }), address.section === "packages" && _jsx(PackagesPage, { version: shown.version, tab: address.tab }), address.section === "pkg" && _jsx(PackagePage, { name: address.tab, page: address.name, modulesRead: modulesRead }), address.section === "choices" && (_jsx(ChoicesPage, { who: address.tab, open: address.name, choices: shown.choices, member: shown.party.find((one) => one.name === address.tab), version: shown.version, flying: thrown !== undefined && thrown.id !== landed ? thrown : undefined, onChanged: (choices) => setShown((before) => ({ ...before, choices })) })), address.section === "journal" && _jsx(JournalView, { version: shown.version, campaign: shown.campaign, tab: address.tab, item: address.name }), address.section === "party" && member && (_jsx(PlayerActsContext.Provider, { value: member.role === "pc" || playerActs === undefined ? playerActs : { ...playerActs, actions: {} }, children: _jsx(MemberSheet, { member: member, headline: shown.headline, sheet: shown.sheet, cards: shown.cards, text: shown.text, knownBy: shown.knownBy, story: shown.story, version: shown.version, onRoll: throwFromSheet, scene: shown.openScene, choices: choicesOf(shown.choices, member.name) }, member.name) }))] }), table
636
554
  ? (_jsxs(PlayTable, { entering: tableMoved, onFold: () => {
637
555
  setTableMoved(true);
638
556
  setTableAway(true);
@@ -653,49 +571,7 @@ function App() {
653
571
  }, onFree: (roll) => {
654
572
  setFree((before) => withFree(shown.campaign, before, roll));
655
573
  setFresh((before) => new Set([...before, roll.id]));
656
- } }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: (id, text) => void copyAct(text).then((done) => (done ? dismissAct(id) : setActProblem(t("Copy did not work: select the words and copy them yourself.")))), onDismiss: dismissAct })] }) }) }) }) }) }));
657
- }
658
- /** The player character of the party by their name; undefined for anyone else, or none. */
659
- function playerNamed(party, name) {
660
- return name === undefined ? undefined : party.find((member) => member.role === "pc" && member.name === name);
661
- }
662
- /**
663
- * Whose sheet the page reads when the address names no one (D-480 (7)): in the Party section the player character the master asks, then whose turn it is;
664
- * elsewhere whose turn it is first, for the card at hand in a fight; else the one in the foreground, else the first.
665
- */
666
- function calledOf(party, section, asked, scene, foreground) {
667
- const asking = playerNamed(party, asked?.who);
668
- const acting = hasTurns(scene) ? playerNamed(party, scene.turn) : undefined;
669
- return (section === "party" ? asking ?? acting : acting ?? asking) ?? playerNamed(party, foreground) ?? party[0];
670
- }
671
- /** The turn of a scene that goes by them, as the round and who acts; empty outside turns. */
672
- function turnKey(scene) {
673
- return hasTurns(scene) ? `${scene.title} ${scene.since ?? ""} ${scene.round ?? ""} ${scene.turn ?? ""}` : "";
674
- }
675
- /** The page as read now; while a card's dice fly, with the sheet and the fight as they were, what the roll changed kept until they land (D-461). */
676
- function withHeld(before, next, hold) {
677
- if (!hold) {
678
- return { ...next, pending: undefined };
679
- }
680
- const steady = (shown) => ({
681
- party: shown.party,
682
- chosen: shown.chosen,
683
- headline: shown.headline,
684
- sheet: shown.sheet,
685
- cards: shown.cards,
686
- text: shown.text,
687
- knownBy: shown.knownBy,
688
- story: shown.story,
689
- openScene: shown.openScene,
690
- pack: shown.pack,
691
- });
692
- return { ...next, ...steady(before), pending: steady(next) };
693
- }
694
- /** Writes the Scene's address over Combat's old one, without a step in the history. */
695
- function redirectCombat() {
696
- if (/^#\/combat(\/|$)/.test(window.location.hash)) {
697
- history.replaceState(null, "", sectionAddress("scene"));
698
- }
574
+ } }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: copyFromStrip, onDismiss: dismissAct })] }) }) }) }) }) }));
699
575
  }
700
576
  // The theme the player picked before, from the start (D-300).
701
577
  restoreTheme();
@@ -1,7 +1,7 @@
1
1
  // The dice thrown on the page (D-278): the models loaded once, the stage, and each throw: all the dice together, then again those rerolled or exploded, past
2
2
  // those that lie still; each shown turned by one of its symmetries so that it lands on its value, with its knocks. The tray loads it, with three.js and
3
3
  // Rapier, at its first throw.
4
- import { readChoice } from "../prefs.js";
4
+ import { readChoice } from "../shell/prefs.js";
5
5
  import { loadDice } from "./load.js";
6
6
  import { coinKind, combine, landingTurn, symmetries } from "./models.js";
7
7
  import { coinOf, diceEdgesPref } from "./sets.js";
@@ -1,8 +1,8 @@
1
1
  // The look of the dice the player rolls (D-279, D-348, D-352): the theme's, or one of the sets chosen in Settings, as sets of real dice, each a material, a
2
2
  // body and the ink of its numbers: resin, metal, wood, stone or crystal, the wood and the stone from CC0 pictures of ambientCG (assets/dice/textures). Kept in
3
3
  // this browser alone. The coins of the dice's material or of a metal, also chosen there (D-526).
4
- import { readChoice } from "../prefs.js";
5
- import { shownTheme } from "../theme.js";
4
+ import { readChoice } from "../shell/prefs.js";
5
+ import { shownTheme } from "../shell/theme.js";
6
6
  const resin = { roughness: 0.35, metalness: 0.05, shine: 0 };
7
7
  const metal = { roughness: 0.3, metalness: 1, shine: 1 };
8
8
  // The gems and the glass: the page and their far faces seen through them (D-418).
@@ -3,7 +3,7 @@
3
3
  // of the same materials, or of the metal chosen (D-526 (1)).
4
4
  import * as THREE from "three";
5
5
  import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
6
- import { shownTheme } from "../theme.js";
6
+ import { shownTheme } from "../shell/theme.js";
7
7
  import { burnAway, crack } from "./burn.js";
8
8
  import { celebrate, embers, lightInk, makePictures } from "./celebration.js";
9
9
  import { floorCrackMaterial } from "./floor-cracks.js";
@@ -6,12 +6,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
6
6
  // notation. The dice and their physics load at the first throw. Coins too, one to three, never with dice: a toss shown lands on its faces, and the player tosses
7
7
  // them as free dice (D-524 (1)).
8
8
  import { useEffect, useRef, useState } from "preact/hooks";
9
- import { CoinFace, CoinFaces, DiceFaces, tossWords } from "../faces.js";
10
- import { DieIcon, Icon } from "../icons.js";
11
- import { notationModifier, shownText, signed } from "../labels.js";
12
- import { Token } from "../party.js";
13
- import { soundPref, useChoice, usePref } from "../prefs.js";
14
- import { trayCheck, useRequested } from "../requested.js";
9
+ import { CoinFace, CoinFaces, DiceFaces, tossWords } from "../parts/faces.js";
10
+ import { DieIcon, Icon } from "../parts/icons.js";
11
+ import { notationModifier, shownText, signed } from "../parts/labels.js";
12
+ import { trayCheck, useRequested } from "../play/requested.js";
13
+ import { Token } from "../sheet/party.js";
14
+ import { soundPref, useChoice, usePref } from "../shell/prefs.js";
15
15
  import { arrowStep, capitalized, t } from "../text.js";
16
16
  import { coinsToThrow, diceToThrow, rareFace } from "./models.js";
17
17
  import { diceText, dieName, doubled, droppedBy, keptOf, keptTotal, mostCoins, notation, trayCoin, trayDice, withAdded, withDropped } from "./pool.js";