rpg-engine 0.7.0 → 0.9.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.
- package/dist/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.js +13 -13
- package/dist/campaign/create-campaign.js +10 -1
- package/dist/campaign/host-files.d.ts +2 -1
- package/dist/campaign/host-files.js +11 -11
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +55 -64
- package/dist/campaign/settings.js +171 -174
- package/dist/{cli.js → cli/cli.js} +3 -3
- package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
- package/dist/{command-line.js → cli/command-line.js} +21 -20
- package/dist/commands/advance.d.ts +1 -1
- package/dist/commands/advance.js +7 -7
- package/dist/commands/ask.d.ts +1 -8
- package/dist/commands/ask.js +16 -29
- package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
- package/dist/commands/{change.js → change/change.js} +46 -52
- package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
- package/dist/commands/{game-damage.js → change/damage.js} +3 -3
- package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
- package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
- package/dist/commands/config.d.ts +4 -4
- package/dist/commands/config.js +142 -138
- package/dist/commands/effect.d.ts +1 -1
- package/dist/commands/effect.js +11 -12
- package/dist/commands/find.d.ts +4 -4
- package/dist/commands/find.js +2 -2
- package/dist/commands/image.js +6 -6
- package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
- package/dist/commands/{import.js → import/import.js} +101 -101
- package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
- package/dist/commands/{game-import.js → import/run.js} +13 -12
- package/dist/commands/index.js +7 -7
- package/dist/commands/init.js +3 -3
- package/dist/commands/install.js +1 -1
- package/dist/commands/instructions.js +6 -6
- package/dist/commands/mode.d.ts +2 -2
- package/dist/commands/mode.js +8 -8
- package/dist/commands/mood.js +4 -4
- package/dist/commands/move.js +13 -20
- package/dist/commands/package.d.ts +2 -2
- package/dist/commands/package.js +138 -93
- package/dist/commands/rename.js +3 -3
- package/dist/commands/reveal.js +29 -18
- package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
- package/dist/commands/{roll.js → roll/roll.js} +69 -69
- package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
- package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
- package/dist/commands/rules.d.ts +2 -2
- package/dist/commands/rules.js +17 -9
- package/dist/commands/save.d.ts +1 -1
- package/dist/commands/save.js +18 -18
- package/dist/commands/scene.d.ts +4 -4
- package/dist/commands/scene.js +31 -28
- package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
- package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
- package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
- package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
- package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
- package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
- package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
- package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
- package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
- package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
- package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
- package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
- package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
- package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
- package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
- package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
- package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
- package/dist/commands/{game-events.js → shared/events.js} +20 -22
- package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
- package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
- package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
- package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
- package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
- package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
- package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
- package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
- package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
- package/dist/commands/{game-images.js → shared/images.js} +7 -6
- package/dist/commands/shared/inputs.d.ts +9 -0
- package/dist/commands/shared/inputs.js +12 -0
- package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
- package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
- package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
- package/dist/commands/{game-knowledge.js → shared/knowledge.js} +56 -44
- package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
- package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
- package/dist/commands/{game-library.js → shared/library.js} +70 -50
- package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
- package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
- package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
- package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
- package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
- package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
- package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
- package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
- package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
- package/dist/commands/{game-money.js → shared/money.js} +4 -4
- package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
- package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
- package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
- package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
- package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
- package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
- package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
- package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
- package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
- package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
- package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
- package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
- package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
- package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
- package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
- package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
- package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
- package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
- package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
- package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
- package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
- package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
- package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
- package/dist/commands/{parts.js → shared/parts.js} +4 -4
- package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
- package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
- package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
- package/dist/commands/{problems.js → shared/problems.js} +21 -22
- package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
- package/dist/commands/{progression.js → shared/progression.js} +4 -4
- package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
- package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
- package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
- package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
- package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
- package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
- package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
- package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
- package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +13 -5
- package/dist/commands/shared/rules.js +66 -0
- package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
- package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
- package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
- package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
- package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
- package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
- package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
- package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
- package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
- package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
- package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
- package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
- package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
- package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
- package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
- package/dist/commands/{game-time.js → shared/time.js} +6 -6
- package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
- package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
- package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
- package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
- package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
- package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
- package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
- package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
- package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
- package/dist/commands/{game-world.js → shared/world.js} +72 -76
- package/dist/commands/show.d.ts +4 -1
- package/dist/commands/show.js +36 -18
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.js +28 -28
- package/dist/commands/thoughts.js +3 -3
- package/dist/commands/trade.js +9 -10
- package/dist/commands/translate.d.ts +1 -1
- package/dist/commands/translate.js +3 -3
- package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
- package/dist/commands/{game-open.js → travel/open.js} +4 -5
- package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
- package/dist/commands/{route.js → travel/route.js} +9 -10
- package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
- package/dist/commands/{travel.js → travel/travel.js} +19 -21
- package/dist/commands/validate.js +5 -5
- package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
- package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
- package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
- package/dist/commands/{game-view-map.js → view/map.js} +15 -16
- package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
- package/dist/commands/{game-view-place.js → view/place.js} +108 -108
- package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
- package/dist/commands/{view.js → view/view.js} +41 -36
- package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
- package/dist/commands/{game-view-world.js → view/world.js} +7 -7
- package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
- package/dist/commands/{game-here.js → write/here.js} +18 -12
- package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
- package/dist/commands/{write.js → write/write.js} +44 -41
- package/dist/confirm/confirm.d.ts +2 -0
- package/dist/confirm/confirm.js +15 -5
- package/dist/core/consents.d.ts +3 -2
- package/dist/core/consents.js +43 -4
- package/dist/core/context.d.ts +8 -6
- package/dist/core/context.js +4 -2
- package/dist/core/download.js +16 -5
- package/dist/core/files.d.ts +8 -1
- package/dist/core/files.js +53 -21
- package/dist/core/formula.d.ts +7 -2
- package/dist/core/formula.js +63 -66
- package/dist/core/instruction-parts.js +1 -1
- package/dist/core/mood.d.ts +0 -1
- package/dist/core/mood.js +3 -3
- package/dist/core/package-api.d.ts +11 -0
- package/dist/core/package-api.js +2 -1
- package/dist/core/package-declarations.d.ts +9 -9
- package/dist/core/package-declarations.js +3 -3
- package/dist/core/process-mark.d.ts +8 -0
- package/dist/core/process-mark.js +72 -0
- package/dist/core/registry.d.ts +5 -0
- package/dist/core/registry.js +10 -0
- package/dist/core/session-store.d.ts +0 -1
- package/dist/core/session-store.js +11 -14
- package/dist/core/store.d.ts +4 -0
- package/dist/core/store.js +29 -8
- package/dist/core/text.d.ts +4 -0
- package/dist/core/text.js +11 -2
- package/dist/core/yaml-file.js +2 -2
- package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
- package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
- package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
- package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
- package/dist/dashboard/app.js +13 -13
- package/dist/dashboard/asked.js +1 -1
- package/dist/dashboard/dice/burn.js +1 -1
- package/dist/dashboard/dice/stage.js +1 -1
- package/dist/dashboard/game-words.js +4 -4
- package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
- package/dist/dashboard/{help.js → help/help.js} +6 -6
- package/dist/dashboard/journal.js +1 -1
- package/dist/dashboard/kit.js +6 -5
- package/dist/dashboard/labels.js +7 -3
- package/dist/dashboard/markdown.js +1 -1
- package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
- package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
- package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
- package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
- package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
- package/dist/dashboard/party.js +1 -1
- package/dist/dashboard/person-panel.js +2 -13
- package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
- package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
- package/dist/dashboard/scene.js +4 -4
- package/dist/dashboard/settings.js +1 -1
- package/dist/dashboard/sheet.js +4 -4
- package/dist/dashboard/text.js +6 -0
- package/dist/dashboard/top.js +2 -2
- package/dist/dashboard/turns.js +2 -2
- package/dist/dashboard/widgets.js +1 -1
- package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
- package/dist/dashboard/{lore.js → world/known.js} +1 -1
- package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
- package/dist/dashboard/{world-map.js → world/map.js} +1 -1
- package/dist/dashboard/{world.js → world/world.js} +14 -14
- package/dist/dice/evaluate.js +1 -1
- package/dist/dice/index.d.ts +2 -2
- package/dist/dice/index.js +2 -2
- package/dist/dice/notation.d.ts +2 -0
- package/dist/dice/notation.js +22 -4
- package/dist/documents/markup.js +2 -2
- package/dist/documents/read.js +29 -13
- package/dist/effects/effect.js +2 -5
- package/dist/extensions/extension.js +6 -8
- package/dist/extensions/index.d.ts +1 -4
- package/dist/extensions/index.js +1 -4
- package/dist/extensions/words.js +2 -1
- package/dist/{pictures → helpers}/briefs.js +17 -14
- package/dist/{pictures → helpers}/claude.js +8 -18
- package/dist/{pictures → helpers}/codex.js +3 -15
- package/dist/helpers/index.d.ts +7 -0
- package/dist/helpers/index.js +9 -0
- package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
- package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
- package/dist/images/images.js +7 -5
- package/dist/images/index.d.ts +1 -1
- package/dist/images/index.js +1 -1
- package/dist/importer/index.d.ts +1 -1
- package/dist/importer/index.js +1 -1
- package/dist/importer/work.d.ts +0 -2
- package/dist/importer/work.js +9 -30
- package/dist/instructions/index.d.ts +2 -0
- package/dist/instructions/index.js +10 -0
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/language-pack.js +15 -3
- package/dist/library/books.js +29 -83
- package/dist/{extensions → packages}/engine.d.ts +1 -1
- package/dist/{extensions → packages}/engine.js +1 -1
- package/dist/packages/index.d.ts +3 -0
- package/dist/packages/index.js +4 -0
- package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
- package/dist/{extensions/packages.js → packages/npm.js} +74 -45
- package/dist/page.d.ts +9 -11
- package/dist/page.js +1 -2
- package/dist/pages/check.js +31 -40
- package/dist/pages/containers.js +20 -20
- package/dist/pages/environment.js +15 -15
- package/dist/pages/index.d.ts +9 -9
- package/dist/pages/index.js +9 -9
- package/dist/pages/inheritance.d.ts +2 -1
- package/dist/pages/inheritance.js +24 -24
- package/dist/pages/load.js +7 -7
- package/dist/pages/maps.d.ts +20 -0
- package/dist/pages/maps.js +51 -1
- package/dist/pages/markdown.d.ts +2 -0
- package/dist/pages/markdown.js +110 -79
- package/dist/pages/page-file.d.ts +2 -1
- package/dist/pages/page-file.js +31 -29
- package/dist/pages/rename-page.d.ts +4 -1
- package/dist/pages/rename-page.js +7 -3
- package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
- package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
- package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
- package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
- package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
- package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
- package/dist/pages/system-pages.js +15 -15
- package/dist/pages/world.d.ts +4 -0
- package/dist/pages/world.js +52 -20
- package/dist/pages/write-page.js +35 -34
- package/dist/player-notes/index.d.ts +1 -1
- package/dist/player-notes/index.js +1 -1
- package/dist/rules/page-search.js +3 -4
- package/dist/rules/rule-book.js +1 -1
- package/dist/rules/search.js +21 -21
- package/dist/rules/shown.js +1 -3
- package/dist/saves/saves.d.ts +2 -2
- package/dist/saves/saves.js +15 -3
- package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
- package/dist/server/dashboard/files.d.ts +59 -0
- package/dist/server/dashboard/files.js +326 -0
- package/dist/server/dashboard/index.d.ts +114 -0
- package/dist/server/dashboard/index.js +419 -0
- package/dist/server/dashboard/news.d.ts +39 -0
- package/dist/server/dashboard/news.js +390 -0
- package/dist/server/dashboard/player.d.ts +48 -0
- package/dist/server/dashboard/player.js +242 -0
- package/dist/server/dashboard/ports.d.ts +10 -0
- package/dist/server/dashboard/ports.js +15 -0
- package/dist/server/dashboard/writes.d.ts +58 -0
- package/dist/server/dashboard/writes.js +492 -0
- package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
- package/dist/{mcp-server.js → server/mcp.js} +57 -42
- package/dist/systems/game-system.d.ts +5 -3
- package/dist/systems/game-system.js +178 -149
- package/dist/systems/index.d.ts +1 -1
- package/dist/systems/index.js +1 -1
- package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
- package/dist/{testing.js → testing/index.js} +32 -18
- package/dist/{system-checks.js → testing/system-checks.js} +18 -12
- package/dist/themes/theme.d.ts +3 -3
- package/dist/themes/theme.js +14 -14
- package/dist/time/calendar.js +5 -2
- package/dist/triggers/trigger.js +5 -8
- package/instructions/dashboard-guide.md +2 -1
- package/instructions/play.md +1 -1
- package/package.json +5 -5
- package/dist/commands/game-maps.d.ts +0 -20
- package/dist/commands/game-maps.js +0 -51
- package/dist/commands/game-rules.js +0 -36
- package/dist/dashboard-server.d.ts +0 -47
- package/dist/dashboard-server.js +0 -1830
- package/dist/pictures/index.d.ts +0 -7
- package/dist/pictures/index.js +0 -9
- /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
- /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
- /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
- /package/dist/commands/{notes.js → shared/notes.js} +0 -0
- /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
- /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
- /package/dist/dashboard/{people.js → packages/people.js} +0 -0
- /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
- /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
- /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
- /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
- /package/dist/{pictures → helpers}/chosen.js +0 -0
- /package/dist/{pictures → helpers}/claude.d.ts +0 -0
- /package/dist/{pictures → helpers}/codex.d.ts +0 -0
- /package/dist/{pictures → helpers}/stop.d.ts +0 -0
- /package/dist/{pictures → helpers}/stop.js +0 -0
- /package/dist/{pictures → helpers}/svg.d.ts +0 -0
- /package/dist/{pictures → helpers}/svg.js +0 -0
- /package/dist/{extensions → packages}/tarball.d.ts +0 -0
- /package/dist/{extensions → packages}/tarball.js +0 -0
- /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
- /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
- /package/dist/{player-acts.js → server/player-acts.js} +0 -0
- /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
package/dist/commands/package.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { changeExtensions, findCampaign, readTextSetting, requireCampaign } from "../campaign/index.js";
|
|
4
|
+
import { plainText } from "../confirm/index.js";
|
|
4
5
|
import { engineSystemsFolder } from "../core/context.js";
|
|
5
6
|
import { neutralExamples } from "../core/examples.js";
|
|
6
7
|
import { installedFromFolder } from "../core/files.js";
|
|
@@ -10,16 +11,17 @@ import { defineCommand } from "../core/registry.js";
|
|
|
10
11
|
import { files, FileStore, isInside, withFiles } from "../core/store.js";
|
|
11
12
|
import { comparableText } from "../core/text.js";
|
|
12
13
|
import { isNewerVersion } from "../core/version.js";
|
|
13
|
-
import { dropConsent, findExtension, installedExtensions,
|
|
14
|
+
import { dropConsent, findExtension, installedExtensions, readExtension, recordConsent, shortName } from "../extensions/index.js";
|
|
14
15
|
import { installedLanguages, languagePackProblems, readLanguagePack } from "../languages/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { campaignMode } from "./
|
|
20
|
-
import { loadCampaignCode, loadNewSystemCode, packageCommandNames, packagesInstalled } from "./
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
16
|
+
import { isLocalSpec, isPackageName, issuesPage, isTarball, isVerified, verifiedScope } from "../packages/index.js";
|
|
17
|
+
import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder } from "../systems/index.js";
|
|
18
|
+
import { exportAdventure, installAdventure, installedAdventures, isAdventureSpec, readAdventureSpec, removeAdventure, storyTouching } from "./shared/adventures.js";
|
|
19
|
+
import { campaignExamples } from "./shared/examples.js";
|
|
20
|
+
import { campaignMode } from "./shared/mode.js";
|
|
21
|
+
import { loadCampaignCode, loadNewSystemCode, packageCommandNames, packagesInstalled } from "./shared/packages/code.js";
|
|
22
|
+
import { listedExtensions, runsCode } from "./shared/packages/extensions.js";
|
|
23
|
+
import { newDatedLogEntry } from "./shared/time.js";
|
|
24
|
+
import { campaignWorld } from "./shared/world.js";
|
|
23
25
|
/** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
|
|
24
26
|
export class YesRefused extends Error {
|
|
25
27
|
code;
|
|
@@ -142,6 +144,77 @@ export const packageCommand = defineCommand({
|
|
|
142
144
|
].filter((line) => line !== "").join("\n");
|
|
143
145
|
},
|
|
144
146
|
});
|
|
147
|
+
/**
|
|
148
|
+
* Installs the game system the campaign in this context's folder plays, when it is one of ours that is not on this computer, as package install does, from
|
|
149
|
+
* npm's cache when the registry does not answer, then loads its code (SYS-10, D-514 (3)); once for each system, as `tried` keeps them. The line that says
|
|
150
|
+
* so to the master, or why it could not; undefined when there is no campaign or nothing to install, and for a system not ours, which asks the player's yes.
|
|
151
|
+
*/
|
|
152
|
+
export async function installCampaignSystem(context, tried) {
|
|
153
|
+
const packages = context.packages;
|
|
154
|
+
return packages === undefined ? undefined : await withFiles(context.files ?? new FileStore(context.systemFolders), async () => {
|
|
155
|
+
const root = findCampaign(context.folder);
|
|
156
|
+
const name = root === undefined ? undefined : readTextSetting(root, "system");
|
|
157
|
+
const ours = name === undefined ? undefined : ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
|
|
158
|
+
// Each system is looked for once: one here stays, as package uninstall keeps the one the campaign plays.
|
|
159
|
+
if (root === undefined || ours === undefined || tried.has(ours.name)) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
tried.add(ours.name);
|
|
163
|
+
if (isSystemHere(context, ours.name)) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
let result;
|
|
167
|
+
try {
|
|
168
|
+
// As package install, which loads the code of the system the campaign plays.
|
|
169
|
+
result = await installed(root, context, ours.package);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// npm's why, without what package install adds for the master, and without its period: the master tells the player, and the player chooses (D-514 (3)).
|
|
173
|
+
const why = (error instanceof Error ? error.message : String(error)).replace(/^\S+ could not be installed: /, "").replace(/\s*Nothing changed[^.]*\.$/, "").replace(/\.$/, "");
|
|
174
|
+
return `The campaign's game system, ${ours.name}, is not on this computer, and could not be installed: ${why}. Tell the player off-game, in brackets and in a table's words, `
|
|
175
|
+
+ `that this computer lacks the ${ours.name} rules and could not download them: once it is online, you install them with package install ${ours.name}, no yes needed. `
|
|
176
|
+
+ "Until then you play without its pages and the sheet's worked-out numbers, or wait, as the player chooses.";
|
|
177
|
+
}
|
|
178
|
+
const version = result.kind === "system-installed" && result.system.version !== undefined ? ` ${result.system.version}` : "";
|
|
179
|
+
return `The campaign's game system, ${ours.name}, was not on this computer: RPG Engine installed it, ${ours.package}${version}, one of its own. Its pages and rules are there from now.`
|
|
180
|
+
+ namesNote(root, context, ours.name);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
|
|
184
|
+
export function isInstalledPackage(context, name) {
|
|
185
|
+
const asked = name.startsWith("npm:") ? name.slice(4) : name.startsWith("@") ? name : `${verifiedScope}${name}`;
|
|
186
|
+
// An npm name only, never a path that climbs to npm's own folder (D-510).
|
|
187
|
+
return [asked, name].some((one) => isPackageName(one) && installedExtensionFolder(context, one) !== undefined);
|
|
188
|
+
}
|
|
189
|
+
/** What the master hears of an adventure installed (D-483 (5)): what it is in a few lines, then what to read and where it starts, never its text. */
|
|
190
|
+
export function adventureText(result) {
|
|
191
|
+
const { manifest } = result;
|
|
192
|
+
const by = manifest.author === undefined ? "" : ` by ${manifest.author}`;
|
|
193
|
+
const rights = manifest.license ?? "all rights reserved";
|
|
194
|
+
const counts = Object.entries(result.counts).map(([kind, count]) => `${count} ${kind}`).join(", ");
|
|
195
|
+
const levels = manifest.levels === undefined ? undefined : manifest.levels.from === manifest.levels.to ? `level ${manifest.levels.from}` : `levels ${manifest.levels.from}-${manifest.levels.to}`;
|
|
196
|
+
const start = result.start === undefined
|
|
197
|
+
? ""
|
|
198
|
+
: result.start.placed
|
|
199
|
+
? ` It starts in [[${result.start.name}]].`
|
|
200
|
+
: ` It starts in [[${result.start.name}]], in no place of the world yet: write it into the place that holds it, or give it a position, and a road from where it is reached.`;
|
|
201
|
+
const read = manifest.opening === undefined ? "Read its places and quests" : `Show [[${manifest.opening}]] and the pages it says to read first`;
|
|
202
|
+
return [
|
|
203
|
+
`${result.already ? "The campaign already has" : "Installed"} the adventure ${manifest.title} ${manifest.version}${by} (${rights}): ${manifest.about.replace(/\.$/, "")}. ${counts}.`,
|
|
204
|
+
levels === undefined ? "" : `It is written for ${levels}: adapt it to the party's.`,
|
|
205
|
+
manifest.content.length === 0 ? "" : `Its content: ${manifest.content.join(", ")}; keep to the player's lines and veils.`,
|
|
206
|
+
result.firstDate === undefined
|
|
207
|
+
? ""
|
|
208
|
+
: result.shift === 0
|
|
209
|
+
? `Its first date: [[${result.firstDate.page}]], on ${result.firstDate.date}.`
|
|
210
|
+
: `Its dates moved ${result.shift} days: the first, [[${result.firstDate.page}]], on ${result.firstDate.date}.`,
|
|
211
|
+
result.textDates === 0 ? "" : result.textDates === 1 ? "1 date in its text stays as written: count it from today." : `${result.textDates} dates in its text stay as written: count them from today.`,
|
|
212
|
+
result.shadows.length === 0 ? "" : `Its pages take the place of the game system's: ${result.shadows.join(", ")}.`,
|
|
213
|
+
result.covers.length === 0 ? "" : `Its rules take the place of the game system's: ${result.covers.join(", ")}.`,
|
|
214
|
+
result.ignored.length === 0 ? "" : `Left out, no part of an adventure: ${result.ignored.join(", ")}.`,
|
|
215
|
+
`${read} before you narrate.${start} Bring a hook into the story: the adventure begins when the player takes it.`,
|
|
216
|
+
].filter((line) => line !== "").join(" ");
|
|
217
|
+
}
|
|
145
218
|
/** The packages on this computer, and those the campaign lists and does not find there: at once, without npm (D-442). */
|
|
146
219
|
function listed(root, context) {
|
|
147
220
|
const used = Object.keys(listedExtensions(root));
|
|
@@ -251,9 +324,19 @@ async function installed(root, context, name) {
|
|
|
251
324
|
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
252
325
|
packagesInstalled();
|
|
253
326
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
327
|
+
// By its whole name: another's skies is not ours, nor ours another's.
|
|
328
|
+
const installed = installedAs(context, described.name);
|
|
329
|
+
const extension = "extension" in installed ? installed.extension : undefined;
|
|
330
|
+
// What npm installed is not what the player said yes to, or no extension: it goes off this computer again, and never runs.
|
|
331
|
+
if (extension === undefined || extension.version !== described.version) {
|
|
332
|
+
await packages.uninstall(described.name);
|
|
333
|
+
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
334
|
+
const why = extension !== undefined
|
|
335
|
+
? `it is the version ${extension.version}, not the ${described.version} the player said yes to`
|
|
336
|
+
: "unread" in installed
|
|
337
|
+
? `its extension does not read: ${installed.unread}`
|
|
338
|
+
: "no extension of that name is where npm put it";
|
|
339
|
+
throw new Error(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`);
|
|
257
340
|
}
|
|
258
341
|
// The player's yes holds for this version and these files, on this computer: its code runs on the server and in the page (D-478, D-510).
|
|
259
342
|
if (!isVerified(described.name, local) && !extension.linked) {
|
|
@@ -273,7 +356,7 @@ async function installed(root, context, name) {
|
|
|
273
356
|
}
|
|
274
357
|
// Its code is checked before the campaign lists it: a package that would not work is never added.
|
|
275
358
|
const commands = runsCode(extension)
|
|
276
|
-
? await packageCommandNames(extension, context
|
|
359
|
+
? await packageCommandNames(extension, context).catch((error) => {
|
|
277
360
|
throw new Error(`The code of ${extension.package} cannot be used: ${error instanceof Error ? error.message : String(error)}. Nothing changed in the campaign.`);
|
|
278
361
|
})
|
|
279
362
|
: [];
|
|
@@ -325,15 +408,9 @@ async function systemInstalled(root, context, spec, name, described) {
|
|
|
325
408
|
if (!isVerified(described.name, local) && !local && installed !== undefined) {
|
|
326
409
|
recordConsent(installed, described.name, described.version);
|
|
327
410
|
}
|
|
328
|
-
|
|
329
|
-
try {
|
|
330
|
-
system = systemsHere(root, context).find((one) => one.package === described.name);
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
throw new Error(`${described.name} was installed, but its system.yaml does not read: ${error instanceof Error ? error.message : String(error)}. Uninstall it with package uninstall ${described.name}.`);
|
|
334
|
-
}
|
|
411
|
+
const system = systemsHere(root, context).find((one) => one.package === described.name);
|
|
335
412
|
if (system === undefined) {
|
|
336
|
-
throw new Error(`${described.name} was installed, but
|
|
413
|
+
throw new Error(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`);
|
|
337
414
|
}
|
|
338
415
|
appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: system.verified, kind: "system" }));
|
|
339
416
|
const plays = readTextSetting(root, "system");
|
|
@@ -359,7 +436,7 @@ function codeText(loaded) {
|
|
|
359
436
|
function systemsHere(root, context) {
|
|
360
437
|
const plays = readTextSetting(root, "system") ?? "";
|
|
361
438
|
const folders = systemFolders(context.systemFolders);
|
|
362
|
-
return
|
|
439
|
+
return readableSystems(context.systemFolders).map((system) => {
|
|
363
440
|
const manifest = packageOf(folders.find((one) => one.name === system.name)?.folder ?? system.folder);
|
|
364
441
|
// The engine's own have no package of their own here; one npm installed is ours only by our scope, and never from a folder (D-441).
|
|
365
442
|
const shipped = isInside(engineSystemsFolder, system.folder);
|
|
@@ -452,42 +529,6 @@ function languagesHere(context) {
|
|
|
452
529
|
...issuesOf(pack.folder),
|
|
453
530
|
}));
|
|
454
531
|
}
|
|
455
|
-
/**
|
|
456
|
-
* Installs the game system the campaign in this context's folder plays, when it is one of ours that is not on this computer, as package install does, from
|
|
457
|
-
* npm's cache when the registry does not answer, then loads its code (SYS-10, D-514 (3)); once for each system, as `tried` keeps them. The line that says
|
|
458
|
-
* so to the master, or why it could not; undefined when there is no campaign or nothing to install, and for a system not ours, which asks the player's yes.
|
|
459
|
-
*/
|
|
460
|
-
export async function installCampaignSystem(context, tried) {
|
|
461
|
-
const packages = context.packages;
|
|
462
|
-
return packages === undefined ? undefined : await withFiles(context.files ?? new FileStore(context.systemFolders), async () => {
|
|
463
|
-
const root = findCampaign(context.folder);
|
|
464
|
-
const name = root === undefined ? undefined : readTextSetting(root, "system");
|
|
465
|
-
const ours = name === undefined ? undefined : ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
|
|
466
|
-
// Each system is looked for once: one here stays, as package uninstall keeps the one the campaign plays.
|
|
467
|
-
if (root === undefined || ours === undefined || tried.has(ours.name)) {
|
|
468
|
-
return undefined;
|
|
469
|
-
}
|
|
470
|
-
tried.add(ours.name);
|
|
471
|
-
if (isSystemHere(context, ours.name)) {
|
|
472
|
-
return undefined;
|
|
473
|
-
}
|
|
474
|
-
let result;
|
|
475
|
-
try {
|
|
476
|
-
// As package install, which loads the code of the system the campaign plays.
|
|
477
|
-
result = await installed(root, context, ours.package);
|
|
478
|
-
}
|
|
479
|
-
catch (error) {
|
|
480
|
-
// npm's why, without what package install adds for the master, and without its period: the master tells the player, and the player chooses (D-514 (3)).
|
|
481
|
-
const why = (error instanceof Error ? error.message : String(error)).replace(/^\S+ could not be installed: /, "").replace(/\s*Nothing changed[^.]*\.$/, "").replace(/\.$/, "");
|
|
482
|
-
return `The campaign's game system, ${ours.name}, is not on this computer, and could not be installed: ${why}. Tell the player off-game, in brackets and in a table's words, `
|
|
483
|
-
+ `that this computer lacks the ${ours.name} rules and could not download them: once it is online, you install them with package install ${ours.name}, no yes needed. `
|
|
484
|
-
+ "Until then you play without its pages and the sheet's worked-out numbers, or wait, as the player chooses.";
|
|
485
|
-
}
|
|
486
|
-
const version = result.kind === "system-installed" && result.system.version !== undefined ? ` ${result.system.version}` : "";
|
|
487
|
-
return `The campaign's game system, ${ours.name}, was not on this computer: RPG Engine installed it, ${ours.package}${version}, one of its own. Its pages and rules are there from now.`
|
|
488
|
-
+ namesNote(root, context, ours.name);
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
532
|
/**
|
|
492
533
|
* The names of a system just installed in the chat, which the host's list of tools may not have yet (D-518): its counter, its rest and its coins, those that
|
|
493
534
|
* are not the neutral ones; nothing when it names none of them.
|
|
@@ -515,11 +556,6 @@ function isSystemHere(context, name) {
|
|
|
515
556
|
return true;
|
|
516
557
|
}
|
|
517
558
|
}
|
|
518
|
-
/** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
|
|
519
|
-
export function isInstalledPackage(context, name) {
|
|
520
|
-
const asked = name.startsWith("npm:") ? name.slice(4) : name.startsWith("@") ? name : `${verifiedScope}${name}`;
|
|
521
|
-
return [asked, name].some((one) => installedExtensionFolder(context, one) !== undefined);
|
|
522
|
-
}
|
|
523
559
|
/** The folder npm installed a package in, among the extensions' folders; undefined when it is not there. */
|
|
524
560
|
function installedExtensionFolder(context, name) {
|
|
525
561
|
return (context.extensionFolders ?? []).map((folder) => join(folder, ...name.split("/"))).find((folder) => files().exists(join(folder, "package.json")));
|
|
@@ -542,7 +578,10 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
|
|
|
542
578
|
if (context.declined?.has(pack) === true) {
|
|
543
579
|
throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined");
|
|
544
580
|
}
|
|
545
|
-
// Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510).
|
|
581
|
+
// Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510). The package's own words cut short, so
|
|
582
|
+
// that a window, which shows so much at most, never loses the warning to them.
|
|
583
|
+
const clean = (text, most) => plainText(text.replace(/\s+/g, " "), most);
|
|
584
|
+
[name, holds] = [clean(name, 120), holds.trim() === "" ? "" : ` ${clean(holds, 160)}`];
|
|
546
585
|
const from = context.actor === "player" ? "the dashboard" : context.host === undefined ? "the command line" : "the chat";
|
|
547
586
|
const can = "Its code runs on this computer with your permissions, and in the dashboard, where it can see the whole campaign, its secrets included, and press buttons and speak to the master for you.";
|
|
548
587
|
const warning = local
|
|
@@ -581,6 +620,32 @@ function usable(context, name) {
|
|
|
581
620
|
return undefined;
|
|
582
621
|
}
|
|
583
622
|
}
|
|
623
|
+
/** The extension npm installed by this whole name, or why it is none: not there under that name, or not read, with what is wrong. */
|
|
624
|
+
function installedAs(context, name) {
|
|
625
|
+
const found = installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name);
|
|
626
|
+
if (found === undefined) {
|
|
627
|
+
return { missing: true };
|
|
628
|
+
}
|
|
629
|
+
try {
|
|
630
|
+
return { extension: readExtension(found.folder) };
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
return { unread: error instanceof Error ? error.message : String(error) };
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/** Why a system npm installed is not among those that read: its system.yaml does not, or it has none. */
|
|
637
|
+
function unreadSystemWhy(folder, name) {
|
|
638
|
+
if (folder === undefined || !files().exists(join(folder, "system.yaml"))) {
|
|
639
|
+
return "it has no system.yaml: it is no game system";
|
|
640
|
+
}
|
|
641
|
+
try {
|
|
642
|
+
systemInFolder(folder, shortName(name).replace(/^system-/, ""));
|
|
643
|
+
return "it does not read as a game system";
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
return `its system.yaml does not read: ${error instanceof Error ? error.message : String(error)}`;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
584
649
|
/** The extension's part of the instructions for the mode the campaign is in, which the chat going on has not been given. */
|
|
585
650
|
function modePart(root, context, extension) {
|
|
586
651
|
const mode = campaignMode(root, campaignWorld(root, context)).replace(" ", "-");
|
|
@@ -625,6 +690,15 @@ async function uninstalled(root, context, name) {
|
|
|
625
690
|
const found = other === undefined
|
|
626
691
|
? installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name || comparableText(shortName(one.package)) === comparableText(name))
|
|
627
692
|
: { package: other };
|
|
693
|
+
// A package that reads as nothing, as a system whose system.yaml is broken, is still npm's to take away by its folder, under its npm name.
|
|
694
|
+
const npmName = name.startsWith("npm:") ? name.slice(4) : name;
|
|
695
|
+
if (found === undefined && packages !== undefined && isPackageName(npmName) && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0)) {
|
|
696
|
+
const why = await packages.uninstall(npmName);
|
|
697
|
+
if (why !== undefined) {
|
|
698
|
+
throw new Error(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`);
|
|
699
|
+
}
|
|
700
|
+
return { kind: "uninstalled", name: npmName, wasUsed: false, extension: false };
|
|
701
|
+
}
|
|
628
702
|
if (found === undefined) {
|
|
629
703
|
const here = installedExtensions(context.extensionFolders ?? []).map((one) => shortName(one.package));
|
|
630
704
|
throw new Error(`${name} is not on this computer${here.length === 0 ? ": no package is" : `; these are: ${here.join(", ")}`}. Nothing changed.`);
|
|
@@ -655,35 +729,6 @@ async function adventureInstalled(root, context, spec) {
|
|
|
655
729
|
const adventure = await readAdventureSpec(spec, context);
|
|
656
730
|
return { kind: "adventure-installed", ...installAdventure(root, context, adventure, spec) };
|
|
657
731
|
}
|
|
658
|
-
/** What the master hears of an adventure installed (D-483 (5)): what it is in a few lines, then what to read and where it starts, never its text. */
|
|
659
|
-
export function adventureText(result) {
|
|
660
|
-
const { manifest } = result;
|
|
661
|
-
const by = manifest.author === undefined ? "" : ` by ${manifest.author}`;
|
|
662
|
-
const rights = manifest.license ?? "all rights reserved";
|
|
663
|
-
const counts = Object.entries(result.counts).map(([kind, count]) => `${count} ${kind}`).join(", ");
|
|
664
|
-
const levels = manifest.levels === undefined ? undefined : manifest.levels.from === manifest.levels.to ? `level ${manifest.levels.from}` : `levels ${manifest.levels.from}-${manifest.levels.to}`;
|
|
665
|
-
const start = result.start === undefined
|
|
666
|
-
? ""
|
|
667
|
-
: result.start.placed
|
|
668
|
-
? ` It starts in [[${result.start.name}]].`
|
|
669
|
-
: ` It starts in [[${result.start.name}]], in no place of the world yet: write it into the place that holds it, or give it a position, and a road from where it is reached.`;
|
|
670
|
-
const read = manifest.opening === undefined ? "Read its places and quests" : `Show [[${manifest.opening}]] and the pages it says to read first`;
|
|
671
|
-
return [
|
|
672
|
-
`${result.already ? "The campaign already has" : "Installed"} the adventure ${manifest.title} ${manifest.version}${by} (${rights}): ${manifest.about.replace(/\.$/, "")}. ${counts}.`,
|
|
673
|
-
levels === undefined ? "" : `It is written for ${levels}: adapt it to the party's.`,
|
|
674
|
-
manifest.content.length === 0 ? "" : `Its content: ${manifest.content.join(", ")}; keep to the player's lines and veils.`,
|
|
675
|
-
result.firstDate === undefined
|
|
676
|
-
? ""
|
|
677
|
-
: result.shift === 0
|
|
678
|
-
? `Its first date: [[${result.firstDate.page}]], on ${result.firstDate.date}.`
|
|
679
|
-
: `Its dates moved ${result.shift} days: the first, [[${result.firstDate.page}]], on ${result.firstDate.date}.`,
|
|
680
|
-
result.textDates === 0 ? "" : result.textDates === 1 ? "1 date in its text stays as written: count it from today." : `${result.textDates} dates in its text stay as written: count them from today.`,
|
|
681
|
-
result.shadows.length === 0 ? "" : `Its pages take the place of the game system's: ${result.shadows.join(", ")}.`,
|
|
682
|
-
result.covers.length === 0 ? "" : `Its rules take the place of the game system's: ${result.covers.join(", ")}.`,
|
|
683
|
-
result.ignored.length === 0 ? "" : `Left out, no part of an adventure: ${result.ignored.join(", ")}.`,
|
|
684
|
-
`${read} before you narrate.${start} Bring a hook into the story: the adventure begins when the player takes it.`,
|
|
685
|
-
].filter((line) => line !== "").join(" ");
|
|
686
|
-
}
|
|
687
732
|
/** What the master hears of an export (ADV-7): the file, what it came from and what stayed out. */
|
|
688
733
|
function exportText(result) {
|
|
689
734
|
const out = [
|
package/dist/commands/rename.js
CHANGED
|
@@ -7,9 +7,9 @@ import { defineCommand } from "../core/registry.js";
|
|
|
7
7
|
import { files } from "../core/store.js";
|
|
8
8
|
import { comparableText } from "../core/text.js";
|
|
9
9
|
import { applyRename, pageNamed, pageWithPath, planRename, renamedLinks } from "../pages/index.js";
|
|
10
|
-
import { readOpenScene, updateScene } from "./
|
|
11
|
-
import { newDatedLogEntry } from "./
|
|
12
|
-
import { campaignWorld } from "./
|
|
10
|
+
import { readOpenScene, updateScene } from "./shared/scene.js";
|
|
11
|
+
import { newDatedLogEntry } from "./shared/time.js";
|
|
12
|
+
import { campaignWorld } from "./shared/world.js";
|
|
13
13
|
export const rename = defineCommand({
|
|
14
14
|
name: "rename",
|
|
15
15
|
description: "Give a page of the campaign a new name, as when the player names their wolf or the character learns a place's true name. "
|
package/dist/commands/reveal.js
CHANGED
|
@@ -4,12 +4,12 @@ import { appendLogEntry, readLog } from "../core/log.js";
|
|
|
4
4
|
import { defineCommand } from "../core/registry.js";
|
|
5
5
|
import { comparableText, withArticle } from "../core/text.js";
|
|
6
6
|
import { baseChain, isEmptyField, isPartyMember, isPlayerCharacter, links, locate, pageNamed, parsePageReference, playerCharacters, secretNames, shownPart, systemLabel, withPage, writePage } from "../pages/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { textList, textsOf } from "./shared/inputs.js";
|
|
8
|
+
import { knownLink, knownLinks } from "./shared/knowledge.js";
|
|
9
|
+
import { placedPosition } from "./shared/positions.js";
|
|
10
|
+
import { copyName, readOpenScene } from "./shared/scene.js";
|
|
11
|
+
import { newDatedLogEntry } from "./shared/time.js";
|
|
12
|
+
import { campaignWorld } from "./shared/world.js";
|
|
13
13
|
export const reveal = defineCommand({
|
|
14
14
|
name: "reveal",
|
|
15
15
|
description: "Record what characters learn: a secret, as Page#Secret, or a whole page they did not know. "
|
|
@@ -25,12 +25,12 @@ export const reveal = defineCommand({
|
|
|
25
25
|
const root = requireCampaign(context.folder);
|
|
26
26
|
let world = campaignWorld(root, context);
|
|
27
27
|
const { scene } = readOpenScene(root);
|
|
28
|
-
const asked =
|
|
28
|
+
const asked = textsOf(input.page);
|
|
29
29
|
if (asked.length === 0) {
|
|
30
30
|
throw new Error("Give what they learn, such as page Coppa#Veleno, or a whole page such as Varro.");
|
|
31
31
|
}
|
|
32
32
|
// An empty to, as an MCP client may send it, is left out.
|
|
33
|
-
const to =
|
|
33
|
+
const to = textsOf(input.to);
|
|
34
34
|
const learners = to.length === 0 ? [playerCharacter(world)] : [...new Set(to.map((name) => learnerOf(world, scene, name)))];
|
|
35
35
|
const found = asked.map((item) => learnableOf(root, world, item));
|
|
36
36
|
const known = found.filter((item) => item.kind === "known").filter((item, index, all) => all.findIndex((other) => sameLink(other.link, item.link)) === index);
|
|
@@ -38,7 +38,7 @@ export const reveal = defineCommand({
|
|
|
38
38
|
const result = { learned: [], known: [], notSecret: found.filter((item) => item.kind === "public").map((item) => ({ what: item.shown, page: item.page })) };
|
|
39
39
|
const lines = [];
|
|
40
40
|
for (const learner of learners) {
|
|
41
|
-
const already = known.filter((item) => knowsLink(learner, item.link));
|
|
41
|
+
const already = known.filter((item) => knowsLink(world, learner, item.link));
|
|
42
42
|
const learned = known.filter((item) => !already.includes(item));
|
|
43
43
|
if (already.length > 0) {
|
|
44
44
|
result.known.push({ who: learner.name, what: already.map((item) => item.shown) });
|
|
@@ -46,7 +46,17 @@ export const reveal = defineCommand({
|
|
|
46
46
|
if (learned.length === 0) {
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
let written;
|
|
50
|
+
try {
|
|
51
|
+
written = writePage(world, learner.name, undefined, { add: { knows: learned.map((item) => item.link) } });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// Those already written have their lines, so that the diary knows who learned it.
|
|
55
|
+
logLearned(root, context, world, lines);
|
|
56
|
+
const before = result.learned.map((one) => one.who);
|
|
57
|
+
const done = before.length === 0 ? "" : ` ${before.join(", ")} learned it, and the log says so.`;
|
|
58
|
+
throw new Error(`${learner.name}'s page could not be written: ${error instanceof Error ? error.message : String(error)}.${done} Fix the file, then reveal it again for ${learner.name}.`);
|
|
59
|
+
}
|
|
50
60
|
world = withPage(world, learner, written.page);
|
|
51
61
|
lines.push({ learner, links: learned.map((item) => item.link) });
|
|
52
62
|
result.learned.push({ who: learner.name, what: learned.map((item) => (item.asked === undefined ? item.shown : `${item.shown} (as ${item.asked} shows it)`)) });
|
|
@@ -69,7 +79,7 @@ export const reveal = defineCommand({
|
|
|
69
79
|
*/
|
|
70
80
|
function logLearned(root, context, world, lines) {
|
|
71
81
|
const players = playerCharacters(world);
|
|
72
|
-
const playerKnows = (link) => players.some((player) => knowsLink(player, link));
|
|
82
|
+
const playerKnows = (link) => players.some((player) => knowsLink(world, player, link));
|
|
73
83
|
for (const { learner, links: learned } of lines) {
|
|
74
84
|
const visible = isPlayerCharacter(learner) || (isPartyMember(learner) && learned.every(playerKnows));
|
|
75
85
|
appendLogEntry(root, newDatedLogEntry(root, context, "learned", visible ? "public" : "hidden", { page: learner.name, knows: learned }));
|
|
@@ -183,16 +193,17 @@ function linksOfEntry(entry) {
|
|
|
183
193
|
function listHint(name, field) {
|
|
184
194
|
return name.includes(",") ? `for more than one, give a list, such as ${field} [${name.split(",").map((part) => part.trim()).join(", ")}].` : undefined;
|
|
185
195
|
}
|
|
186
|
-
/** Whether a character's knows holds a link, however written. */
|
|
187
|
-
function knowsLink(learner, link) {
|
|
188
|
-
const
|
|
189
|
-
|
|
196
|
+
/** Whether a character's knows holds a link, however written: by the page it names, under an alias too (D-417), and its secret. */
|
|
197
|
+
function knowsLink(world, learner, link) {
|
|
198
|
+
const [wanted] = links(link).map((one) => knownLink(world, one));
|
|
199
|
+
if (wanted === undefined) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
const samePage = (known) => (known.page === undefined || wanted.page === undefined ? comparableText(known.name) === comparableText(wanted.name) : known.page.path === wanted.page.path);
|
|
203
|
+
return knownLinks(world, learner).some((known) => samePage(known) && comparableText(known.secret ?? "") === comparableText(wanted.secret ?? ""));
|
|
190
204
|
}
|
|
191
205
|
/** Whether two texts are the same link: [[coppa#veleno]] and [[Coppa#Veleno]]. */
|
|
192
206
|
function sameLink(first, second) {
|
|
193
207
|
const key = (text) => links(text).map((link) => comparableText(`${link.page}#${link.section ?? ""}`)).join("|");
|
|
194
208
|
return key(first) !== "" && key(first) === key(second);
|
|
195
209
|
}
|
|
196
|
-
function listOf(value) {
|
|
197
|
-
return (typeof value === "string" ? [value] : value).filter((item) => item.trim() !== "");
|
|
198
|
-
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { Context } from "
|
|
3
|
-
import { type Page, type World } from "
|
|
4
|
-
import type { GameSystem } from "
|
|
2
|
+
import type { Context } from "../../core/context.ts";
|
|
3
|
+
import { type Page, type World } from "../../pages/index.ts";
|
|
4
|
+
import type { GameSystem } from "../../systems/index.ts";
|
|
5
5
|
export declare const faceValues: z.ZodPreprocess<z.ZodArray<z.ZodNumber>, unknown>;
|
|
6
|
-
export declare const roll: import("
|
|
6
|
+
export declare const roll: import("../../core/registry.ts").Command<z.ZodObject<{
|
|
7
7
|
notation: z.ZodOptional<z.ZodString>;
|
|
8
8
|
why: z.ZodOptional<z.ZodString>;
|
|
9
9
|
check: z.ZodOptional<z.ZodString>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { requireCampaign } from "
|
|
3
|
-
import { numberOf } from "
|
|
4
|
-
import { appendLogEntry, readLog } from "
|
|
5
|
-
import { defineCommand } from "
|
|
6
|
-
import { comparableText, sameName, valueNamed } from "
|
|
7
|
-
import { readCounter } from "
|
|
8
|
-
import { askOracle, DiceError, rollDice, sha256, tossCoins } from "
|
|
9
|
-
import { declaredKind, findPage, isPlayerCharacter, pagesWithName, writePage } from "
|
|
10
|
-
import { effectiveFields, effectsOf } from "
|
|
11
|
-
import { systemNamed } from "
|
|
12
|
-
import { behindTheScreen, namesNoOne, ofTheParty, screenNote, screenUp, sealHiddenRoll } from "
|
|
13
|
-
import { packagesRolled } from "
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
2
|
+
import { requireCampaign } from "../../campaign/index.js";
|
|
3
|
+
import { numberOf } from "../../core/formula.js";
|
|
4
|
+
import { appendLogEntry, readLog } from "../../core/log.js";
|
|
5
|
+
import { defineCommand } from "../../core/registry.js";
|
|
6
|
+
import { comparableText, sameName, valueNamed } from "../../core/text.js";
|
|
7
|
+
import { readCounter } from "../../counters/index.js";
|
|
8
|
+
import { askOracle, DiceError, rollDice, sha256, tossCoins } from "../../dice/index.js";
|
|
9
|
+
import { declaredKind, findPage, isPlayerCharacter, pagesWithName, writePage } from "../../pages/index.js";
|
|
10
|
+
import { effectiveFields, effectsOf } from "../shared/effect-layer.js";
|
|
11
|
+
import { systemNamed } from "../shared/effects.js";
|
|
12
|
+
import { behindTheScreen, namesNoOne, ofTheParty, screenNote, screenUp, sealHiddenRoll } from "../shared/master-rolls.js";
|
|
13
|
+
import { packagesRolled } from "../shared/packages/hooks.js";
|
|
14
|
+
import { firstInChat } from "../shared/parts.js";
|
|
15
|
+
import { copyPage, readOpenScene } from "../shared/scene.js";
|
|
16
|
+
import { knowledgeNote } from "../shared/sheet.js";
|
|
17
|
+
import { newDatedLogEntry } from "../shared/time.js";
|
|
18
|
+
import { itemList, signedText, workedFields } from "../shared/worked-out.js";
|
|
19
|
+
import { campaignSystem, campaignSystemWords, campaignWorld, missingSystemHint } from "../shared/world.js";
|
|
20
|
+
import { rollPageTable } from "./tables.js";
|
|
21
21
|
// Faces arrive as "14,7" or "14 7" from a shell (PowerShell turns 14,7 into "14 7"), or as an array.
|
|
22
22
|
export const faceValues = z.preprocess((value) => (typeof value === "string" ? value.split(/[\s,;]+/).filter(Boolean).map(Number) : value), z.array(z.number()));
|
|
23
23
|
// A name in a notation, at the start of a term: a field of the sheet of who rolls, such as athletics or sleight-of-hand (DAT-8). A hyphen inside a name is the
|
|
@@ -138,6 +138,56 @@ export const roll = defineCommand({
|
|
|
138
138
|
return `${output.id} ${label ? label + ": " : ""}${output.text}${output.physical ? " (physical dice)" : ""}${note}`;
|
|
139
139
|
},
|
|
140
140
|
});
|
|
141
|
+
/** The dice a game system rolls a number of its sheet with, for an example: that field's, else its first; 2d6 without them (D-280, D-514). */
|
|
142
|
+
export function sheetDiceOf(system, field) {
|
|
143
|
+
const dice = Object.entries(system?.sheetDice ?? {});
|
|
144
|
+
const own = field === undefined ? undefined : dice.find(([listed]) => comparableText(listed) === comparableText(field))?.[1];
|
|
145
|
+
return own ?? dice[0]?.[1] ?? "2d6";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The page of who rolls, a character or a copy in the open scene, with its world; undefined when who names neither, as a free label does. Without names to
|
|
149
|
+
* read, a name two pages share is a label too: the roll needs no sheet.
|
|
150
|
+
*/
|
|
151
|
+
export function rollerOf(root, context, who, readsSheet) {
|
|
152
|
+
if (who === undefined) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
const world = campaignWorld(root, context);
|
|
156
|
+
const named = pagesWithName(world, who);
|
|
157
|
+
const page = readsSheet ? findPage(world, who) : named.length === 1 ? named[0] : undefined;
|
|
158
|
+
if (page !== undefined) {
|
|
159
|
+
return { world, page };
|
|
160
|
+
}
|
|
161
|
+
const { scene } = readOpenScene(root);
|
|
162
|
+
const copy = scene === undefined ? undefined : sameName(Object.keys(scene.copies), who);
|
|
163
|
+
return scene === undefined || copy === undefined ? undefined : { world, page: copyPage(copy, scene.copies[copy]) };
|
|
164
|
+
}
|
|
165
|
+
/** Whether a notation names a field, such as athletics in 1d20+athletics (DAT-8). */
|
|
166
|
+
export function hasNames(notation) {
|
|
167
|
+
return [...notation.matchAll(namePattern)].some((match) => !diePattern.test(notation.slice((match.index ?? 0) + match[1].length + match[2].length)));
|
|
168
|
+
}
|
|
169
|
+
/** The notation with each name of a field as 0, to tell whether it is dice before a sheet is read: 1d20+athletics as 1d20+0. */
|
|
170
|
+
export function namesAsZero(notation) {
|
|
171
|
+
return notation.replace(namePattern, (whole, sign, space, name, offset) => (diePattern.test(notation.slice(offset + sign.length + space.length)) ? whole : whole.replace(name, "0")));
|
|
172
|
+
}
|
|
173
|
+
/** The notation with each name of a field replaced by its value on the sheet of who rolls, effects and formulas included, and the values taken (DAT-8). */
|
|
174
|
+
export function withSheetValues(notation, roller, who, system) {
|
|
175
|
+
const taken = {};
|
|
176
|
+
const fields = roller === undefined ? undefined : effectiveFields(roller.world, roller.page);
|
|
177
|
+
const replaced = notation.replace(namePattern, (whole, sign, space, name, offset) => {
|
|
178
|
+
if (diePattern.test(notation.slice(offset + sign.length + space.length))) {
|
|
179
|
+
return whole;
|
|
180
|
+
}
|
|
181
|
+
// "sleight of hand": a name of several words, which a notation cannot hold.
|
|
182
|
+
const words = /^\s+[A-Za-z]/.test(notation.slice(offset + whole.length));
|
|
183
|
+
checkNotScore(roller, system, fields, name);
|
|
184
|
+
const value = sheetValue(roller, fields, name, who, words, system);
|
|
185
|
+
taken[name] = value;
|
|
186
|
+
const negative = (sign === "-") !== (value < 0);
|
|
187
|
+
return `${negative ? "-" : sign === "" ? "" : "+"}${Math.abs(value)}`;
|
|
188
|
+
});
|
|
189
|
+
return { notation: replaced, taken };
|
|
190
|
+
}
|
|
141
191
|
/** A roll with what to say when the player asks whether a roll was real, once in a chat, as the core's rule left the instructions for it (D-530). */
|
|
142
192
|
function withRealNote(context, output) {
|
|
143
193
|
return firstInChat(context, "roll-real")
|
|
@@ -270,12 +320,6 @@ function keptExample(world) {
|
|
|
270
320
|
function declaredRolls(world) {
|
|
271
321
|
return Object.keys(world.system?.fields ?? {}).find((name) => declaredKind(world, name) === "rolls");
|
|
272
322
|
}
|
|
273
|
-
/** The dice a game system rolls a number of its sheet with, for an example: that field's, else its first; 2d6 without them (D-280, D-514). */
|
|
274
|
-
export function sheetDiceOf(system, field) {
|
|
275
|
-
const dice = Object.entries(system?.sheetDice ?? {});
|
|
276
|
-
const own = field === undefined ? undefined : dice.find(([listed]) => comparableText(listed) === comparableText(field))?.[1];
|
|
277
|
-
return own ?? dice[0]?.[1] ?? "2d6";
|
|
278
|
-
}
|
|
279
323
|
/** " Elara keeps 3, 4 in portent: give from Elara.": the characters whose field holds the number use asked for, when the page asked does not (KEP-3). */
|
|
280
324
|
function otherKeepers(world, kept, value) {
|
|
281
325
|
const others = world.pages.filter((page) => page !== kept.page && page.system === undefined).flatMap((page) => {
|
|
@@ -313,50 +357,6 @@ function takeKept(kept) {
|
|
|
313
357
|
writePage(kept.world, kept.page.name, undefined, left.length === 0 ? { unset: [kept.field] } : { set: { [kept.field]: left } });
|
|
314
358
|
return `${kept.value} from ${kept.page.name}'s ${kept.field} took the place of the die; ${left.length === 0 ? "none is left" : `left: ${left.join(", ")}`}.`;
|
|
315
359
|
}
|
|
316
|
-
/**
|
|
317
|
-
* The page of who rolls, a character or a copy in the open scene, with its world; undefined when who names neither, as a free label does. Without names to
|
|
318
|
-
* read, a name two pages share is a label too: the roll needs no sheet.
|
|
319
|
-
*/
|
|
320
|
-
export function rollerOf(root, context, who, readsSheet) {
|
|
321
|
-
if (who === undefined) {
|
|
322
|
-
return undefined;
|
|
323
|
-
}
|
|
324
|
-
const world = campaignWorld(root, context);
|
|
325
|
-
const named = pagesWithName(world, who);
|
|
326
|
-
const page = readsSheet ? findPage(world, who) : named.length === 1 ? named[0] : undefined;
|
|
327
|
-
if (page !== undefined) {
|
|
328
|
-
return { world, page };
|
|
329
|
-
}
|
|
330
|
-
const { scene } = readOpenScene(root);
|
|
331
|
-
const copy = scene === undefined ? undefined : sameName(Object.keys(scene.copies), who);
|
|
332
|
-
return scene === undefined || copy === undefined ? undefined : { world, page: copyPage(copy, scene.copies[copy]) };
|
|
333
|
-
}
|
|
334
|
-
/** Whether a notation names a field, such as athletics in 1d20+athletics (DAT-8). */
|
|
335
|
-
export function hasNames(notation) {
|
|
336
|
-
return [...notation.matchAll(namePattern)].some((match) => !diePattern.test(notation.slice((match.index ?? 0) + match[1].length + match[2].length)));
|
|
337
|
-
}
|
|
338
|
-
/** The notation with each name of a field as 0, to tell whether it is dice before a sheet is read: 1d20+athletics as 1d20+0. */
|
|
339
|
-
export function namesAsZero(notation) {
|
|
340
|
-
return notation.replace(namePattern, (whole, sign, space, name, offset) => (diePattern.test(notation.slice(offset + sign.length + space.length)) ? whole : whole.replace(name, "0")));
|
|
341
|
-
}
|
|
342
|
-
/** The notation with each name of a field replaced by its value on the sheet of who rolls, effects and formulas included, and the values taken (DAT-8). */
|
|
343
|
-
export function withSheetValues(notation, roller, who, system) {
|
|
344
|
-
const taken = {};
|
|
345
|
-
const fields = roller === undefined ? undefined : effectiveFields(roller.world, roller.page);
|
|
346
|
-
const replaced = notation.replace(namePattern, (whole, sign, space, name, offset) => {
|
|
347
|
-
if (diePattern.test(notation.slice(offset + sign.length + space.length))) {
|
|
348
|
-
return whole;
|
|
349
|
-
}
|
|
350
|
-
// "sleight of hand": a name of several words, which a notation cannot hold.
|
|
351
|
-
const words = /^\s+[A-Za-z]/.test(notation.slice(offset + whole.length));
|
|
352
|
-
checkNotScore(roller, system, fields, name);
|
|
353
|
-
const value = sheetValue(roller, fields, name, who, words, system);
|
|
354
|
-
taken[name] = value;
|
|
355
|
-
const negative = (sign === "-") !== (value < 0);
|
|
356
|
-
return `${negative ? "-" : sign === "" ? "" : "+"}${Math.abs(value)}`;
|
|
357
|
-
});
|
|
358
|
-
return { notation: replaced, taken };
|
|
359
|
-
}
|
|
360
360
|
/** Refuses a score the system shows with a modifier beside it, such as str with str-mod (DAT-2): a roll adds the modifier, and 1d20+str would add the score. */
|
|
361
361
|
function checkNotScore(roller, system, fields, name) {
|
|
362
362
|
// Only a score with its modifier beside it, as str with str-mod; not a speed with the one written beside it (SPD-1).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Context } from "
|
|
2
|
-
import { type FaceSource, type TableRoll } from "
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import { type FaceSource, type TableRoll } from "../../dice/index.ts";
|
|
3
3
|
/** A roll on the table of a page's section, given as Page#Section; refused, saying what to fix, before anything is rolled. */
|
|
4
4
|
export declare function rollPageTable(root: string, context: Context, reference: string, source: FaceSource): TableRoll & {
|
|
5
5
|
table: string;
|