rpg-engine 0.15.0 → 0.17.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 (503) hide show
  1. package/dist/adventures/source.d.ts +3 -1
  2. package/dist/adventures/source.js +31 -1
  3. package/dist/campaign/find-campaign.js +8 -4
  4. package/dist/campaign/index.d.ts +1 -1
  5. package/dist/campaign/index.js +1 -1
  6. package/dist/campaign/settings.d.ts +6 -0
  7. package/dist/campaign/settings.js +22 -1
  8. package/dist/cli/cli.js +1 -1
  9. package/dist/cli/command-line.js +1 -1
  10. package/dist/commands/advance.d.ts +1 -1
  11. package/dist/commands/advance.js +6 -6
  12. package/dist/commands/ask.js +7 -7
  13. package/dist/commands/change/amounts.d.ts +32 -0
  14. package/dist/commands/change/amounts.js +150 -0
  15. package/dist/commands/change/change.d.ts +4 -54
  16. package/dist/commands/change/change.js +19 -749
  17. package/dist/commands/change/damage.d.ts +30 -0
  18. package/dist/commands/change/damage.js +73 -2
  19. package/dist/commands/change/dice.d.ts +34 -0
  20. package/dist/commands/change/dice.js +59 -0
  21. package/dist/commands/change/fields.d.ts +37 -0
  22. package/dist/commands/change/fields.js +156 -0
  23. package/dist/commands/change/holder.d.ts +48 -0
  24. package/dist/commands/change/holder.js +162 -0
  25. package/dist/commands/change/recipe-pace.js +1 -1
  26. package/dist/commands/change/recipe.d.ts +58 -0
  27. package/dist/commands/change/recipe.js +179 -0
  28. package/dist/commands/choices.js +3 -3
  29. package/dist/commands/config/config.d.ts +15 -0
  30. package/dist/commands/config/config.js +355 -0
  31. package/dist/commands/config/custom-levels.d.ts +7 -0
  32. package/dist/commands/config/custom-levels.js +32 -0
  33. package/dist/commands/{config.d.ts → config/dashboard.d.ts} +2 -24
  34. package/dist/commands/config/dashboard.js +171 -0
  35. package/dist/commands/config/entries.d.ts +17 -0
  36. package/dist/commands/config/entries.js +76 -0
  37. package/dist/commands/config/news.d.ts +7 -0
  38. package/dist/commands/config/news.js +88 -0
  39. package/dist/commands/config/shown.d.ts +9 -0
  40. package/dist/commands/config/shown.js +80 -0
  41. package/dist/commands/config/words.d.ts +27 -0
  42. package/dist/commands/config/words.js +204 -0
  43. package/dist/commands/effect.js +9 -9
  44. package/dist/commands/find.js +1 -1
  45. package/dist/commands/image.js +6 -6
  46. package/dist/commands/import/import.d.ts +0 -2
  47. package/dist/commands/import/import.js +68 -45
  48. package/dist/commands/import/run.js +1 -1
  49. package/dist/commands/index.js +3 -3
  50. package/dist/commands/init.js +2 -2
  51. package/dist/commands/install.js +1 -1
  52. package/dist/commands/instructions.js +6 -6
  53. package/dist/commands/mode.d.ts +2 -2
  54. package/dist/commands/mode.js +8 -8
  55. package/dist/commands/mood.js +4 -4
  56. package/dist/commands/move.js +10 -10
  57. package/dist/commands/package/consent.d.ts +11 -0
  58. package/dist/commands/package/consent.js +52 -0
  59. package/dist/commands/package/here.d.ts +51 -0
  60. package/dist/commands/package/here.js +128 -0
  61. package/dist/commands/package/install.d.ts +10 -0
  62. package/dist/commands/package/install.js +337 -0
  63. package/dist/commands/package/package.d.ts +18 -0
  64. package/dist/commands/package/package.js +270 -0
  65. package/dist/commands/package/result.d.ts +89 -0
  66. package/dist/commands/package/result.js +1 -0
  67. package/dist/commands/package/uninstall.d.ts +6 -0
  68. package/dist/commands/package/uninstall.js +70 -0
  69. package/dist/commands/rename.js +3 -3
  70. package/dist/commands/reveal.js +5 -5
  71. package/dist/commands/roll/roll.js +11 -9
  72. package/dist/commands/roll/tables.js +1 -1
  73. package/dist/commands/rules.d.ts +2 -2
  74. package/dist/commands/rules.js +3 -3
  75. package/dist/commands/save.d.ts +2 -2
  76. package/dist/commands/save.js +2 -2
  77. package/dist/commands/scene/close.d.ts +18 -0
  78. package/dist/commands/scene/close.js +179 -0
  79. package/dist/commands/scene/members.d.ts +14 -0
  80. package/dist/commands/scene/members.js +32 -0
  81. package/dist/commands/scene/open.d.ts +6 -0
  82. package/dist/commands/scene/open.js +298 -0
  83. package/dist/commands/scene/result.d.ts +98 -0
  84. package/dist/commands/scene/result.js +2 -0
  85. package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
  86. package/dist/commands/scene/scene.js +210 -0
  87. package/dist/commands/scene/turns.d.ts +18 -0
  88. package/dist/commands/scene/turns.js +229 -0
  89. package/dist/commands/shared/books/adventure-layers.d.ts +89 -0
  90. package/dist/commands/shared/books/adventure-layers.js +201 -0
  91. package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +28 -9
  92. package/dist/commands/shared/{adventures.js → books/adventures.js} +77 -35
  93. package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
  94. package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
  95. package/dist/commands/shared/{library.js → books/library.js} +9 -9
  96. package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
  97. package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
  98. package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
  99. package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
  100. package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
  101. package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
  102. package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
  103. package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
  104. package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
  105. package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
  106. package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
  107. package/dist/commands/shared/{mode.js → campaign/mode.js} +24 -13
  108. package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
  109. package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
  110. package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
  111. package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
  112. package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
  113. package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
  114. package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +3 -3
  115. package/dist/commands/shared/{parts.js → campaign/parts.js} +3 -3
  116. package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
  117. package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
  118. package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
  119. package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
  120. package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
  121. package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
  122. package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
  123. package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
  124. package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
  125. package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
  126. package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
  127. package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
  128. package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
  129. package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
  130. package/dist/commands/shared/characters/orders.d.ts +4 -0
  131. package/dist/commands/shared/characters/orders.js +10 -0
  132. package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +9 -6
  133. package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +17 -7
  134. package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
  135. package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
  136. package/dist/commands/shared/examples.js +2 -2
  137. package/dist/commands/shared/packages/catalog.js +2 -2
  138. package/dist/commands/shared/packages/code.d.ts +1 -1
  139. package/dist/commands/shared/packages/code.js +8 -8
  140. package/dist/commands/shared/packages/extensions.d.ts +1 -1
  141. package/dist/commands/shared/packages/extensions.js +1 -1
  142. package/dist/commands/shared/packages/hooks.d.ts +1 -1
  143. package/dist/commands/shared/packages/hooks.js +1 -1
  144. package/dist/commands/shared/packages/widgets.d.ts +3 -3
  145. package/dist/commands/shared/packages/widgets.js +3 -3
  146. package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
  147. package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
  148. package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
  149. package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
  150. package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
  151. package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
  152. package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
  153. package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
  154. package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
  155. package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
  156. package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
  157. package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
  158. package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
  159. package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
  160. package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
  161. package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
  162. package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
  163. package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
  164. package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
  165. package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
  166. package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
  167. package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
  168. package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
  169. package/dist/commands/shared/{scene.js → scene/scene.js} +10 -8
  170. package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
  171. package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
  172. package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
  173. package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
  174. package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
  175. package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
  176. package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
  177. package/dist/commands/shared/sheet/effect-values.js +69 -0
  178. package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
  179. package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
  180. package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
  181. package/dist/commands/shared/sheet/formula-problems.js +140 -0
  182. package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
  183. package/dist/commands/shared/sheet/formula-scope.js +235 -0
  184. package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
  185. package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
  186. package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
  187. package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
  188. package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +7 -5
  189. package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
  190. package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
  191. package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
  192. package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
  193. package/dist/commands/shared/sheet/system-fields.js +45 -0
  194. package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
  195. package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
  196. package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
  197. package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
  198. package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
  199. package/dist/commands/shared/sheet/worked-out.js +291 -0
  200. package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
  201. package/dist/commands/shared/sheet/worked-text.js +55 -0
  202. package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
  203. package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
  204. package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
  205. package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
  206. package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
  207. package/dist/commands/shared/{events.js → time/events.js} +10 -13
  208. package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
  209. package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
  210. package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
  211. package/dist/commands/shared/{time.js → time/time.js} +6 -6
  212. package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
  213. package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
  214. package/dist/commands/show.d.ts +9 -0
  215. package/dist/commands/show.js +43 -10
  216. package/dist/commands/status.d.ts +2 -1
  217. package/dist/commands/status.js +28 -22
  218. package/dist/commands/thoughts.d.ts +1 -0
  219. package/dist/commands/thoughts.js +26 -18
  220. package/dist/commands/trade.js +8 -8
  221. package/dist/commands/translate.d.ts +1 -1
  222. package/dist/commands/translate.js +3 -3
  223. package/dist/commands/travel/open.d.ts +1 -1
  224. package/dist/commands/travel/open.js +2 -2
  225. package/dist/commands/travel/route.js +7 -6
  226. package/dist/commands/travel/travel.d.ts +1 -1
  227. package/dist/commands/travel/travel.js +8 -8
  228. package/dist/commands/validate.js +3 -3
  229. package/dist/commands/view/journal.d.ts +2 -2
  230. package/dist/commands/view/journal.js +2 -2
  231. package/dist/commands/view/layers.d.ts +34 -0
  232. package/dist/commands/view/layers.js +44 -0
  233. package/dist/commands/view/map.d.ts +1 -1
  234. package/dist/commands/view/map.js +6 -6
  235. package/dist/commands/view/memory.d.ts +16 -0
  236. package/dist/commands/view/memory.js +96 -0
  237. package/dist/commands/view/page.d.ts +32 -0
  238. package/dist/commands/view/page.js +166 -0
  239. package/dist/commands/view/place.d.ts +7 -2
  240. package/dist/commands/view/place.js +30 -12
  241. package/dist/commands/view/result.d.ts +252 -0
  242. package/dist/commands/view/result.js +1 -0
  243. package/dist/commands/view/saves.d.ts +6 -0
  244. package/dist/commands/view/saves.js +53 -0
  245. package/dist/commands/view/story.d.ts +32 -0
  246. package/dist/commands/view/story.js +227 -0
  247. package/dist/commands/view/view.d.ts +29 -292
  248. package/dist/commands/view/view.js +31 -536
  249. package/dist/commands/view/world.d.ts +1 -1
  250. package/dist/commands/view/world.js +3 -3
  251. package/dist/commands/write/checks.d.ts +42 -0
  252. package/dist/commands/write/checks.js +291 -0
  253. package/dist/commands/write/here.d.ts +1 -1
  254. package/dist/commands/write/here.js +5 -5
  255. package/dist/commands/write/inheritance.d.ts +40 -0
  256. package/dist/commands/write/inheritance.js +185 -0
  257. package/dist/commands/write/input.d.ts +29 -0
  258. package/dist/commands/write/input.js +124 -0
  259. package/dist/commands/write/layer.d.ts +44 -0
  260. package/dist/commands/write/layer.js +68 -0
  261. package/dist/commands/write/notes.d.ts +22 -0
  262. package/dist/commands/write/notes.js +76 -0
  263. package/dist/commands/write/progression.d.ts +27 -0
  264. package/dist/commands/write/progression.js +175 -0
  265. package/dist/commands/write/write.d.ts +2 -0
  266. package/dist/commands/write/write.js +36 -816
  267. package/dist/core/files.d.ts +2 -0
  268. package/dist/core/files.js +7 -0
  269. package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
  270. package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
  271. package/dist/core/session-store.js +3 -3
  272. package/dist/core/store.d.ts +2 -2
  273. package/dist/core/store.js +18 -4
  274. package/dist/core/text.d.ts +2 -0
  275. package/dist/core/text.js +4 -0
  276. package/dist/dashboard/acts/acts.js +1 -1
  277. package/dist/dashboard/acts/sending.js +110 -0
  278. package/dist/dashboard/acts/sheet.js +2 -2
  279. package/dist/dashboard/acts/strip.js +1 -1
  280. package/dist/dashboard/address.js +6 -0
  281. package/dist/dashboard/api.js +19 -1
  282. package/dist/dashboard/app.js +51 -171
  283. package/dist/dashboard/dice/roller.js +1 -1
  284. package/dist/dashboard/dice/sets.js +2 -2
  285. package/dist/dashboard/dice/stage.js +1 -1
  286. package/dist/dashboard/dice/tray.js +6 -6
  287. package/dist/dashboard/guide/ar.md +7 -3
  288. package/dist/dashboard/guide/cs.md +9 -5
  289. package/dist/dashboard/guide/da.md +9 -5
  290. package/dist/dashboard/guide/de.md +7 -3
  291. package/dist/dashboard/guide/el.md +9 -5
  292. package/dist/dashboard/guide/en.md +4 -0
  293. package/dist/dashboard/guide/es.md +8 -4
  294. package/dist/dashboard/guide/fi.md +9 -5
  295. package/dist/dashboard/guide/fr.md +8 -4
  296. package/dist/dashboard/guide/he.md +7 -3
  297. package/dist/dashboard/guide/hi.md +10 -6
  298. package/dist/dashboard/guide/hu.md +8 -4
  299. package/dist/dashboard/guide/is.md +9 -5
  300. package/dist/dashboard/guide/it.md +5 -1
  301. package/dist/dashboard/guide/ja.md +9 -5
  302. package/dist/dashboard/guide/ko.md +8 -4
  303. package/dist/dashboard/guide/nb.md +8 -4
  304. package/dist/dashboard/guide/nl.md +8 -4
  305. package/dist/dashboard/guide/pl.md +8 -4
  306. package/dist/dashboard/guide/pt.md +7 -3
  307. package/dist/dashboard/guide/ro.md +9 -5
  308. package/dist/dashboard/guide/ru.md +8 -4
  309. package/dist/dashboard/guide/sv.md +9 -5
  310. package/dist/dashboard/guide/tr.md +9 -5
  311. package/dist/dashboard/guide/uk.md +8 -4
  312. package/dist/dashboard/guide/zh.md +8 -4
  313. package/dist/dashboard/help/help.js +3 -3
  314. package/dist/dashboard/i18n/ar.json +29 -0
  315. package/dist/dashboard/i18n/cs.json +29 -0
  316. package/dist/dashboard/i18n/da.json +29 -0
  317. package/dist/dashboard/i18n/de.json +29 -0
  318. package/dist/dashboard/i18n/el.json +29 -0
  319. package/dist/dashboard/i18n/es.json +29 -0
  320. package/dist/dashboard/i18n/fi.json +29 -0
  321. package/dist/dashboard/i18n/fr.json +29 -0
  322. package/dist/dashboard/i18n/he.json +29 -0
  323. package/dist/dashboard/i18n/hi.json +29 -0
  324. package/dist/dashboard/i18n/hu.json +29 -0
  325. package/dist/dashboard/i18n/is.json +29 -0
  326. package/dist/dashboard/i18n/it.json +29 -0
  327. package/dist/dashboard/i18n/ja.json +30 -1
  328. package/dist/dashboard/i18n/ko.json +29 -0
  329. package/dist/dashboard/i18n/nb.json +29 -0
  330. package/dist/dashboard/i18n/nl.json +29 -0
  331. package/dist/dashboard/i18n/pl.json +29 -0
  332. package/dist/dashboard/i18n/pt.json +29 -0
  333. package/dist/dashboard/i18n/ro.json +29 -0
  334. package/dist/dashboard/i18n/ru.json +29 -0
  335. package/dist/dashboard/i18n/sv.json +29 -0
  336. package/dist/dashboard/i18n/tr.json +29 -0
  337. package/dist/dashboard/i18n/uk.json +29 -0
  338. package/dist/dashboard/i18n/zh.json +29 -0
  339. package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
  340. package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
  341. package/dist/dashboard/kit.js +3 -3
  342. package/dist/dashboard/packages/ask-card.js +3 -3
  343. package/dist/dashboard/packages/catalog.js +196 -0
  344. package/dist/dashboard/packages/changes.js +111 -0
  345. package/dist/dashboard/packages/engine.js +87 -0
  346. package/dist/dashboard/packages/installed.js +53 -0
  347. package/dist/dashboard/packages/library.js +97 -0
  348. package/dist/dashboard/packages/outcomes.js +45 -0
  349. package/dist/dashboard/packages/packages.js +27 -578
  350. package/dist/dashboard/packages/page-code.js +15 -2
  351. package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
  352. package/dist/dashboard/packages/rows.js +84 -0
  353. package/dist/dashboard/packages/share.js +44 -0
  354. package/dist/dashboard/packages/widgets.js +3 -3
  355. package/dist/dashboard/{card.js → parts/card.js} +1 -1
  356. package/dist/dashboard/parts/changed.js +37 -0
  357. package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
  358. package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
  359. package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
  360. package/dist/dashboard/{labels.js → parts/labels.js} +2 -1
  361. package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
  362. package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
  363. package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
  364. package/dist/dashboard/{refusals.js → parts/refusals.js} +5 -1
  365. package/dist/dashboard/{status.js → parts/status.js} +4 -4
  366. package/dist/dashboard/{widgets.js → parts/widgets.js} +5 -3
  367. package/dist/dashboard/place/key.js +24 -0
  368. package/dist/dashboard/place/paper.js +67 -0
  369. package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
  370. package/dist/dashboard/place/things.js +129 -0
  371. package/dist/dashboard/place/tokens.js +93 -0
  372. package/dist/dashboard/place/view.js +124 -0
  373. package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
  374. package/dist/dashboard/{asked.js → play/asked.js} +10 -10
  375. package/dist/dashboard/{choices.js → play/choices.js} +11 -10
  376. package/dist/dashboard/{requested.js → play/requested.js} +1 -1
  377. package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
  378. package/dist/dashboard/{scene.js → play/scene.js} +14 -14
  379. package/dist/dashboard/{turns.js → play/turns.js} +12 -12
  380. package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
  381. package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
  382. package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
  383. package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
  384. package/dist/dashboard/{setup.js → settings/setup.js} +5 -5
  385. package/dist/dashboard/{party.js → sheet/party.js} +8 -8
  386. package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
  387. package/dist/dashboard/{sheet.js → sheet/sheet.js} +27 -24
  388. package/dist/dashboard/{story.js → sheet/story.js} +3 -3
  389. package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
  390. package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
  391. package/dist/dashboard/{master.js → shell/master.js} +2 -2
  392. package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
  393. package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
  394. package/dist/dashboard/shell/shown.js +38 -0
  395. package/dist/dashboard/{table.js → shell/table.js} +2 -2
  396. package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
  397. package/dist/dashboard/{top.js → shell/top.js} +7 -7
  398. package/dist/dashboard/style.css +288 -4
  399. package/dist/dashboard/world/calendar.js +4 -4
  400. package/dist/dashboard/world/drawing.js +92 -0
  401. package/dist/dashboard/world/key.js +21 -0
  402. package/dist/dashboard/world/lore.js +10 -6
  403. package/dist/dashboard/world/map-card.js +186 -0
  404. package/dist/dashboard/world/place-card.js +39 -0
  405. package/dist/dashboard/world/places.js +29 -0
  406. package/dist/dashboard/world/world.js +9 -341
  407. package/dist/extensions/extension.d.ts +1 -1
  408. package/dist/extensions/extension.js +1 -1
  409. package/dist/images/images.js +12 -9
  410. package/dist/index.d.ts +1 -1
  411. package/dist/languages/index.d.ts +1 -1
  412. package/dist/languages/index.js +1 -1
  413. package/dist/packages/npm.js +1 -1
  414. package/dist/page.d.ts +2 -2
  415. package/dist/page.js +1 -1
  416. package/dist/pages/check.js +23 -1
  417. package/dist/pages/containers.d.ts +1 -1
  418. package/dist/pages/containers.js +1 -1
  419. package/dist/pages/index.d.ts +4 -2
  420. package/dist/pages/index.js +4 -2
  421. package/dist/pages/inheritance.d.ts +2 -2
  422. package/dist/pages/layers.d.ts +52 -0
  423. package/dist/pages/layers.js +105 -0
  424. package/dist/pages/markdown.d.ts +5 -1
  425. package/dist/pages/markdown.js +13 -1
  426. package/dist/pages/rename-page.js +1 -1
  427. package/dist/pages/stacks/writes.js +48 -22
  428. package/dist/pages/standard-fields.d.ts +1 -1
  429. package/dist/pages/system-pages.d.ts +5 -3
  430. package/dist/pages/system-pages.js +16 -7
  431. package/dist/pages/world.d.ts +8 -1
  432. package/dist/pages/world.js +16 -4
  433. package/dist/pages/write-layer.d.ts +23 -0
  434. package/dist/pages/write-layer.js +162 -0
  435. package/dist/pages/write-page.d.ts +2 -2
  436. package/dist/pages/write-page.js +2 -2
  437. package/dist/rules/index.d.ts +1 -1
  438. package/dist/rules/index.js +1 -1
  439. package/dist/rules/search.d.ts +1 -1
  440. package/dist/rules/shown.d.ts +1 -1
  441. package/dist/server/dashboard/choices.d.ts +2 -0
  442. package/dist/server/dashboard/choices.js +6 -4
  443. package/dist/server/dashboard/files.js +5 -5
  444. package/dist/server/dashboard/index.d.ts +2 -2
  445. package/dist/server/dashboard/index.js +7 -3
  446. package/dist/server/dashboard/news.js +4 -3
  447. package/dist/server/dashboard/player.js +1 -1
  448. package/dist/server/dashboard/writes.d.ts +7 -0
  449. package/dist/server/dashboard/writes.js +48 -7
  450. package/dist/server/mcp.js +28 -13
  451. package/dist/systems/campaign-data.d.ts +15 -0
  452. package/dist/systems/campaign-data.js +85 -0
  453. package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
  454. package/dist/systems/{system-code.js → code.js} +2 -2
  455. package/dist/systems/game-system.d.ts +7 -61
  456. package/dist/systems/game-system.js +1 -984
  457. package/dist/systems/index.d.ts +6 -3
  458. package/dist/systems/index.js +6 -3
  459. package/dist/systems/installed.d.ts +31 -0
  460. package/dist/systems/installed.js +89 -0
  461. package/dist/systems/maps.d.ts +3 -0
  462. package/dist/systems/maps.js +9 -0
  463. package/dist/systems/read.d.ts +3 -0
  464. package/dist/systems/read.js +471 -0
  465. package/dist/systems/schema.d.ts +289 -0
  466. package/dist/systems/schema.js +243 -0
  467. package/dist/systems/settings.d.ts +19 -0
  468. package/dist/systems/settings.js +78 -0
  469. package/dist/systems/versions.d.ts +12 -0
  470. package/dist/systems/versions.js +52 -0
  471. package/dist/testing/index.js +1 -1
  472. package/instructions/import.md +1 -1
  473. package/instructions/play.md +1 -1
  474. package/instructions/voices.md +1 -1
  475. package/package.json +1 -1
  476. package/dist/commands/config.js +0 -948
  477. package/dist/commands/package.d.ts +0 -143
  478. package/dist/commands/package.js +0 -785
  479. package/dist/commands/scene.js +0 -894
  480. package/dist/commands/shared/worked-out.js +0 -805
  481. package/dist/dashboard/place/map-view.js +0 -417
  482. /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
  483. /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
  484. /package/dist/core/{package-api.js → packages/api.js} +0 -0
  485. /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
  486. /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
  487. /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
  488. /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
  489. /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
  490. /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
  491. /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
  492. /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
  493. /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
  494. /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
  495. /package/dist/languages/{language-pack.js → pack.js} +0 -0
  496. /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
  497. /package/dist/pages/{page-file.js → file.js} +0 -0
  498. /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
  499. /package/dist/pages/{page-types.js → types.js} +0 -0
  500. /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
  501. /package/dist/rules/{rule-book.js → book.js} +0 -0
  502. /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
  503. /package/dist/systems/{system-folders.js → folders.js} +0 -0
@@ -1,31 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  // The World section (D-276, D-318), in four tabs: the world map as the player character knows it, hexes on paper that stays light in both themes, the names in
3
3
  // the story's serif, and the places as a list, its twin; what the character knows, its documents and the calendar. The map moves and zooms with the mouse, the
4
4
  // wheel, touch and the keys; a place opens its card. The page draws only what view gives with map and world (VIEW-7, VIEW-11): a place the character does not
5
5
  // know never reaches it.
6
6
  import { useEffect, useMemo, useRef, useState } from "preact/hooks";
7
7
  import { sectionAddress } from "../address.js";
8
- import { pictureAddress, readMap, readView, readWorld } from "../api.js";
9
- import { fromLabel, terrainLabel } from "../game-words.js";
10
- import { Glass, GlassDefs } from "../glass.js";
11
- import { Icon } from "../icons.js";
12
- import { biomeLabel, biomes, placeKindLabel, placeKinds, symbolRadius } from "../map-symbols.js";
13
- import { plainLine } from "../markdown.js";
8
+ import { readMap, readWorld } from "../api.js";
14
9
  import { WidgetCards } from "../packages/widgets.js";
15
- import { PageHead } from "../pages.js";
16
- import { PageTabs } from "../tabs.js";
10
+ import { biomeLabel } from "../parts/map-symbols.js";
11
+ import { PageHead } from "../shell/pages.js";
12
+ import { PageTabs } from "../shell/tabs.js";
17
13
  import { t } from "../text.js";
18
14
  import { CalendarTab } from "./calendar.js";
15
+ import { wayLabel } from "./key.js";
19
16
  import { DocumentsTab, LoreTab } from "./lore.js";
20
- import { clampScale, fading, fitView, hexCorners, hexesOf, lengthText, liftedOf, mapLayout, mapNameOf, mapPart, marksOf, nameRun, nameShares, pathOf, placeAreaLabels, placeLabels, regionEdges, riverOutline, scaleBar, trailCourse, waterOf, wayShapes, waysOf, zoomedView, } from "./map.js";
21
- // How wide the map shows around the party at first on a phone, in km; how much a step of the zoom and of the keys moves.
22
- const phoneSpan = 46;
23
- const zoomStep = 1.5;
24
- const keyStep = 60;
25
- // How far a pointer moves before a press is a drag, not a click, in pixels.
26
- const dragFrom = 4;
27
- // The ways in the order they are drawn, the rivers under the roads.
28
- const wayOrder = ["river", "road", "path"];
17
+ import { MapCard } from "./map-card.js";
18
+ import { mapLayout, mapNameOf, mapPart } from "./map.js";
19
+ import { PlacesList } from "./places.js";
29
20
  // The section's tabs, the map's first: its address is the section's own.
30
21
  const worldTabs = ["map", "lore", "documents", "calendar"];
31
22
  /**
@@ -119,332 +110,9 @@ function MapTab({ map, problem, lead, place, readMore }) {
119
110
  };
120
111
  return (_jsxs("div", { class: "world-map", children: [_jsx(MapCard, { map: drawn, full: map, part: part, layout: layout, lead: lead, chosen: chosen, focus: focus, onChoose: choose, onGo: goTo, readMore: readMore }, part.name), _jsx(PlacesList, { map: drawn, full: map, layout: layout, onChoose: choose })] }));
121
112
  }
122
- /**
123
- * The map's card: its head, with the maps the character knows as tabs; the map with its tools and the card of the chosen place; the key under it. `map` is what
124
- * the current map draws, `full` the whole world map, for the ways that lead to other maps.
125
- */
126
- /** A biome's own picture, as the map draws its land: a tile in its colour with its mark, or the bare land for one the page does not know. */
127
- export function BiomeSwatch({ look }) {
128
- return (_jsxs("svg", { class: "key-swatch", viewBox: "0 0 22 16", "aria-hidden": "true", children: [_jsx("rect", { class: `hex lit ${look}`, x: 1, y: 1, width: 20, height: 14, rx: 3 }), biomes[look] !== undefined && _jsx("path", { class: `tuft ${look}`, transform: "translate(11 9)", d: biomes[look].mark })] }));
129
- }
130
- function MapCard({ map, full, part, layout, lead, chosen, focus, onChoose, onGo, readMore }) {
131
- const box = useRef(null);
132
- const [size, setSize] = useState();
133
- const [view, setView] = useState();
134
- // The ways drawn by hand and the trail along them, once for each map: the same at every drawing.
135
- const ways = useMemo(() => wayShapes(map), [map]);
136
- const trails = useMemo(() => part.trails.map((run) => trailCourse(run, ways, waterOf(map))), [part, ways, map]);
137
- const lifted = useMemo(() => liftedOf(map, layout, ways, trails), [map, layout, ways, trails]);
138
- // Under a map aligned with another, the other one as a ghost: its ways and its places, faint (D-320).
139
- const ghost = useMemo(() => {
140
- if (part.ghost === undefined) {
141
- return undefined;
142
- }
143
- const { places, roads } = part.ghost;
144
- return { ways: wayShapes({ ...full, places, roads }), spots: places.filter((place) => place.x !== undefined && place.y !== undefined && place.radius === undefined) };
145
- }, [part, full]);
146
- const pointers = useRef(new Map());
147
- const drag = useRef(undefined);
148
- const narrow = size !== undefined && size.width < 600;
149
- // The map's size, as the window changes it.
150
- useEffect(() => {
151
- const element = box.current;
152
- if (element === null) {
153
- return;
154
- }
155
- const observer = new ResizeObserver(() => setSize({ width: element.clientWidth, height: element.clientHeight }));
156
- observer.observe(element);
157
- return () => observer.disconnect();
158
- }, []);
159
- // The first view: all the character knows; on a phone, the land around the party; with a place already chosen, as from the Lore's Show on the map, that place.
160
- useEffect(() => {
161
- if (size !== undefined && view === undefined) {
162
- const spot = shownPoint(map, layout, focus.name);
163
- const start = startView(map, lifted, size);
164
- setView(spot === undefined ? start : roomFor(spot, start, size, size.width < 600));
165
- }
166
- }, [size]);
167
- // A place chosen: the map brings it where the card leaves room, right of it on a wide screen, above it on a phone.
168
- useEffect(() => {
169
- const spot = shownPoint(map, layout, focus.name);
170
- if (spot !== undefined && size !== undefined && view !== undefined) {
171
- setView(roomFor(spot, view, size, narrow));
172
- }
173
- }, [focus.count]);
174
- // The wheel zooms around the pointer; the page does not scroll under it.
175
- useEffect(() => {
176
- const element = box.current;
177
- if (element === null || size === undefined) {
178
- return;
179
- }
180
- const wheel = (event) => {
181
- event.preventDefault();
182
- const bounds = element.getBoundingClientRect();
183
- setView((before) => before === undefined ? before : zoomedView(before, event.deltaY < 0 ? 1.2 : 1 / 1.2, { x: event.clientX - bounds.left, y: event.clientY - bounds.top }, size.width, size.height));
184
- };
185
- element.addEventListener("wheel", wheel, { passive: false });
186
- return () => element.removeEventListener("wheel", wheel);
187
- }, [size]);
188
- const zoom = (factor) => {
189
- if (size !== undefined) {
190
- setView((before) => before === undefined ? before : zoomedView(before, factor, { x: size.width / 2, y: size.height / 2 }, size.width, size.height));
191
- }
192
- };
193
- // One pointer moves the map, two pinch it: mouse, pen and touch alike. A press that hardly moves is a click.
194
- const begin = (moved) => {
195
- const points = [...pointers.current.values()];
196
- const centre = middleOf(points);
197
- drag.current = view === undefined ? undefined : { view, ...centre, spread: spreadOf(points), moved };
198
- };
199
- const onPointerDown = (event) => {
200
- pointers.current.set(event.pointerId, { x: event.clientX, y: event.clientY });
201
- begin(false);
202
- };
203
- const onPointerMove = (event) => {
204
- const start = drag.current;
205
- if (start === undefined || !pointers.current.has(event.pointerId)) {
206
- return;
207
- }
208
- pointers.current.set(event.pointerId, { x: event.clientX, y: event.clientY });
209
- const points = [...pointers.current.values()];
210
- const centre = middleOf(points);
211
- const spread = spreadOf(points);
212
- if (!start.moved && Math.hypot(centre.x - start.x, centre.y - start.y) < dragFrom && points.length === 1) {
213
- return;
214
- }
215
- if (!start.moved) {
216
- event.currentTarget.setPointerCapture(event.pointerId);
217
- start.moved = true;
218
- }
219
- const s = start.spread > 0 && spread > 0 ? clampScale(start.view.s * spread / start.spread) : start.view.s;
220
- setView({ s, x: start.view.x - (centre.x - start.x) / s, y: start.view.y + (centre.y - start.y) / s });
221
- };
222
- const onPointerUp = (event) => {
223
- pointers.current.delete(event.pointerId);
224
- const moved = drag.current?.moved === true;
225
- if (pointers.current.size > 0) {
226
- begin(moved);
227
- }
228
- else if (!moved) {
229
- // A click on a place opens its card; on the land, it closes it.
230
- const name = event.target.closest("[data-place]")?.dataset.place;
231
- onChoose(name);
232
- drag.current = undefined;
233
- }
234
- else {
235
- drag.current = undefined;
236
- }
237
- };
238
- const onKeyDown = (event) => {
239
- // Escape closes the card from anywhere in the map, and the map takes the keys again.
240
- if (event.key === "Escape" && chosen !== undefined) {
241
- onChoose(undefined);
242
- box.current?.focus();
243
- return;
244
- }
245
- if (event.target !== box.current || view === undefined) {
246
- return;
247
- }
248
- const step = keyStep / view.s;
249
- const moves = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, step], ArrowDown: [0, -step] };
250
- const move = moves[event.key];
251
- if (move !== undefined) {
252
- event.preventDefault();
253
- setView({ ...view, x: view.x + move[0], y: view.y + move[1] });
254
- }
255
- else if (event.key === "+" || event.key === "=") {
256
- zoom(zoomStep);
257
- }
258
- else if (event.key === "-") {
259
- zoom(1 / zoomStep);
260
- }
261
- };
262
- const spot = layout.spots.find((one) => one.name === chosen);
263
- const label = layout.partySpot === undefined ? t("World map") : t("World map, your party at {place}", { place: layout.partySpot.name });
264
- const here = full.maps.find((known) => known.name === part.name);
265
- const partyMap = full.party === undefined ? undefined : mapNameOf(full, full.party);
266
- return (_jsxs("section", { class: "card map-card", "aria-labelledby": "map-title", children: [_jsxs("header", { class: "map-head", children: [_jsx("h3", { id: "map-title", children: t("Map") }), _jsx("span", { class: "map-sub", children: [
267
- layout.spots.length === 1 ? t("1 place you know") : t("{count} places you know", { count: layout.spots.length }),
268
- here?.under === undefined ? undefined : t("under {map}", { map: here.under }),
269
- here?.mirror === undefined ? undefined : t("the mirror of {map}", { map: here.mirror }),
270
- partyMap === undefined || partyMap === part.name ? undefined : t("your party is on {map}", { map: partyMap }),
271
- ].filter((text) => text !== undefined).join(" · ") }), _jsxs("button", { type: "button", class: "map-to-list", onClick: () => document.getElementById("places-title")?.scrollIntoView({ block: "start", behavior: "smooth" }), children: [_jsx(Icon, { name: "list" }), _jsx("span", { children: t("List") })] })] }), full.maps.length > 1 && (_jsx("nav", { class: "map-tabs", "aria-label": t("Maps"), children: full.maps.map((known) => (_jsxs("button", { type: "button", class: "map-tab", "aria-current": known.name === part.name ? "true" : undefined, onClick: () => onGo(known.name), children: [known.name, known.name === partyMap && _jsx("span", { class: "map-tab-party", "aria-label": t("your party is here") })] }, known.name))) })), _jsxs("div", { ref: box, class: "map", tabIndex: 0, role: "region", "aria-roledescription": "map", "aria-label": label, "aria-describedby": "map-help", onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, onKeyDown: onKeyDown, children: [size !== undefined && view !== undefined && (_jsx(Drawing, { map: map, layout: layout, ways: ways, trails: trails, lifted: lifted, ghost: ghost, passages: part.passages.map((passage) => passage.place), lead: lead, view: view, size: size, narrow: narrow, chosen: chosen })), _jsxs("div", { class: "map-tools", role: "toolbar", "aria-label": t("Map"), children: [_jsx(Tool, { name: "plus", label: t("Zoom in"), onClick: () => zoom(zoomStep) }), _jsx(Tool, { name: "minus", label: t("Zoom out"), onClick: () => zoom(1 / zoomStep) }), _jsx(Tool, { name: "locate", label: t("Your party"), onClick: () => (map.party !== undefined && view !== undefined ? setView({ ...view, x: map.party.x, y: map.party.y }) : partyMap !== undefined && onGo(partyMap)) }), _jsx(Tool, { name: "fit", label: t("All you know"), onClick: () => size !== undefined && setView(fitView(lifted, size.width, size.height)) })] }), _jsx("p", { id: "map-help", class: "visually-hidden", children: t("Arrows move the map, plus and minus zoom, Escape closes a place's card. The list of places below says the same.") }), spot !== undefined && _jsx(PlaceCard, { place: spot, map: full, layout: layout, narrow: narrow, onClose: () => onChoose(undefined), onGo: onGo, readMore: readMore(spot.name) })] }), _jsx(Key, { map: map, layout: layout, narrow: narrow, trail: trails.length > 0, passages: part.passages.length > 0 })] }));
272
- }
273
- /**
274
- * The drawing, from the view: the paper, the hexes lit and fogged with the marks of their biome and the ink round each region, the ways drawn by hand with
275
- * their tails into the fog, the trail, the places, the party, the labels, the compass and the scale.
276
- */
277
- function Drawing({ map, layout, ways, trails, lifted, ghost, passages, lead, view, size, narrow, chosen }) {
278
- const { width, height } = size;
279
- const X = (x) => width / 2 + (x - view.x) * view.s;
280
- const Y = (y) => height / 2 - (y - view.y) * view.s;
281
- const screen = (points) => points.map((point) => ({ x: X(point.x), y: Y(point.y) }));
282
- const line = (points) => pathOf(screen(points));
283
- const { across, hexes } = hexesOf(view, width, height, lifted, layout.regions);
284
- const hexPixels = across * view.s;
285
- const edges = regionEdges(hexes, across);
286
- const scale = scaleBar(view.s, map.unit);
287
- const image = lead?.image === undefined ? undefined : `/images/${encodeURIComponent(lead.image.file)}?v=${lead.image.version}`;
288
- const party = map.party;
289
- // Ink a little bolder near, finer far.
290
- const weight = Math.min(1.5, Math.max(0.7, view.s / 8));
291
- const drawn = [...ways].sort((first, second) => wayRank(first.kind) - wayRank(second.kind));
292
- // What the labels must leave free: the tools, the compass, the scale and the places' symbols; the regions' names go first, below their middle, above, across it.
293
- const reserved = [{ x: width - 64, y: 0, width: 64, height: 220 }, { x: 0, y: 0, width: 80, height: 86 }, { x: 0, y: height - 50, width: 210, height: 50 }];
294
- const markBoxes = layout.spots.map((spot) => ({ x: X(spot.x) - symbolOf(spot).r, y: Y(spot.y) - symbolOf(spot).r, width: symbolOf(spot).r * 2, height: symbolOf(spot).r * 2 }));
295
- const regionWishes = layout.regions.map((region) => ({
296
- x: X(region.x),
297
- ys: nameShares(region, hexes).map((share) => Y(region.y + region.radius * share)),
298
- width: region.name.length * 14,
299
- height: region.terrain === undefined ? 20 : 34,
300
- }));
301
- const regionLabels = placeAreaLabels(regionWishes, markBoxes, reserved, width, height);
302
- const regionBoxes = regionLabels.flatMap((placed, index) => placed === undefined ? [] : [{ x: placed.x - regionWishes[index].width / 2 - 3, y: placed.y - 15, width: regionWishes[index].width + 6, height: regionWishes[index].height }]);
303
- // A way's name along its longest run between two stops on the screen, following its bends, when the run holds it.
304
- const wayNames = drawn.map((way) => {
305
- const run = nameRun(screen(way.course), way.stops, way.name.length * 7.5 + 60);
306
- // The bends of a river or a path would scatter its name: it goes along their way instead, beside them.
307
- return run === undefined || wayLook(way.kind) === "road" ? run : [run[0], run.at(-1)];
308
- });
309
- const labels = placeLabels(layout.spots.map((spot) => {
310
- const isParty = spot === layout.partySpot;
311
- const big = isParty || (placeKinds[spot.kind ?? ""]?.size ?? 0) >= 2;
312
- return { text: spot.name, x: X(spot.x), y: Y(spot.y), r: isParty ? 19 : symbolOf(spot).r + 1, size: big ? 16 : 13.5, weight: weightOf(spot, layout) };
313
- }), markBoxes, [...reserved, ...regionBoxes], width, height);
314
- return (_jsxs("svg", { class: "map-svg", viewBox: `0 0 ${width} ${height}`, "aria-hidden": "true", children: [_jsxs("defs", { children: [_jsx(GlassDefs, { prefix: "map" }), _jsxs("filter", { id: "map-grain", x: "0", y: "0", width: "100%", height: "100%", children: [_jsx("feTurbulence", { type: "fractalNoise", baseFrequency: "0.9", numOctaves: 3, seed: 2 }), _jsx("feColorMatrix", { values: "0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.12 0 0 0 0.09 0" }), _jsx("feComposite", { in2: "SourceGraphic", operator: "in" })] }), _jsxs("filter", { id: "map-ink", x: "-5%", y: "-5%", width: "110%", height: "110%", children: [_jsx("feTurbulence", { type: "fractalNoise", baseFrequency: "0.05", numOctaves: 2, seed: 4 }), _jsx("feDisplacementMap", { in: "SourceGraphic", scale: 2.2 })] }), _jsxs("radialGradient", { id: "map-age", cx: "50%", cy: "50%", r: "72%", children: [_jsx("stop", { offset: "0.62", "stop-color": "#6e5028", "stop-opacity": "0" }), _jsx("stop", { offset: "1", "stop-color": "#6e5028", "stop-opacity": "0.3" })] }), _jsx("clipPath", { id: "map-token", children: _jsx("circle", { r: 13 }) }), wayNames.map((run, index) => run === undefined ? null : _jsx("path", { id: `world-way-name-${index}`, d: pathOf(run) }, index))] }), _jsx("rect", { class: "map-fog", width: width, height: height }), hexes.map((hex, index) => (_jsx("polygon", { class: hex.lit ? `hex lit ${biomeLook(hex.biome)}` : "hex fogged", "fill-opacity": hex.lit ? (0.8 + hex.tone * 0.2).toFixed(2) : undefined, points: hexCorners(hex, across).map((corner) => `${X(corner.x).toFixed(1)},${Y(corner.y).toFixed(1)}`).join(" ") }, index))), hexPixels >= 24 && (_jsx("g", { class: "tufts", children: hexes.filter((hex) => hex.lit && hex.biome !== undefined && biomes[hex.biome] !== undefined).flatMap((hex, index) => marksOf(hex, hexPixels).map((mark, at) => (_jsx("path", { class: `tuft ${hex.biome}`, transform: `translate(${(X(hex.x) + mark.x).toFixed(1)} ${(Y(hex.y) + mark.y).toFixed(1)}) scale(${mark.scale.toFixed(2)})`, d: biomes[hex.biome ?? ""].mark }, `${index} ${at}`)))) })), [...edges].map(([region, segments]) => (_jsx("path", { class: `region-edge ${biomeLook(layout.regions.find((one) => one.name === region)?.biome)}${region === chosen ? " selected" : ""}`, d: segments.map(([from, to]) => `M${X(from.x).toFixed(1)} ${Y(from.y).toFixed(1)}L${X(to.x).toFixed(1)} ${Y(to.y).toFixed(1)}`).join(""), filter: "url(#map-ink)" }, region))), _jsx("rect", { class: "map-grain", width: width, height: height, filter: "url(#map-grain)" }), trails.map((run, index) => _jsx("path", { class: "trail", d: line(run) }, index)), drawn.filter((way) => way.name === chosen).map((way, index) => _jsx("path", { class: "chosen-way", d: line(way.course) }, index)), ghost !== undefined && (_jsxs("g", { class: "ghost", children: [ghost.ways.map((way, index) => _jsx(WayDrawing, { way: way, look: wayLook(way.kind), screen: screen, weight: weight }, `${way.name} ${index}`)), ghost.spots.map((spot) => _jsx(PlaceSymbol, { spot: spot, x: X(spot.x), y: Y(spot.y), chosen: false }, spot.name))] })), drawn.map((way, index) => _jsx(WayDrawing, { way: way, look: wayLook(way.kind), screen: screen, weight: weight }, `${way.name} ${index}`)), drawn.map((way, index) => wayNames[index] === undefined ? null : (_jsx("text", { class: `way-label ${wayLook(way.kind)}`, dy: wayLook(way.kind) === "river" ? -16 : -6, children: _jsx("textPath", { href: `#world-way-name-${index}`, startOffset: "50%", "text-anchor": "middle", children: way.name }) }, `${way.name} ${index}`))), _jsx("rect", { class: "map-age", width: width, height: height, fill: "url(#map-age)" }), layout.spots.filter((spot) => passages.includes(spot.name)).map((spot) => _jsx("circle", { class: "passage-ring", cx: X(spot.x), cy: Y(spot.y), r: symbolOf(spot).r + 5 }, spot.name)), layout.spots.filter((spot) => spot !== layout.partySpot).map((spot) => _jsx(PlaceSymbol, { spot: spot, x: X(spot.x), y: Y(spot.y), chosen: spot.name === chosen }, spot.name)), party !== undefined && (_jsxs("g", { class: layout.partySpot !== undefined && layout.partySpot.name === chosen ? "party-mark selected" : "party-mark", transform: `translate(${X(party.x).toFixed(1)} ${Y(party.y).toFixed(1)})`, "data-place": layout.partySpot?.name, children: [_jsx("circle", { class: "party-pulse", r: 17 }), _jsxs("g", { filter: "url(#map-drop)", children: [_jsx("circle", { class: "party-ring", r: 17 }), _jsx("circle", { class: "party-disc", r: 14.5 }), image !== undefined && _jsx("image", { href: image, x: -13, y: -13, width: 26, height: 26, "clip-path": "url(#map-token)" }), _jsx(Glass, { r: 14.5, prefix: "map" })] })] })), _jsxs("g", { class: "labels", children: [layout.regions.map((region, index) => {
315
- const placed = regionLabels[index];
316
- return placed === undefined ? null : (_jsxs("g", { children: [_jsx("text", { class: "label region-label", x: placed.x, y: placed.y, "text-anchor": "middle", children: region.name }), region.terrain !== undefined && _jsx("text", { class: "label region-note", x: placed.x, y: placed.y + 15, "text-anchor": "middle", children: terrainLabel(region.terrain) })] }, region.name));
317
- }), layout.spots.map((spot, index) => {
318
- const label = labels[index];
319
- const big = spot === layout.partySpot || (placeKinds[spot.kind ?? ""]?.size ?? 0) >= 2;
320
- return label.hidden ? null : _jsx("text", { class: `label place-label${big ? " big" : ""}`, x: label.x, y: label.y, "text-anchor": label.anchor, children: label.text }, spot.name);
321
- })] }), _jsxs("g", { class: "compass", transform: `translate(${narrow ? 34 : 40} ${narrow ? 42 : 46}) scale(${narrow ? 0.85 : 1})`, children: [_jsx("circle", { class: "compass-ring", r: 15 }), _jsx("path", { class: "compass-diagonals", d: "M-12-12 12 12 M-12 12 12-12" }), _jsx("path", { class: "compass-point", d: "M0-26 5-5 26 0 5 5 0 26-5 5-26 0-5-5Z" }), _jsx("path", { class: "compass-shade", d: "M0-26 5-5 0 0Z M26 0 5 5 0 0Z M0 26-5 5 0 0Z M-26 0-5-5 0 0Z" }), _jsx("text", { class: "compass-n", y: -30, "text-anchor": "middle", children: "N" })] }), _jsxs("g", { class: "scale", transform: `translate(16 ${height - 22})`, children: [_jsx("rect", { class: "scale-back", x: -8, y: -20, width: scale.width + 64, height: 34, rx: 6 }), _jsx("rect", { class: "scale-a", width: scale.width / 2, height: 5 }), _jsx("rect", { class: "scale-b", x: scale.width / 2, width: scale.width / 2, height: 5 }), _jsx("text", { class: "scale-text", x: 0, y: -8, children: "0" }), _jsx("text", { class: "scale-text", x: scale.width, y: -8, "text-anchor": "middle", children: scale.value }), _jsx("text", { class: "scale-text", x: scale.width + 8, y: 5, children: map.unit.name === "km" ? "km" : t("miles") })] })] }));
322
- }
323
- /**
324
- * A way drawn by hand, in the map's ink: a road as two lines, a path dashed, a river in water widening toward its mouth, outlined in ink; its tails fade into
325
- * the fog.
326
- */
327
- function WayDrawing({ way, look, screen, weight }) {
328
- const course = screen(way.course);
329
- return (_jsxs("g", { class: `way-drawing ${look}`, children: [way.tails.map((tail) => fading(screen(tail.course)).map((piece, index) => (_jsx("path", { class: `tail ${look}`, d: pathOf(piece.points), "stroke-opacity": piece.opacity.toFixed(2), "stroke-width": (look === "river" ? (tail.from === "before" ? 1.6 : 4.4) : look === "road" ? 2.2 : 1.3) * weight }, `${tail.from} ${index}`)))), look === "river" && _jsx("path", { class: "river-water", d: riverOutline(course, 1.6 * weight, 4.6 * weight), filter: "url(#map-ink)" }), look === "road" && (_jsxs(_Fragment, { children: [_jsx("path", { class: "road-ink", d: pathOf(course), "stroke-width": 3.8 * weight, filter: "url(#map-ink)" }), _jsx("path", { class: "road-paper", d: pathOf(course), "stroke-width": 1.5 * weight })] })), (look === "path" || look === "other") && _jsx("path", { class: `${look}-ink`, d: pathOf(course), "stroke-width": 1.4 * weight, filter: "url(#map-ink)" })] }));
330
- }
331
- /** A place's symbol by its kind: a disc with its picture, in four sizes; a kind the page does not know, a plain dot. */
332
- function PlaceSymbol({ spot, x, y, chosen }) {
333
- const kind = spot.kind === undefined ? undefined : placeKinds[spot.kind];
334
- const { r } = symbolOf(spot);
335
- const scale = r * 1.62 / 24;
336
- return (_jsxs("g", { class: `spot size-${kind?.size ?? "dot"}${chosen ? " selected" : ""}`, transform: `translate(${x.toFixed(1)} ${y.toFixed(1)})`, "data-place": spot.name, children: [kind === undefined ? _jsx("circle", { class: "spot-dot", r: 4 }) : (_jsxs("g", { filter: "url(#map-drop)", children: [_jsx("circle", { class: "spot-disc", r: r }), _jsx("path", { class: "spot-glyph", transform: `translate(${-12 * scale} ${-12 * scale}) scale(${scale})`, d: kind.glyph }), _jsx(Glass, { r: r, prefix: "map" })] })), _jsx("circle", { class: "spot-hit", r: Math.max(r, 16) })] }));
337
- }
338
- /** The card of a place: its picture, what it is and where, its text as the character knows it, what it holds, its ways, the scene when the party is there. */
339
- function PlaceCard({ place, map, layout, narrow, onClose, onGo, readMore }) {
340
- const [text, setText] = useState();
341
- const here = place === layout.partySpot;
342
- const region = layout.regions.find((one) => place.within.includes(one.name));
343
- const inside = layout.inside(place.name);
344
- const ways = waysOf(map, place.name);
345
- const closer = useRef(null);
346
- // Its text, read when the card opens: the first lines as the character knows them.
347
- useEffect(() => {
348
- // Only this place's: an answer for the one opened before, which came late, is left.
349
- let live = true;
350
- setText(undefined);
351
- readView(place.name).then((page) => live && setText(page.kind === "page" ? plainLine(page.text) : undefined), () => live && setText(undefined));
352
- closer.current?.focus({ preventScroll: true });
353
- return () => {
354
- live = false;
355
- };
356
- }, [place.name]);
357
- const eyebrow = [placeKindLabel(place.kind) ?? t("Place"), region?.name, here || place.from?.direction === undefined ? undefined : t("{distance} from you", { distance: fromLabel(place.from, (km) => lengthText(km, map.unit)) })].filter((part) => part !== undefined);
358
- return (_jsxs("div", { class: narrow ? "place-card sheet" : "place-card", role: "dialog", "aria-labelledby": "place-card-title", onPointerDown: (event) => event.stopPropagation(), onPointerUp: (event) => event.stopPropagation(), children: [place.image !== undefined && _jsx("img", { class: "pc-image", src: pictureAddress(place.image), alt: "" }), _jsx("button", { ref: closer, type: "button", class: "pc-close icon-button", "aria-label": t("Close"), onClick: onClose, children: _jsx(Icon, { name: "close" }) }), _jsxs("div", { class: "pc-body", children: [_jsx("p", { class: "eyebrow pc-eyebrow", children: eyebrow.join(" · ") }), _jsx("h3", { id: "place-card-title", children: place.name }), here && (_jsxs("p", { class: "pc-here", children: [_jsx("span", { class: "here-dot", "aria-hidden": "true" }), t("Your party is here")] })), text !== undefined && _jsx("p", { class: "pc-text", children: text }), readMore !== undefined && _jsx("a", { class: "pc-more md-link", href: readMore, children: t("Read all you know") }), inside.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h4", { class: "eyebrow pc-sub", children: t("Inside") }), _jsx("ul", { class: "in-chips", children: inside.flatMap((child) => [
359
- _jsx("li", { class: "in-chip", children: child.name }, child.name),
360
- ...layout.inside(child.name).map((grandchild) => (_jsxs("li", { class: "in-chip", children: [_jsx("span", { class: "in-path", children: "\u203A" }), " ", grandchild.name] }, grandchild.name))),
361
- ]) })] })), ways.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h4", { class: "eyebrow pc-sub", children: t("Ways") }), _jsx("ul", { class: "pc-ways", children: ways.map((way, index) => (_jsxs("li", { children: [_jsx(Icon, { name: wayIcon(way.kind) }), _jsxs("span", { children: [_jsx("b", { children: way.road }), ` ${t("to")} `, way.map === undefined || way.to === undefined ? way.to ?? t("somewhere you do not know") : (_jsx("button", { type: "button", class: "way-to-map", onClick: () => onGo(way.map, way.to), children: t("{place}, on {map}", { place: way.to, map: way.map }) })), way.km !== undefined && " · ", way.km !== undefined && _jsx("span", { class: "way-km num", children: lengthText(way.km, map.unit) })] })] }, index))) })] })), here && (_jsxs("a", { class: "pc-scene", href: sectionAddress("scene"), children: [_jsx(Icon, { name: "scene" }), _jsx("span", { children: t("Scene") })] }))] })] }));
362
- }
363
- /** The key under the map: the ways, the trail and the party; the land's biomes, difficult terrain and the fog; the kinds of place on this map. */
364
- function Key({ map, layout, narrow, trail, passages }) {
365
- // A passage is no line on the map: its ring says it (ROA-8).
366
- const ways = [...new Set(map.roads.filter((road) => road.kind !== "portal").map((road) => wayLook(road.kind)))].sort((first, second) => wayRank(first) - wayRank(second));
367
- const lands = [...new Set(layout.regions.map((region) => biomeLook(region.biome)))].filter((look) => look !== "open");
368
- const kinds = [...new Set(layout.spots.map((spot) => (spot.kind !== undefined && placeKinds[spot.kind] !== undefined ? spot.kind : "other")))];
369
- return (_jsxs("details", { class: "map-key", open: !narrow, children: [_jsx("summary", { children: t("Key") }), _jsxs("div", { class: "key-groups", children: [_jsxs("div", { class: "key-group", children: [_jsx("h4", { class: "eyebrow key-title", children: t("Ways") }), _jsxs("ul", { children: [ways.map((look) => (_jsxs("li", { children: [_jsxs("svg", { class: "key-way", viewBox: "0 0 30 16", "aria-hidden": "true", children: [look === "river" && _jsx("path", { class: "river-water", d: "M2 9.6Q8 5.8 15 8.2T28 6.6L28 9.6Q22 12 15 10.4T2 10.8Z" }), look === "road" && (_jsxs(_Fragment, { children: [_jsx("path", { class: "road-ink", d: "M2 9q7-4 13-1t13-1", "stroke-width": 3.8 }), _jsx("path", { class: "road-paper", d: "M2 9q7-4 13-1t13-1", "stroke-width": 1.5 })] })), (look === "path" || look === "other") && _jsx("path", { class: `${look}-ink`, d: "M2 9q7-4 13-1t13-1", "stroke-width": 1.4 })] }), wayLabel(look)] }, look))), trail && (_jsxs("li", { children: [_jsx("svg", { class: "key-way", viewBox: "0 0 30 16", "aria-hidden": "true", children: _jsx("path", { class: "trail", d: "M4 8h22" }) }), t("Your trail")] })), _jsxs("li", { children: [_jsxs("svg", { class: "key-symbol", viewBox: "-9 -9 18 18", "aria-hidden": "true", children: [_jsx("circle", { class: "party-ring", r: 7.5 }), _jsx("circle", { class: "party-disc", r: 5.5 })] }), t("Your party")] }), passages && (_jsxs("li", { children: [_jsx("svg", { class: "key-symbol", viewBox: "-12 -12 24 24", "aria-hidden": "true", children: _jsx("circle", { class: "passage-ring", r: 9 }) }), t("Passage to another map")] }))] })] }), _jsxs("div", { class: "key-group", children: [_jsx("h4", { class: "eyebrow key-title", children: t("Land") }), _jsxs("ul", { children: [lands.map((look) => (_jsxs("li", { children: [_jsx(BiomeSwatch, { look: look }), biomeLabel(look) ?? t("Other land")] }, look))), _jsxs("li", { children: [_jsx("svg", { class: "key-swatch", viewBox: "0 0 22 16", "aria-hidden": "true", children: _jsx("rect", { class: "hex fogged", x: 1, y: 1, width: 20, height: 14, rx: 3 }) }), t("Not found yet")] })] })] }), _jsxs("div", { class: "key-group", children: [_jsx("h4", { class: "eyebrow key-title", children: t("Places") }), _jsx("ul", { children: kinds.map((kind) => (_jsxs("li", { children: [_jsx("svg", { class: "key-symbol", viewBox: "-17 -17 34 34", "aria-hidden": "true", children: _jsx(PlaceSymbol, { spot: { name: kind, x: 0, y: 0, within: [], ...(kind === "other" ? {} : { kind }) }, x: 0, y: 0, chosen: false }) }), placeKindLabel(kind) ?? t("Other place")] }, kind))) })] })] })] }));
370
- }
371
- /** The map's twin: every place the character knows, nearest the party first, with how far and which way; then the regions and the ways. */
372
- function PlacesList({ map, full, layout, onChoose }) {
373
- const choose = (name) => {
374
- onChoose(name);
375
- document.querySelector(".map")?.scrollIntoView({ block: "nearest", behavior: "smooth" });
376
- };
377
- return (_jsxs("section", { class: "card map-list", "aria-labelledby": "places-title", children: [_jsxs("header", { class: "map-head", children: [_jsx("h3", { id: "places-title", children: t("Places you know") }), _jsx("span", { class: "map-sub", children: map.party === undefined ? t("on the map") : t("from your party, as the crow flies") })] }), _jsx("ol", { class: "places", children: layout.spots.map((spot) => (_jsx("li", { children: _jsxs("button", { type: "button", class: "place-row", onClick: () => choose(spot.name), children: [_jsx("span", { class: "pr-name", children: spot.name }), _jsx("span", { class: "pr-kind", children: [placeKindLabel(spot.kind) ?? t("Place"), ...(layout.inside(spot.name).length > 0 ? [t("{count} inside", { count: layout.inside(spot.name).length })] : [])].join(" · ") }), _jsx("span", { class: "pr-far num", dir: "auto", children: spot.from === undefined ? "" : fromLabel(spot.from, (km) => lengthText(km, map.unit)) })] }) }, spot.name))) }), (layout.regions.length > 0 || map.roads.length > 0) && _jsx("h4", { class: "eyebrow pc-sub", children: t("Regions and ways") }), _jsxs("ul", { class: "places", children: [layout.regions.map((region) => _jsx(RegionRow, { region: region, unit: map.unit }, region.name)), waysListed(map.roads, full.roads).map((road) => (_jsx("li", { children: _jsxs("span", { class: "place-row static", children: [_jsx("span", { class: "pr-name", children: road.name }), _jsx("span", { class: "pr-kind", children: wayLabel(road.kind) }), _jsx("span", { class: "pr-far num", children: lengthText(road.km, map.unit) })] }) }, road.name)))] })] }));
378
- }
379
- function RegionRow({ region, unit }) {
380
- return (_jsx("li", { children: _jsxs("span", { class: "place-row static", children: [_jsx("span", { class: "pr-name", children: region.name }), _jsxs("span", { class: "pr-kind", children: [region.biome !== undefined && biomes[region.biome] !== undefined && _jsx(BiomeSwatch, { look: region.biome }), [t("Region"), biomeLabel(region.biome), region.terrain === undefined ? undefined : terrainLabel(region.terrain)].filter((part) => part !== undefined).join(" · ")] }), _jsx("span", { class: "pr-far num", dir: "auto", children: t("{length} across", { length: lengthText(region.radius * 2, unit) }) })] }) }));
381
- }
382
- function Tool({ name, label, onClick }) {
383
- return (_jsx("button", { type: "button", class: "map-tool", "aria-label": label, "data-tip": label, onClick: onClick, onPointerDown: (event) => event.stopPropagation(), onPointerUp: (event) => event.stopPropagation(), children: _jsx(Icon, { name: name }) }));
384
- }
385
- /** The view at first: all the character knows; on a phone, the land around the party. */
386
- function startView(map, lifted, size) {
387
- return size.width < 600 && map.party !== undefined ? { x: map.party.x, y: map.party.y, s: clampScale(size.width / phoneSpan) } : fitView(lifted, size.width, size.height);
388
- }
389
- /** The view that brings a place where the card leaves room: right of it on a wide screen, in the upper part on a phone. */
390
- function roomFor(spot, view, size, narrow) {
391
- const freeX = narrow ? size.width / 2 : (340 + size.width - 60) / 2;
392
- const freeY = narrow ? size.height * 0.2 : size.height / 2;
393
- return { ...view, x: spot.x - (freeX - size.width / 2) / view.s, y: spot.y - (size.height / 2 - freeY) / view.s };
394
- }
395
- function symbolOf(spot) {
396
- const kind = spot.kind === undefined ? undefined : placeKinds[spot.kind];
397
- return { r: kind === undefined ? 5 : symbolRadius[kind.size] };
398
- }
399
- /** How much a place's name weighs for its room: the party's place, then the larger kinds, then those holding more. */
400
- function weightOf(spot, layout) {
401
- return (spot === layout.partySpot ? 100 : 0) + (placeKinds[spot.kind ?? ""]?.size ?? -1) * 20 + layout.inside(spot.name).length * 5;
402
- }
403
- /** The look of a biome: its own when the page draws it, the bare land for none, another for one it does not know. */
404
- function biomeLook(biome) {
405
- return biome === undefined ? "open" : biomes[biome] !== undefined ? biome : "unknown-biome";
406
- }
407
- function wayLook(kind) {
408
- return wayOrder.includes(kind) ? kind : "other";
409
- }
410
- function wayRank(kind) {
411
- const rank = wayOrder.indexOf(wayLook(kind));
412
- return rank < 0 ? wayOrder.length : rank;
413
- }
414
- function wayIcon(kind) {
415
- return kind === "river" ? "river" : kind === "path" ? "path" : "road";
416
- }
417
- function middleOf(points) {
418
- return { x: points.reduce((sum, point) => sum + point.x, 0) / points.length, y: points.reduce((sum, point) => sum + point.y, 0) / points.length };
419
- }
420
- function spreadOf(points) {
421
- return points.length > 1 ? Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y) : 0;
422
- }
423
- /** A kind of way by its name in the page's language: River, Road, Path. */
424
- function wayLabel(kind) {
425
- const labels = { river: t("River"), road: t("Road"), path: t("Path"), portal: t("Portal"), other: t("Other way") };
426
- return labels[kind] ?? `${kind[0]?.toUpperCase() ?? ""}${kind.slice(1)}`;
427
- }
428
- /**
429
- * The ways of a map as its list names them: each once, with its whole length, on this map and the others it leads to, its pieces together; a portal, which
430
- * has none, left out.
431
- */
432
- function waysListed(roads, whole) {
433
- const names = [...new Set(roads.filter((road) => road.kind !== "portal").map((road) => road.name))];
434
- return names.map((name) => {
435
- const pieces = whole.filter((road) => road.name === name);
436
- const km = pieces.reduce((sum, road) => sum + road.points.slice(1).reduce((length, point) => length + point.km, 0), 0);
437
- return { name, kind: pieces[0]?.kind ?? "other", km };
438
- });
439
- }
440
113
  /** The map that draws a name: a place's or a region's own, the middle of a way's; none for a name it does not draw. */
441
114
  function mapHolding(map, name) {
442
115
  const points = map.roads.find((road) => road.name === name)?.points;
443
116
  const point = map.places.find((one) => one.name === name && one.x !== undefined) ?? points?.[Math.floor(points.length / 2)];
444
117
  return point === undefined ? undefined : mapNameOf(map, point);
445
118
  }
446
- /** Where the map brings a name chosen: a place, the middle of a region, or the middle of a way; none for a name it does not draw. */
447
- function shownPoint(map, layout, name) {
448
- const points = map.roads.find((road) => road.name === name)?.points;
449
- return layout.spots.find((one) => one.name === name) ?? layout.regions.find((one) => one.name === name) ?? points?.[Math.floor((points?.length ?? 0) / 2)];
450
- }
@@ -1,5 +1,5 @@
1
1
  import { type InstructionPart } from "../core/instruction-parts.ts";
2
- import { type DeclaredWidget, type FigureSize } from "../core/package-declarations.ts";
2
+ import { type DeclaredWidget, type FigureSize } from "../core/packages/declarations.ts";
3
3
  /** The file that makes a folder an extension of rpg-engine (D-427). */
4
4
  export declare const extensionFileName = "extension.yaml";
5
5
  /** What an extension may add to the campaign's game system in extension.yaml, written as campaign.yaml writes it (CAM-2, D-505). */
@@ -3,7 +3,7 @@ import { join, resolve } from "node:path";
3
3
  import { z } from "zod";
4
4
  import { installedFromFolder, packageFoldersIn, realPath } from "../core/files.js";
5
5
  import { readParts } from "../core/instruction-parts.js";
6
- import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
6
+ import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/packages/declarations.js";
7
7
  import { files, isInside } from "../core/store.js";
8
8
  import { comparableText, wordCount } from "../core/text.js";
9
9
  import { readYamlValues } from "../core/yaml-file.js";
@@ -9,20 +9,21 @@ export const largestImage = 5 * 1024 * 1024;
9
9
  export const imageExtensions = ["png", "jpg", "webp", "svg"];
10
10
  /** Reads the picture at `path`, by what its bytes are rather than by its extension: PNG, JPEG, WebP or SVG, up to largestImage. */
11
11
  export function readImage(path) {
12
- // Its size first, from the disk: a file of gigabytes is never read to be refused.
12
+ // Its size and its first bytes, from the disk: a file of gigabytes is never read whole to be refused.
13
13
  const size = files().size(path);
14
- if (size !== undefined && size > largestImage) {
15
- return { problem: `${basename(path)} is ${megabytes(size)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).` };
16
- }
17
- const bytes = size === undefined ? undefined : files().bytes(path);
18
- if (bytes === undefined) {
14
+ const head = size === undefined ? undefined : files().bytes(path, formatBytes);
15
+ if (head === undefined) {
19
16
  return { problem: `There is no file at ${path}: give the full path of the picture.` };
20
17
  }
21
- const extension = imageExtensions.find((candidate) => isFormat[candidate](bytes));
18
+ const extension = imageExtensions.find((candidate) => isFormat[candidate](head));
22
19
  if (extension === undefined) {
23
20
  return { problem: `${basename(path)} is not a PNG, JPEG, WebP or SVG picture: convert it to one of those, or give another file.` };
24
21
  }
25
- return { bytes, extension };
22
+ if (size !== undefined && size > largestImage) {
23
+ return { problem: `${basename(path)} is ${megabytes(size)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).` };
24
+ }
25
+ const bytes = files().bytes(path);
26
+ return bytes === undefined ? { problem: `There is no file at ${path}: give the full path of the picture.` } : { bytes, extension };
26
27
  }
27
28
  /** The file named `name` in the images folder of the first of `folders` that has one, looked for in the folders inside it too; undefined when none has it. */
28
29
  export function findImage(folders, name) {
@@ -58,12 +59,14 @@ export function findHiddenImage(folders, name) {
58
59
  export function imageLink(fileName) {
59
60
  return `[[${fileName}]]`;
60
61
  }
62
+ // How much of a file tells its format: an SVG's root element may come after a declaration and comments.
63
+ const formatBytes = 4096;
61
64
  const isFormat = {
62
65
  png: (bytes) => startsWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
63
66
  jpg: (bytes) => startsWith(bytes, [0xff, 0xd8, 0xff]),
64
67
  webp: (bytes) => ascii(bytes, 0, 4) === "RIFF" && ascii(bytes, 8, 12) === "WEBP",
65
68
  // An SVG is text: its root element comes after an XML declaration, a doctype or comments, if any.
66
- svg: (bytes) => /^(?:\uFEFF)?\s*(?:<\?xml[^>]*>\s*)?(?:(?:<!--[\s\S]*?-->|<!DOCTYPE[^>]*>)\s*)*<svg[\s>]/i.test(new TextDecoder().decode(bytes.subarray(0, 4096))),
69
+ svg: (bytes) => /^(?:\uFEFF)?\s*(?:<\?xml[^>]*>\s*)?(?:(?:<!--[\s\S]*?-->|<!DOCTYPE[^>]*>)\s*)*<svg[\s>]/i.test(new TextDecoder().decode(bytes.subarray(0, formatBytes))),
67
70
  };
68
71
  function startsWith(bytes, prefix) {
69
72
  return prefix.every((byte, index) => bytes[index] === byte);
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { getVersion } from "./core/version.ts";
2
- export type { Asked, AskedRoll, Asking, AskingQuestion, ButtonWords, CalendarDay, CardTint, CounterChange, DieTone, Game, GameMoment, GamePage, GameView, PackageCode, PackageCommand, PackageEntry, PackageKit, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./core/package-api.ts";
2
+ export type { Asked, AskedRoll, Asking, AskingQuestion, ButtonWords, CalendarDay, CardTint, CounterChange, DieTone, Game, GameMoment, GamePage, GameView, PackageCode, PackageCommand, PackageEntry, PackageKit, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./core/packages/api.ts";
@@ -1 +1 @@
1
- export { installedLanguages, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.ts";
1
+ export { installedLanguages, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.ts";
@@ -1,3 +1,3 @@
1
1
  // Languages as packages (D-485 (3)): a translation made by hand of the dashboard's phrases, its Guide and a game system's words, which comes before the
2
2
  // translation on the fly. Depends on nothing else in rpg-engine but the core.
3
- export { installedLanguages, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.js";
3
+ export { installedLanguages, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.js";
@@ -3,7 +3,7 @@ import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, re
3
3
  import { tmpdir } from "node:os";
4
4
  import { isAbsolute, join, resolve } from "node:path";
5
5
  import { ourScope } from "../core/consents.js";
6
- import { packageApi, readsApi } from "../core/package-declarations.js";
6
+ import { packageApi, readsApi } from "../core/packages/declarations.js";
7
7
  import { Refusal } from "../core/refusal.js";
8
8
  import { isNewerVersion } from "../core/version.js";
9
9
  import { isTarball, tarballText, unpackTarball } from "./tarball.js";
package/dist/page.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ComponentChildren, ComponentType, JSX } from "preact";
2
- import type { CardPage, DieTone, FigureSize, Track, WidgetText, WidgetValue } from "./core/package-api.ts";
3
- export { type CardPage, cardPages, type DieTone, type FigureSize, type Track, type WidgetText, type WidgetValue } from "./core/package-api.ts";
2
+ import type { CardPage, DieTone, FigureSize, Track, WidgetText, WidgetValue } from "./core/packages/api.ts";
3
+ export { type CardPage, cardPages, type DieTone, type FigureSize, type Track, type WidgetText, type WidgetValue } from "./core/packages/api.ts";
4
4
  /** Where a figure is drawn: a chip in the top, a card beside the rolls, a card in a page, a roll's card, or the panel on someone of the party (D-516). */
5
5
  export type FigurePlace = "top" | "side" | "page" | "ask" | "person";
6
6
  /** The part a figure draws in place of the dashboard's own, its words translated: what the dashboard says of it to a screen reader. */
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- export { cardPages } from "./core/package-api.js";
1
+ export { cardPages } from "./core/packages/api.js";
@@ -57,6 +57,7 @@ function worldProblems(world) {
57
57
  ...world.problems.map((message) => ({ message })),
58
58
  ...[...pagesByName.values()].filter((pages) => pages.length > 1).map(repeatedPageProblem),
59
59
  ...world.pages.flatMap((page) => hidingProblems(world, page)),
60
+ ...layerProblems(world),
60
61
  ...world.pages.flatMap((page) => [
61
62
  ...pageAlone.fields(page),
62
63
  ...linkProblems(world, pagesByName, page),
@@ -71,6 +72,23 @@ function worldProblems(world) {
71
72
  ]),
72
73
  ];
73
74
  }
75
+ /**
76
+ * The campaign's layers that do nothing (SYS-11): one over no page of the system, as after a change of the rules' version or of the page's name, and the fields
77
+ * written by hand in one that a layer cannot change, which the page reads from the system all the same.
78
+ */
79
+ function layerProblems(world) {
80
+ const stray = (world.strayLayers ?? []).map((path) => ({
81
+ path,
82
+ message: `This layer lies over no page of the system ${world.system?.name ?? ""}, which has no page at that path in the rules the campaign plays: it changes nothing.`,
83
+ fix: "move it to the path of the page it is for, as the system's world/ folder has it, or remove it if that page is no more",
84
+ }));
85
+ const ignored = (world.system?.pages ?? []).filter((page) => (page.layer?.ignored.length ?? 0) > 0).map((page) => ({
86
+ path: page.layer?.path,
87
+ message: `The layer over ${page.name} writes ${page.layer?.ignored.join(", ") ?? ""}, which a layer cannot change: the name, the type, a field no page inherits (INH-8), or uses on an item that is a kind (STK-1).`,
88
+ fix: `remove ${page.layer?.ignored.length === 1 ? "it" : "them"} from the layer by hand; for one thing of its own, write a page of the campaign that derives from ${page.name}`,
89
+ }));
90
+ return [...stray, ...ignored];
91
+ }
74
92
  /** A check that reads the page alone, made once for each page: a page never changes, and a session keeps those whose files do not (D-194). */
75
93
  function onceForEachPage(check) {
76
94
  const done = new WeakMap();
@@ -142,7 +160,7 @@ function repeatedFieldProblems(page) {
142
160
  function linkProblems(world, pagesByName, page) {
143
161
  const inFields = Object.entries(page.fields).flatMap(([field, value]) => textsIn(value).flatMap((entry) => links(entry).map((link) => ({ link, field, entry, inList: Array.isArray(value) }))));
144
162
  const inText = links(page.body).map((link) => ({ link, field: undefined, entry: undefined, inList: false }));
145
- const stackOfAlias = (entry, field) => entry !== undefined && field === containerFieldOf(page.type) && readEntry(entry).shape === "stack" && entryPage(world, links(entry)[0]?.page ?? "") === undefined
163
+ const stackOfAlias = (entry, field) => entry !== undefined && field === containerFieldOf(page.type) && ["stack", "link"].includes(readEntry(entry).shape) && entryPage(world, links(entry)[0]?.page ?? "") === undefined
146
164
  && goodsNamed(world, links(entry)[0]?.page ?? "") !== undefined;
147
165
  return [...inFields.filter((found) => !stackOfAlias(found.entry, found.field)), ...inText].flatMap((found) => {
148
166
  const broken = brokenLink(world, pagesByName, found.link);
@@ -315,6 +333,10 @@ function stackProblems(world, holder) {
315
333
  if (read.shape === "stack" && page === undefined && goodsNamed(world, read.page) !== undefined) {
316
334
  return [{ path: holder.path, message: `${holder.name} counts [[${read.page}]] in ${field}, which counts nothing: ${missingKindMessage(world, holder, field, read)}`, fix: remove(entry) + ", then the stack above" }];
317
335
  }
336
+ if (read.shape === "link" && page === undefined && goodsNamed(world, read.page) !== undefined) {
337
+ const message = missingKindMessage(world, holder, field, { page: read.page, count: 1 });
338
+ return [{ path: holder.path, message: `${holder.name} lists [[${read.page}]] in ${field}, which puts nothing there: ${message}`, fix: remove(entry) + ", then the stack above" }];
339
+ }
318
340
  if (read.shape === "stack" && page !== undefined && !isKind(world, page)) {
319
341
  const reason = notKindReason(world, page) ?? `${page.name} is one thing with a story of its own`;
320
342
  return [{ path: holder.path, message: `${holder.name} counts ${page.name} in ${field}, but it is no kind to count: ${reason}.`, fix: `${remove(entry)}, and give ${holder.name} the thing itself with move` }];
@@ -1,4 +1,4 @@
1
- import type { PageType } from "./page-types.ts";
1
+ import type { PageType } from "./types.ts";
2
2
  import { type Page, type World } from "./world.ts";
3
3
  /** A stack to set in a container's list (STK-3): the kind's name, its new count, 0 to take it away, and its label. */
4
4
  export interface StackCount {
@@ -2,8 +2,8 @@
2
2
  import { join } from "node:path";
3
3
  import { files } from "../core/store.js";
4
4
  import { comparableText, withArticle } from "../core/text.js";
5
+ import { changeFields, joinPageFile, readFields, splitPageFile } from "./file.js";
5
6
  import { links } from "./markdown.js";
6
- import { changeFields, joinPageFile, readFields, splitPageFile } from "./page-file.js";
7
7
  import { countOf, doubledKinds, entryOfKind, stackEntry, withStackCount } from "./stacks/entry.js";
8
8
  import { notKindReason } from "./stacks/kinds.js";
9
9
  import { canHold, containerFieldOf, isEmptyField } from "./standard-fields.js";
@@ -1,12 +1,12 @@
1
1
  export { checkWorld, equippedNotes, goodsFieldProblems } from "./check.ts";
2
2
  export { applyMove, type MovePlan, MoveStopped, planLeave, planMove, type StackCount } from "./containers.ts";
3
3
  export { changedEnvironment, environmentAt, type EnvironmentEntry, formatEnvironmentEntry, placesAround, readEnvironment } from "./environment.ts";
4
+ export { changedFields, type FieldChange, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./file.ts";
4
5
  export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, type Inherited, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.ts";
6
+ export { layeredPage, layeredPages, layerFolder, type LayerMark, layerParts, layersFolderName, layerTakes, systemOriginal } from "./layers.ts";
5
7
  export { carriedWeight, type LoadRule, weightUnit } from "./load.ts";
6
8
  export { type MapField, mapKey, mapOf, mapProblems, type PlaceMap, readMapField, sameFrame } from "./maps.ts";
7
9
  export { everyGoalTicked, firstTable, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, withLinksAsWords, withoutComments, withoutFencedBlocks, withoutUnreadSecrets, } from "./markdown.ts";
8
- export { changedFields, type FieldChange, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.ts";
9
- export { type PageType, pageTypeNames, worldFolderName } from "./page-types.ts";
10
10
  export { formatPosition, type Position, readPosition } from "./positions.ts";
11
11
  export { applyRename, planRename, type Renamed, renamedLinks, type RenamePlan } from "./rename-page.ts";
12
12
  export { readStops, type Stops } from "./roads.ts";
@@ -14,5 +14,7 @@ export { countedText, entryOfKind, type EntryReading, readEntry, withStackCount
14
14
  export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, type HeldStack, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, type Stack, stackName, stacksOf } from "./stacks/kinds.ts";
15
15
  export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.ts";
16
16
  export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.ts";
17
+ export { type PageType, pageTypeNames, worldFolderName } from "./types.ts";
17
18
  export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, versionTranslations, withPage, type World, } from "./world.ts";
19
+ export { type LayerWrite, removeLayer, writeLayer } from "./write-layer.ts";
18
20
  export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";