rpg-engine 0.7.0 → 0.8.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 +3 -3
- 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} +42 -42
- 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} +2 -2
- package/dist/commands/{game-rules.js → shared/rules.js} +4 -4
- 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 +1 -1
- package/dist/commands/show.js +32 -17
- 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} +35 -35
- 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 +6 -1
- package/dist/core/files.js +47 -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/{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 +3 -3
- 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.js +25 -19
- 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/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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// What the game system works out from the fields of a page (D-199, FOR-3–FOR-8): its computed fields, each with the values it came from, and the limits of
|
|
2
2
|
// its counters. The formulas are the system's data; this is where they meet the pages and the counters.
|
|
3
|
-
import { chosenDice, contributingReads, diceFields, factorOf, fieldsRead, listItems, numberOf, parseRollFormula, tablesRead, workOut, } from "
|
|
4
|
-
import { comparableText, sameName } from "
|
|
5
|
-
import { formatCounter, readCounter } from "
|
|
6
|
-
import { readEffects } from "
|
|
7
|
-
import { bonusPages, carriedWeight, declaredKind, inheritedFields, isEmptyField, pagesWithName, readFieldValue, systemPageNamed, weightUnit } from "
|
|
8
|
-
import { formatDuration } from "
|
|
3
|
+
import { chosenDice, contributingReads, diceFields, factorOf, fieldsRead, listItems, numberOf, parseRollFormula, tablesRead, workOut, } from "../../core/formula.js";
|
|
4
|
+
import { comparableText, sameName } from "../../core/text.js";
|
|
5
|
+
import { formatCounter, readCounter } from "../../counters/index.js";
|
|
6
|
+
import { readEffects } from "../../effects/index.js";
|
|
7
|
+
import { bonusPages, carriedWeight, declaredKind, inheritedFields, isEmptyField, pagesWithName, readFieldValue, systemPageNamed, weightUnit } from "../../pages/index.js";
|
|
8
|
+
import { formatDuration } from "../../time/index.js";
|
|
9
9
|
import { progressionOf, progressionProblems, progressionValue } from "./progression.js";
|
|
10
10
|
/**
|
|
11
11
|
* The computed fields of the game system that have a value with these fields (FOR-4), in the order the system gives them; `explained`, each with only the
|
|
@@ -95,46 +95,6 @@ export function carriedIn(fields) {
|
|
|
95
95
|
const value = fields[carriedKey];
|
|
96
96
|
return typeof value === "number" ? value : undefined;
|
|
97
97
|
}
|
|
98
|
-
function effectValuesOver(world, page) {
|
|
99
|
-
const fields = { ...inheritedFields(world, page) };
|
|
100
|
-
const read = readEffects(Object.entries(page.fields).find(([field]) => comparableText(field) === "effects")?.[1]);
|
|
101
|
-
// What the pages of the system's bonus lists give, as a Ring of Protection one is attuned to or a feat, adds up as effects do (FOR-5, D-449); an at-least
|
|
102
|
-
// field rises to theirs, as Gauntlets of Ogre Power's str 19, and stays when higher.
|
|
103
|
-
for (const page of bonusPages(world, fields)) {
|
|
104
|
-
for (const [field, value] of Object.entries(inheritedFields(world, page))) {
|
|
105
|
-
const kind = declaredKind(world, field);
|
|
106
|
-
const amount = kind === "bonus" || kind === "at-least" ? numberOf(value) : undefined;
|
|
107
|
-
const key = keyOf(fields, field) ?? field;
|
|
108
|
-
const current = numberOf(fields[key]);
|
|
109
|
-
fields[key] = amount === undefined ? fields[key] : kind === "bonus" ? (current ?? 0) + amount : Math.max(current ?? amount, amount);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
for (const effect of "effects" in read ? read.effects : []) {
|
|
113
|
-
for (const [field, value] of effect.values) {
|
|
114
|
-
const key = keyOf(fields, field) ?? field;
|
|
115
|
-
const kind = declaredKind(world, field);
|
|
116
|
-
fields[key] = kind === "bonus"
|
|
117
|
-
? (numberOf(fields[key]) ?? 0) + (numberOf(effectValue(value)) ?? 0)
|
|
118
|
-
: kind === "factor"
|
|
119
|
-
? (factorOf(fields[key]) ?? 1) * (factorOf(value) ?? 1)
|
|
120
|
-
: effectValue(value);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// What a character carries weighs, for the formulas that read it as load, as a speed; under a key no list of fields shows (FOR-2, LOAD-1).
|
|
124
|
-
if (page.type === "character" && world.system?.load !== undefined) {
|
|
125
|
-
fields[carriedKey] = carriedWeight(world, world.system.load, page);
|
|
126
|
-
}
|
|
127
|
-
return fields;
|
|
128
|
-
}
|
|
129
|
-
/** A value of an effect as a page would hold it: a number, a link, a counter as text; text as it is when it does not read. */
|
|
130
|
-
function effectValue(value) {
|
|
131
|
-
try {
|
|
132
|
-
return readFieldValue(value);
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
98
|
/** Whether a counter of the system comes back with a rest (DAT-9): who keeps the sheet has it full until it spends it. */
|
|
139
99
|
export function isUse(world, field) {
|
|
140
100
|
return (world.system?.uses ?? []).some((name) => name.endsWith("*") ? comparableText(field).startsWith(comparableText(name.slice(0, -1))) : comparableText(name) === comparableText(field));
|
|
@@ -164,130 +124,10 @@ export function refillAmount(world, fields, field, occasions, max) {
|
|
|
164
124
|
export function formulaValue(world, fields, formula) {
|
|
165
125
|
return workOut(formula, formulaScope(world, fields)).value;
|
|
166
126
|
}
|
|
167
|
-
/** What the lists of a page give as computed fields: what its classes give (PRO-2, PRO-3), then what the formulas of its items' pages work out (PRO-5). */
|
|
168
|
-
function givenFields(world, scope, explained = false) {
|
|
169
|
-
return [...progressionFields(world, scope), ...itemFields(world, scope, explained)];
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The fields the classes give as computed fields, each with the items it comes from (PRO-2, FOR-8): the values of their rows, then the features. A column named
|
|
173
|
-
* as a counter of the system is not one: it is that counter's maximum (DAT-9).
|
|
174
|
-
*/
|
|
175
|
-
function progressionFields(world, scope) {
|
|
176
|
-
const progression = scope.progression();
|
|
177
|
-
if (progression === undefined) {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
const values = progression.values.filter((value) => !isSystemCounter(world, value.field)).map((value) => ({
|
|
181
|
-
field: value.field,
|
|
182
|
-
value: value.value,
|
|
183
|
-
reads: value.from.map((from) => ({ list: progression.lists[0], item: from.name, value: from.level })),
|
|
184
|
-
}));
|
|
185
|
-
const features = progression.features.length + progression.written.length === 0 ? [] : [{
|
|
186
|
-
field: progression.featuresField,
|
|
187
|
-
value: [...progression.features.map((feature) => feature.name), ...progression.written].join(", "),
|
|
188
|
-
reads: progression.from.map((from) => ({ list: from.list, item: from.name, value: from.level ?? 1 })),
|
|
189
|
-
}];
|
|
190
|
-
return [...values, ...features];
|
|
191
|
-
}
|
|
192
|
-
/** The fields the formulas of the items' pages give, one value for each item, for every list the system names (PRO-5). */
|
|
193
|
-
function itemFields(world, scope, explained) {
|
|
194
|
-
return Object.values(world.system?.itemFormulas ?? {}).flat().flatMap((field) => {
|
|
195
|
-
const worked = scope.each(field, explained);
|
|
196
|
-
// A bonus an item gives as nothing, as the speed a heavy armor takes from who has its Strength, says nothing (FOR-8).
|
|
197
|
-
return worked === undefined || (worked.value === 0 && declaredKind(world, field) === "bonus") ? [] : [worked];
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
127
|
/** The list whose items' pages give a field as a formula, as classes for spell-save-dc (PRO-5); undefined when none does. */
|
|
201
128
|
export function itemList(world, field) {
|
|
202
129
|
return Object.entries(world.system?.itemFormulas ?? {}).find(([, names]) => names.some((name) => comparableText(name) === comparableText(field.trim())))?.[0];
|
|
203
130
|
}
|
|
204
|
-
/**
|
|
205
|
-
* A formula that each item of its list gives on its page, such as a class's spell-save-dc or a weapon's attack, worked out on who lists them for each item that
|
|
206
|
-
* gives one (PRO-5): a number, or a roll as text, for one; "Cleric 13, Wizard 12" for several. Undefined when none gives it.
|
|
207
|
-
*/
|
|
208
|
-
function eachItem(world, field, items) {
|
|
209
|
-
if (items.length === 0) {
|
|
210
|
-
return undefined;
|
|
211
|
-
}
|
|
212
|
-
const [first] = items;
|
|
213
|
-
return items.length === 1
|
|
214
|
-
? { field, value: first.value, reads: first.reads }
|
|
215
|
-
: { field, value: items.map((item) => `${item.name} ${signedText(world, field, item.value)}`).join(", "), reads: items.flatMap((item) => item.reads) };
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* What a field gives for each item of its list whose page gives it (PRO-5): a number, or a roll as text, as "1d8+3 slashing". The formula reads first the
|
|
219
|
-
* item's own fields, as a magic weapon's bonus, then those of who lists it.
|
|
220
|
-
*/
|
|
221
|
-
function itemValues(world, scope, field, explained) {
|
|
222
|
-
const list = itemList(world, field);
|
|
223
|
-
if (list === undefined) {
|
|
224
|
-
return [];
|
|
225
|
-
}
|
|
226
|
-
return listItems(scope.field(list)).flatMap((item) => {
|
|
227
|
-
const page = scope.page(item.name);
|
|
228
|
-
const given = itemFormula(page, field);
|
|
229
|
-
if (page === undefined || given === undefined) {
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
const own = itemScope(world, scope, page, list);
|
|
233
|
-
const worked = given.formula === undefined ? undefined : workOut(given.formula, own);
|
|
234
|
-
// The dice it takes, as the Martial Arts die of a monk when it is larger (D-235); none of its choices with a value, no value.
|
|
235
|
-
const dice = given.dice === undefined ? undefined : chosenDice(given.dice, own);
|
|
236
|
-
if ((given.formula !== undefined && worked?.value === undefined) || (given.dice !== undefined && dice === undefined)) {
|
|
237
|
-
return [];
|
|
238
|
-
}
|
|
239
|
-
const reads = worked === undefined || given.formula === undefined ? [] : explained ? contributingReads(given.formula, own, worked) : worked.reads;
|
|
240
|
-
return [{ name: item.name, value: rollValue(given, dice, worked?.value), reads: [...(dice?.reads ?? []), ...reads] }];
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* "1d8+3 slashing": a roll's dice, the number its formula works out, unless 0, and its words; the number alone for a plain formula. Dice that are a number, as an
|
|
245
|
-
* unarmed strike's 1, add to it: "4 bludgeoning" (D-235).
|
|
246
|
-
*/
|
|
247
|
-
function rollValue(given, dice, value) {
|
|
248
|
-
const rolled = dice?.dice;
|
|
249
|
-
const total = dice?.number === undefined ? value : (value ?? 0) + dice.number;
|
|
250
|
-
if (rolled === undefined && given.words === undefined && total !== undefined) {
|
|
251
|
-
return total;
|
|
252
|
-
}
|
|
253
|
-
const number = total === undefined || (total === 0 && rolled !== undefined) ? "" : rolled === undefined ? String(total) : total > 0 ? `+${total}` : String(total);
|
|
254
|
-
return `${rolled ?? ""}${number}${given.words === undefined ? "" : ` ${given.words}`}`;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* The scope of an item's formula: the item's own fields first, as a magic weapon's bonus, written 1 or +1, then those of who lists it (PRO-5). The formulas
|
|
258
|
-
* the item gives for its list are worked out on who lists it: a monk's Unarmored Defense reads the armor-class-bonus of the shield it has equipped.
|
|
259
|
-
*/
|
|
260
|
-
function itemScope(world, scope, page, list) {
|
|
261
|
-
const given = world.system?.itemFormulas?.[list] ?? [];
|
|
262
|
-
return {
|
|
263
|
-
...scope,
|
|
264
|
-
field: (name) => {
|
|
265
|
-
const key = keyOf(page, name);
|
|
266
|
-
if (key === undefined || isEmptyField(page[key]) || given.some((field) => comparableText(field) === comparableText(name))) {
|
|
267
|
-
return scope.field(name);
|
|
268
|
-
}
|
|
269
|
-
return numberOf(page[key]) ?? page[key];
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
/** The formula an item's page gives in a field, read once for each text; undefined when it gives none, or one that does not read, which validate reports (PRO-5). */
|
|
274
|
-
function itemFormula(fields, field) {
|
|
275
|
-
const text = fields === undefined ? undefined : fields[keyOf(fields, field) ?? ""];
|
|
276
|
-
if (typeof text !== "string" && typeof text !== "number") {
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
const key = String(text);
|
|
280
|
-
if (!itemFormulas.has(key)) {
|
|
281
|
-
try {
|
|
282
|
-
itemFormulas.set(key, parseRollFormula(key));
|
|
283
|
-
}
|
|
284
|
-
catch {
|
|
285
|
-
itemFormulas.set(key, undefined);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return itemFormulas.get(key);
|
|
289
|
-
}
|
|
290
|
-
const itemFormulas = new Map();
|
|
291
131
|
/**
|
|
292
132
|
* Each item of a list with what the formulas of its page give, field by field, in the order of the list, for a sheet that shows them item by item, as the
|
|
293
133
|
* attacks of the weapons a character has equipped (PRO-5).
|
|
@@ -301,29 +141,6 @@ export function itemLines(world, fields, list, names, explained = false) {
|
|
|
301
141
|
return values.length === 0 ? [] : [{ item, values }];
|
|
302
142
|
});
|
|
303
143
|
}
|
|
304
|
-
/** A field the classes give, as a computed field that cannot be written, with the lists it comes from (PRO-2, FOR-7); undefined for any other field. */
|
|
305
|
-
function progressedField(world, scope, field) {
|
|
306
|
-
const found = givenFields(world, scope).find((worked) => comparableText(worked.field) === comparableText(field.trim()));
|
|
307
|
-
const list = found === undefined ? undefined : itemList(world, found.field);
|
|
308
|
-
// The features are written too, beside those the rows give (PRO-3).
|
|
309
|
-
if (found === undefined || comparableText(found.field) === comparableText(scope.progression()?.featuresField ?? "")) {
|
|
310
|
-
return undefined;
|
|
311
|
-
}
|
|
312
|
-
// A formula of the items' pages comes from what it reads, as the bonus an item gives, and from its list (PRO-5); the rows, from the lists alone.
|
|
313
|
-
if (list !== undefined) {
|
|
314
|
-
const read = listItems(scope.field(list)).flatMap((item) => {
|
|
315
|
-
const page = scope.page(item.name);
|
|
316
|
-
const given = itemFormula(page, found.field);
|
|
317
|
-
// What the item holds itself, as a weapon's bonus, comes from it, not from who lists it.
|
|
318
|
-
// Only the dice a field gives count, as a monk's martial-arts: one no one has is no source.
|
|
319
|
-
const dice = (given === undefined ? [] : diceFields(given)).filter((name) => scope.field(name) !== undefined).flatMap((name) => writtenSources(world, { kind: "field", name }, scope));
|
|
320
|
-
const formula = given?.formula === undefined ? [] : writtenSources(world, given.formula, scope);
|
|
321
|
-
return [...formula, ...dice].filter((name) => page === undefined || keyOf(page, name) === undefined);
|
|
322
|
-
});
|
|
323
|
-
return { name: found.field, value: found.value, from: [...new Set([...read, list])] };
|
|
324
|
-
}
|
|
325
|
-
return { name: found.field, value: found.value, from: scope.progression()?.lists ?? [] };
|
|
326
|
-
}
|
|
327
144
|
/** The minimum and maximum the game system works out for a counter with these fields, where they have a whole value (FOR-6). */
|
|
328
145
|
export function counterLimits(world, fields, field) {
|
|
329
146
|
const limits = Object.entries(world.system?.formulas?.counters ?? {}).find(([name]) => comparableText(name) === comparableText(field.trim()))?.[1];
|
|
@@ -332,18 +149,6 @@ export function counterLimits(world, fields, field) {
|
|
|
332
149
|
}
|
|
333
150
|
return limitsIn(formulaScope(world, fields), limits, field);
|
|
334
151
|
}
|
|
335
|
-
/** The limits of a counter worked out in a scope, where they have a whole value (FOR-6); without a max formula, the column of a class's row (DAT-9). */
|
|
336
|
-
function limitsIn(scope, limits, field) {
|
|
337
|
-
const whole = (worked) => (worked?.value !== undefined && Number.isSafeInteger(worked.value) ? worked.value : undefined);
|
|
338
|
-
const min = whole(limits.min === undefined ? undefined : workOut(limits.min, scope));
|
|
339
|
-
const row = limits.max === undefined ? numberOf(progressionValue(scope.progression(), field)) : undefined;
|
|
340
|
-
const max = limits.max === undefined ? (row !== undefined && Number.isSafeInteger(row) ? row : undefined) : whole(workOut(limits.max, scope));
|
|
341
|
-
return { ...(min === undefined ? {} : { min }), ...(max === undefined ? {} : { max: atLeastZero(max) }) };
|
|
342
|
-
}
|
|
343
|
-
/** A maximum worked out below 0, as 1 + cha-mod with Charisma 7, is 0: a counter is never written with a maximum below 0 (FOR-6). */
|
|
344
|
-
function atLeastZero(max) {
|
|
345
|
-
return Math.max(0, max);
|
|
346
|
-
}
|
|
347
152
|
/**
|
|
348
153
|
* The name, as the game system declares it, of a counter that starts at 0 where a page does not hold it yet, as temporary hit points or experience points:
|
|
349
154
|
* declared a counter, with no maximum and not a use that comes back with a rest (CNT-8, D-266). Undefined for any other.
|
|
@@ -387,36 +192,6 @@ export function maximumHint(world, fields, field) {
|
|
|
387
192
|
const [raise] = worked.value === 0 ? [] : maximumSources(world, field, fields).filter((name) => declaredKind(world, name) !== "list");
|
|
388
193
|
return { made: `${worked.value}${parts === "" ? "" : `, from ${parts}`}`, ...(raise === undefined ? {} : { raise }) };
|
|
389
194
|
}
|
|
390
|
-
/**
|
|
391
|
-
* The written fields a formula comes from, through the computed fields it reads that have a value: what can be changed, as wis for passive-perception, and
|
|
392
|
-
* level where the page writes it, having no classes (FOR-7).
|
|
393
|
-
*/
|
|
394
|
-
function writtenSources(world, formula, scope, seen = new Set()) {
|
|
395
|
-
const formulas = world.system?.formulas;
|
|
396
|
-
const index = formulas === undefined ? undefined : formulaIndex(formulas);
|
|
397
|
-
const sources = fieldsRead(formula).flatMap((name) => {
|
|
398
|
-
const entry = index?.computed.get(comparableText(name));
|
|
399
|
-
// What the classes give comes from the lists that name them (PRO-3); what the items' pages give, from their list, as armor-class from equipped (PRO-5).
|
|
400
|
-
// Whether the classes or the items give it, without asking where they come from, which may read this field again.
|
|
401
|
-
if (entry === undefined && givenFields(world, scope).some((worked) => comparableText(worked.field) === comparableText(name))) {
|
|
402
|
-
const list = itemList(world, name);
|
|
403
|
-
return list === undefined ? (scope.progression()?.lists ?? [name]) : [list];
|
|
404
|
-
}
|
|
405
|
-
// What the engine gives a formula, as the campaign's rigor or a character's load, is no field anyone writes (FOR-2).
|
|
406
|
-
if (["rigor", "effects", "load", "load-limit"].includes(comparableText(name))) {
|
|
407
|
-
return [];
|
|
408
|
-
}
|
|
409
|
-
if (entry === undefined || scope.computed(name)?.value === undefined) {
|
|
410
|
-
return [name];
|
|
411
|
-
}
|
|
412
|
-
if (seen.has(comparableText(name))) {
|
|
413
|
-
return [];
|
|
414
|
-
}
|
|
415
|
-
seen.add(comparableText(name));
|
|
416
|
-
return writtenSources(world, entry[1], scope, seen);
|
|
417
|
-
});
|
|
418
|
-
return sources.filter((name, position) => sources.findIndex((other) => comparableText(other) === comparableText(name)) === position);
|
|
419
|
-
}
|
|
420
195
|
/** Why a computed field is not written or changed, and what to change instead: the fields it comes from, or an effect on a bonus among them (FOR-7). */
|
|
421
196
|
export function computedMessage(world, computed, page) {
|
|
422
197
|
const bonuses = directBonuses(world, computed);
|
|
@@ -433,13 +208,6 @@ export function aloneNote(world, field, bonuses) {
|
|
|
433
208
|
const one = shared.length === 1;
|
|
434
209
|
return shared.length === 0 ? "" : `; ${shared.join(" and ")} also ${one ? "changes" : "change"} the other fields that read ${one ? "it" : "them"}, so for ${field} alone add the number to its roll`;
|
|
435
210
|
}
|
|
436
|
-
/**
|
|
437
|
-
* The bonus fields among those a computed field comes from, which an effect on the page gives to change it, as bonus-ac for ac (FOR-5); not those the items of a
|
|
438
|
-
* list give, as a shield's armor-class-bonus, which change on the item (PRO-5).
|
|
439
|
-
*/
|
|
440
|
-
export function effectBonuses(world, from) {
|
|
441
|
-
return from.filter((field) => declaredKind(world, field) === "bonus" && itemList(world, field) === undefined);
|
|
442
|
-
}
|
|
443
211
|
/** The bonus fields an effect gives to change a computed field that its formula reads itself, as bonus-skills for insight, not bonus-proficiency through proficiency. */
|
|
444
212
|
export function directBonuses(world, computed) {
|
|
445
213
|
return effectBonuses(world, computed.from).filter((field) => computed.direct?.some((name) => comparableText(name) === comparableText(field)) === true);
|
|
@@ -575,6 +343,238 @@ export function workedOutProblems(world) {
|
|
|
575
343
|
checkedWorlds.set(world, problems);
|
|
576
344
|
return problems;
|
|
577
345
|
}
|
|
346
|
+
function effectValuesOver(world, page) {
|
|
347
|
+
const fields = { ...inheritedFields(world, page) };
|
|
348
|
+
const read = readEffects(Object.entries(page.fields).find(([field]) => comparableText(field) === "effects")?.[1]);
|
|
349
|
+
// What the pages of the system's bonus lists give, as a Ring of Protection one is attuned to or a feat, adds up as effects do (FOR-5, D-449); an at-least
|
|
350
|
+
// field rises to theirs, as Gauntlets of Ogre Power's str 19, and stays when higher.
|
|
351
|
+
for (const page of bonusPages(world, fields)) {
|
|
352
|
+
for (const [field, value] of Object.entries(inheritedFields(world, page))) {
|
|
353
|
+
const kind = declaredKind(world, field);
|
|
354
|
+
const amount = kind === "bonus" || kind === "at-least" ? numberOf(value) : undefined;
|
|
355
|
+
const key = keyOf(fields, field) ?? field;
|
|
356
|
+
const current = numberOf(fields[key]);
|
|
357
|
+
fields[key] = amount === undefined ? fields[key] : kind === "bonus" ? (current ?? 0) + amount : Math.max(current ?? amount, amount);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
for (const effect of "effects" in read ? read.effects : []) {
|
|
361
|
+
for (const [field, value] of effect.values) {
|
|
362
|
+
const key = keyOf(fields, field) ?? field;
|
|
363
|
+
const kind = declaredKind(world, field);
|
|
364
|
+
fields[key] = kind === "bonus"
|
|
365
|
+
? (numberOf(fields[key]) ?? 0) + (numberOf(effectValue(value)) ?? 0)
|
|
366
|
+
: kind === "factor"
|
|
367
|
+
? (factorOf(fields[key]) ?? 1) * (factorOf(value) ?? 1)
|
|
368
|
+
: effectValue(value);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// What a character carries weighs, for the formulas that read it as load, as a speed; under a key no list of fields shows (FOR-2, LOAD-1).
|
|
372
|
+
if (page.type === "character" && world.system?.load !== undefined) {
|
|
373
|
+
fields[carriedKey] = carriedWeight(world, world.system.load, page);
|
|
374
|
+
}
|
|
375
|
+
return fields;
|
|
376
|
+
}
|
|
377
|
+
/** A value of an effect as a page would hold it: a number, a link, a counter as text; text as it is when it does not read. */
|
|
378
|
+
function effectValue(value) {
|
|
379
|
+
try {
|
|
380
|
+
return readFieldValue(value);
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
return value;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/** What the lists of a page give as computed fields: what its classes give (PRO-2, PRO-3), then what the formulas of its items' pages work out (PRO-5). */
|
|
387
|
+
function givenFields(world, scope, explained = false) {
|
|
388
|
+
return [...progressionFields(world, scope), ...itemFields(world, scope, explained)];
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* The fields the classes give as computed fields, each with the items it comes from (PRO-2, FOR-8): the values of their rows, then the features. A column named
|
|
392
|
+
* as a counter of the system is not one: it is that counter's maximum (DAT-9).
|
|
393
|
+
*/
|
|
394
|
+
function progressionFields(world, scope) {
|
|
395
|
+
const progression = scope.progression();
|
|
396
|
+
if (progression === undefined) {
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
const values = progression.values.filter((value) => !isSystemCounter(world, value.field)).map((value) => ({
|
|
400
|
+
field: value.field,
|
|
401
|
+
value: value.value,
|
|
402
|
+
reads: value.from.map((from) => ({ list: progression.lists[0], item: from.name, value: from.level })),
|
|
403
|
+
}));
|
|
404
|
+
const features = progression.features.length + progression.written.length === 0 ? [] : [{
|
|
405
|
+
field: progression.featuresField,
|
|
406
|
+
value: [...progression.features.map((feature) => feature.name), ...progression.written].join(", "),
|
|
407
|
+
reads: progression.from.map((from) => ({ list: from.list, item: from.name, value: from.level ?? 1 })),
|
|
408
|
+
}];
|
|
409
|
+
return [...values, ...features];
|
|
410
|
+
}
|
|
411
|
+
/** The fields the formulas of the items' pages give, one value for each item, for every list the system names (PRO-5). */
|
|
412
|
+
function itemFields(world, scope, explained) {
|
|
413
|
+
return Object.values(world.system?.itemFormulas ?? {}).flat().flatMap((field) => {
|
|
414
|
+
const worked = scope.each(field, explained);
|
|
415
|
+
// A bonus an item gives as nothing, as the speed a heavy armor takes from who has its Strength, says nothing (FOR-8).
|
|
416
|
+
return worked === undefined || (worked.value === 0 && declaredKind(world, field) === "bonus") ? [] : [worked];
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A formula that each item of its list gives on its page, such as a class's spell-save-dc or a weapon's attack, worked out on who lists them for each item that
|
|
421
|
+
* gives one (PRO-5): a number, or a roll as text, for one; "Cleric 13, Wizard 12" for several. Undefined when none gives it.
|
|
422
|
+
*/
|
|
423
|
+
function eachItem(world, field, items) {
|
|
424
|
+
if (items.length === 0) {
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
427
|
+
const [first] = items;
|
|
428
|
+
return items.length === 1
|
|
429
|
+
? { field, value: first.value, reads: first.reads }
|
|
430
|
+
: { field, value: items.map((item) => `${item.name} ${signedText(world, field, item.value)}`).join(", "), reads: items.flatMap((item) => item.reads) };
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* What a field gives for each item of its list whose page gives it (PRO-5): a number, or a roll as text, as "1d8+3 slashing". The formula reads first the
|
|
434
|
+
* item's own fields, as a magic weapon's bonus, then those of who lists it.
|
|
435
|
+
*/
|
|
436
|
+
function itemValues(world, scope, field, explained) {
|
|
437
|
+
const list = itemList(world, field);
|
|
438
|
+
if (list === undefined) {
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
return listItems(scope.field(list)).flatMap((item) => {
|
|
442
|
+
const page = scope.page(item.name);
|
|
443
|
+
const given = itemFormula(page, field);
|
|
444
|
+
if (page === undefined || given === undefined) {
|
|
445
|
+
return [];
|
|
446
|
+
}
|
|
447
|
+
const own = itemScope(world, scope, page, list);
|
|
448
|
+
const worked = given.formula === undefined ? undefined : workOut(given.formula, own);
|
|
449
|
+
// The dice it takes, as the Martial Arts die of a monk when it is larger (D-235); none of its choices with a value, no value.
|
|
450
|
+
const dice = given.dice === undefined ? undefined : chosenDice(given.dice, own);
|
|
451
|
+
if ((given.formula !== undefined && worked?.value === undefined) || (given.dice !== undefined && dice === undefined)) {
|
|
452
|
+
return [];
|
|
453
|
+
}
|
|
454
|
+
const reads = worked === undefined || given.formula === undefined ? [] : explained ? contributingReads(given.formula, own, worked) : worked.reads;
|
|
455
|
+
return [{ name: item.name, value: rollValue(given, dice, worked?.value), reads: [...(dice?.reads ?? []), ...reads] }];
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* "1d8+3 slashing": a roll's dice, the number its formula works out, unless 0, and its words; the number alone for a plain formula. Dice that are a number, as an
|
|
460
|
+
* unarmed strike's 1, add to it: "4 bludgeoning" (D-235).
|
|
461
|
+
*/
|
|
462
|
+
function rollValue(given, dice, value) {
|
|
463
|
+
const rolled = dice?.dice;
|
|
464
|
+
const total = dice?.number === undefined ? value : (value ?? 0) + dice.number;
|
|
465
|
+
if (rolled === undefined && given.words === undefined && total !== undefined) {
|
|
466
|
+
return total;
|
|
467
|
+
}
|
|
468
|
+
const number = total === undefined || (total === 0 && rolled !== undefined) ? "" : rolled === undefined ? String(total) : total > 0 ? `+${total}` : String(total);
|
|
469
|
+
return `${rolled ?? ""}${number}${given.words === undefined ? "" : ` ${given.words}`}`;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* The scope of an item's formula: the item's own fields first, as a magic weapon's bonus, written 1 or +1, then those of who lists it (PRO-5). The formulas
|
|
473
|
+
* the item gives for its list are worked out on who lists it: a monk's Unarmored Defense reads the armor-class-bonus of the shield it has equipped.
|
|
474
|
+
*/
|
|
475
|
+
function itemScope(world, scope, page, list) {
|
|
476
|
+
const given = world.system?.itemFormulas?.[list] ?? [];
|
|
477
|
+
return {
|
|
478
|
+
...scope,
|
|
479
|
+
field: (name) => {
|
|
480
|
+
const key = keyOf(page, name);
|
|
481
|
+
if (key === undefined || isEmptyField(page[key]) || given.some((field) => comparableText(field) === comparableText(name))) {
|
|
482
|
+
return scope.field(name);
|
|
483
|
+
}
|
|
484
|
+
return numberOf(page[key]) ?? page[key];
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
/** The formula an item's page gives in a field, read once for each text; undefined when it gives none, or one that does not read, which validate reports (PRO-5). */
|
|
489
|
+
function itemFormula(fields, field) {
|
|
490
|
+
const text = fields === undefined ? undefined : fields[keyOf(fields, field) ?? ""];
|
|
491
|
+
if (typeof text !== "string" && typeof text !== "number") {
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
const key = String(text);
|
|
495
|
+
if (!itemFormulas.has(key)) {
|
|
496
|
+
try {
|
|
497
|
+
itemFormulas.set(key, parseRollFormula(key));
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
itemFormulas.set(key, undefined);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return itemFormulas.get(key);
|
|
504
|
+
}
|
|
505
|
+
const itemFormulas = new Map();
|
|
506
|
+
/** A field the classes give, as a computed field that cannot be written, with the lists it comes from (PRO-2, FOR-7); undefined for any other field. */
|
|
507
|
+
function progressedField(world, scope, field) {
|
|
508
|
+
const found = givenFields(world, scope).find((worked) => comparableText(worked.field) === comparableText(field.trim()));
|
|
509
|
+
const list = found === undefined ? undefined : itemList(world, found.field);
|
|
510
|
+
// The features are written too, beside those the rows give (PRO-3).
|
|
511
|
+
if (found === undefined || comparableText(found.field) === comparableText(scope.progression()?.featuresField ?? "")) {
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
// A formula of the items' pages comes from what it reads, as the bonus an item gives, and from its list (PRO-5); the rows, from the lists alone.
|
|
515
|
+
if (list !== undefined) {
|
|
516
|
+
const read = listItems(scope.field(list)).flatMap((item) => {
|
|
517
|
+
const page = scope.page(item.name);
|
|
518
|
+
const given = itemFormula(page, found.field);
|
|
519
|
+
// What the item holds itself, as a weapon's bonus, comes from it, not from who lists it.
|
|
520
|
+
// Only the dice a field gives count, as a monk's martial-arts: one no one has is no source.
|
|
521
|
+
const dice = (given === undefined ? [] : diceFields(given)).filter((name) => scope.field(name) !== undefined).flatMap((name) => writtenSources(world, { kind: "field", name }, scope));
|
|
522
|
+
const formula = given?.formula === undefined ? [] : writtenSources(world, given.formula, scope);
|
|
523
|
+
return [...formula, ...dice].filter((name) => page === undefined || keyOf(page, name) === undefined);
|
|
524
|
+
});
|
|
525
|
+
return { name: found.field, value: found.value, from: [...new Set([...read, list])] };
|
|
526
|
+
}
|
|
527
|
+
return { name: found.field, value: found.value, from: scope.progression()?.lists ?? [] };
|
|
528
|
+
}
|
|
529
|
+
/** The limits of a counter worked out in a scope, where they have a whole value (FOR-6); without a max formula, the column of a class's row (DAT-9). */
|
|
530
|
+
function limitsIn(scope, limits, field) {
|
|
531
|
+
const whole = (worked) => (worked?.value !== undefined && Number.isSafeInteger(worked.value) ? worked.value : undefined);
|
|
532
|
+
const min = whole(limits.min === undefined ? undefined : workOut(limits.min, scope));
|
|
533
|
+
const row = limits.max === undefined ? numberOf(progressionValue(scope.progression(), field)) : undefined;
|
|
534
|
+
const max = limits.max === undefined ? (row !== undefined && Number.isSafeInteger(row) ? row : undefined) : whole(workOut(limits.max, scope));
|
|
535
|
+
return { ...(min === undefined ? {} : { min }), ...(max === undefined ? {} : { max: atLeastZero(max) }) };
|
|
536
|
+
}
|
|
537
|
+
/** A maximum worked out below 0, as 1 + cha-mod with Charisma 7, is 0: a counter is never written with a maximum below 0 (FOR-6). */
|
|
538
|
+
function atLeastZero(max) {
|
|
539
|
+
return Math.max(0, max);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* The written fields a formula comes from, through the computed fields it reads that have a value: what can be changed, as wis for passive-perception, and
|
|
543
|
+
* level where the page writes it, having no classes (FOR-7).
|
|
544
|
+
*/
|
|
545
|
+
function writtenSources(world, formula, scope, seen = new Set()) {
|
|
546
|
+
const formulas = world.system?.formulas;
|
|
547
|
+
const index = formulas === undefined ? undefined : formulaIndex(formulas);
|
|
548
|
+
const sources = fieldsRead(formula).flatMap((name) => {
|
|
549
|
+
const entry = index?.computed.get(comparableText(name));
|
|
550
|
+
// What the classes give comes from the lists that name them (PRO-3); what the items' pages give, from their list, as armor-class from equipped (PRO-5).
|
|
551
|
+
// Whether the classes or the items give it, without asking where they come from, which may read this field again.
|
|
552
|
+
if (entry === undefined && givenFields(world, scope).some((worked) => comparableText(worked.field) === comparableText(name))) {
|
|
553
|
+
const list = itemList(world, name);
|
|
554
|
+
return list === undefined ? (scope.progression()?.lists ?? [name]) : [list];
|
|
555
|
+
}
|
|
556
|
+
// What the engine gives a formula, as the campaign's rigor or a character's load, is no field anyone writes (FOR-2).
|
|
557
|
+
if (["rigor", "effects", "load", "load-limit"].includes(comparableText(name))) {
|
|
558
|
+
return [];
|
|
559
|
+
}
|
|
560
|
+
if (entry === undefined || scope.computed(name)?.value === undefined) {
|
|
561
|
+
return [name];
|
|
562
|
+
}
|
|
563
|
+
if (seen.has(comparableText(name))) {
|
|
564
|
+
return [];
|
|
565
|
+
}
|
|
566
|
+
seen.add(comparableText(name));
|
|
567
|
+
return writtenSources(world, entry[1], scope, seen);
|
|
568
|
+
});
|
|
569
|
+
return sources.filter((name, position) => sources.findIndex((other) => comparableText(other) === comparableText(name)) === position);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* The bonus fields among those a computed field comes from, which an effect on the page gives to change it, as bonus-ac for ac (FOR-5); not those the items of a
|
|
573
|
+
* list give, as a shield's armor-class-bonus, which change on the item (PRO-5).
|
|
574
|
+
*/
|
|
575
|
+
function effectBonuses(world, from) {
|
|
576
|
+
return from.filter((field) => declaredKind(world, field) === "bonus" && itemList(world, field) === undefined);
|
|
577
|
+
}
|
|
578
578
|
const checkedWorlds = new WeakMap();
|
|
579
579
|
/**
|
|
580
580
|
* A formula an item's page gives that who lists it can have no value from (PRO-5): one that does not read, that reads itself, a table the system lacks or a name
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type CountedByGame } from "
|
|
2
|
-
import type { Context } from "
|
|
3
|
-
import type { Problem } from "
|
|
4
|
-
import { type PageType, type World } from "
|
|
5
|
-
import { type CampaignData, type GameSystem, type SystemLayer, type SystemSetting, type SystemWords } from "
|
|
1
|
+
import { type CountedByGame } from "../../campaign/index.ts";
|
|
2
|
+
import type { Context } from "../../core/context.ts";
|
|
3
|
+
import type { Problem } from "../../core/problem.ts";
|
|
4
|
+
import { type PageType, type World } from "../../pages/index.ts";
|
|
5
|
+
import { type CampaignData, type GameSystem, type SystemLayer, type SystemSetting, type SystemWords } from "../../systems/index.ts";
|
|
6
6
|
/** The world of the campaign in `root`, with the pages of its game system when campaign.yaml names one that is installed (SYS-1, SYS-3). */
|
|
7
7
|
export declare function campaignWorld(root: string, context: Context): World;
|
|
8
8
|
/**
|
|
@@ -22,13 +22,6 @@ export declare function campaignSystemWords(root: string, context: Context): Rec
|
|
|
22
22
|
export declare function campaignSystem(root: string, context: Context): GameSystem | undefined;
|
|
23
23
|
/** What the campaign's extensions add to its game system, in the order campaign.yaml lists them, then the campaign's own additions, which win (CAM-2). */
|
|
24
24
|
export declare function systemLayers(root: string, context: Context, campaign: CampaignData): SystemLayer[];
|
|
25
|
-
/** The layers over the campaign's system that it plays with, in order, and by name those left out because the system would not read with them (CAM-3). */
|
|
26
|
-
export declare function playedLayers(root: string, context: Context): {
|
|
27
|
-
kept: SystemLayer[];
|
|
28
|
-
refused: string[];
|
|
29
|
-
};
|
|
30
|
-
/** The name of an extension's layer of additions, as messages give it. */
|
|
31
|
-
export declare function extensionLayer(name: string): string;
|
|
32
25
|
/** A setting the campaign's game system adds to the setup (DAT-10), by its name in any case; undefined when the system has none by that name. */
|
|
33
26
|
export declare function systemSetting(root: string, context: Context, name: string): SystemSetting | undefined;
|
|
34
27
|
/**
|
|
@@ -38,8 +31,6 @@ export declare function systemSetting(root: string, context: Context, name: stri
|
|
|
38
31
|
export declare function playedSettingValue(root: string, context: Context, setting: SystemSetting): string | undefined;
|
|
39
32
|
/** The names of the player characters the game has begun with (D-519): from the first, the campaign keeps its system and the version of its rules (SYS-9, VER-4). */
|
|
40
33
|
export declare function playersOfTheGame(root: string, context: Context): string[];
|
|
41
|
-
/** The value campaign.yaml gives a setting of the system, when it is one the system has (DAT-10). */
|
|
42
|
-
export declare function systemSettingValue(root: string, setting: SystemSetting): string | undefined;
|
|
43
34
|
/** "xp is not kept with advancement milestones": said when a field the campaign's settings leave out is written or changed (DAT-10); undefined for any other. */
|
|
44
35
|
export declare function leftOutNote(root: string, context: Context, field: string): string | undefined;
|
|
45
36
|
/** A setting of the system written by hand with a value the system does not have (DAT-10): what it takes instead. */
|