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,10 +1,10 @@
|
|
|
1
1
|
// The stacks of goods (D-429, STK-1–STK-4): which items are kinds, what a container counts of each, and which stack a holder means.
|
|
2
|
-
import { comparableText, withArticle } from "
|
|
3
|
-
import { baseChain, inheritedFields } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { comparableText, withArticle } from "../../core/text.js";
|
|
3
|
+
import { baseChain, inheritedFields } from "../inheritance.js";
|
|
4
|
+
import { containerFieldOf } from "../standard-fields.js";
|
|
5
|
+
import { alwaysInList, isDeclaredUncounted } from "../system-pages.js";
|
|
6
|
+
import { heldNames, isCountedItem, pageNamed, pagesWithName, systemPageNamed, textsIn, validHoldersOf } from "../world.js";
|
|
7
|
+
import { countedText, readEntry } from "./entry.js";
|
|
8
8
|
// A counter with a maximum, as uses: 10/10: what a thing of its own spends, which a stack cannot keep (STK-1).
|
|
9
9
|
const usesPattern = /^\s*-?\d+\s*\/\s*\d+\s*$/;
|
|
10
10
|
/**
|
|
@@ -75,22 +75,10 @@ export function heldStacks(world, holder, kind) {
|
|
|
75
75
|
if (own !== undefined) {
|
|
76
76
|
return [{ container: holder, stack: own }];
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const next = [];
|
|
83
|
-
for (const item of level.filter((page) => !seen.has(page))) {
|
|
84
|
-
seen.add(item);
|
|
85
|
-
const stack = ownStack(world, item, kind);
|
|
86
|
-
if (stack !== undefined) {
|
|
87
|
-
found.push({ container: item, stack });
|
|
88
|
-
}
|
|
89
|
-
next.push(...itemsHeldBy(world, item));
|
|
90
|
-
}
|
|
91
|
-
level = next;
|
|
92
|
-
}
|
|
93
|
-
return found;
|
|
78
|
+
return itemsWithin(world, holder).flatMap((item) => {
|
|
79
|
+
const stack = ownStack(world, item, kind);
|
|
80
|
+
return stack === undefined ? [] : [{ container: item, stack }];
|
|
81
|
+
});
|
|
94
82
|
}
|
|
95
83
|
/**
|
|
96
84
|
* The stacks a holder keeps of a kind or of a kind that derives from it, as the campaign's Razioni from the system's Rations (UPK-1): its own first, then
|
|
@@ -98,25 +86,22 @@ export function heldStacks(world, holder, kind) {
|
|
|
98
86
|
*/
|
|
99
87
|
export function heldStacksOfKind(world, holder, kind) {
|
|
100
88
|
const derives = (candidate) => candidate === kind || baseChain(world, candidate).includes(kind);
|
|
101
|
-
|
|
102
|
-
const found = [...own];
|
|
103
|
-
const seen = new Set([holder]);
|
|
104
|
-
let level = itemsHeldBy(world, holder);
|
|
105
|
-
while (level.length > 0) {
|
|
106
|
-
const next = [];
|
|
107
|
-
for (const item of level.filter((page) => !seen.has(page))) {
|
|
108
|
-
seen.add(item);
|
|
109
|
-
found.push(...stacksOf(world, item).filter((stack) => derives(stack.kind)).map((stack) => ({ container: item, stack })));
|
|
110
|
-
next.push(...itemsHeldBy(world, item));
|
|
111
|
-
}
|
|
112
|
-
level = next;
|
|
113
|
-
}
|
|
114
|
-
return found;
|
|
89
|
+
return [holder, ...itemsWithin(world, holder)].flatMap((container) => stacksOf(world, container).filter((stack) => derives(stack.kind)).map((stack) => ({ container, stack })));
|
|
115
90
|
}
|
|
116
91
|
/** Whether a character carries some of a kind, in its own list or inside what it carries (STK-11). */
|
|
117
92
|
export function carriesKind(world, character, kind) {
|
|
118
93
|
return heldStacks(world, character, kind).length > 0;
|
|
119
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether a holder carries a thing by a name, in its own list or inside what it carries: an item, a copy by its base, a stack by its kind, or text as on a paper
|
|
97
|
+
* sheet, its count aside; the names compared by same.
|
|
98
|
+
*/
|
|
99
|
+
export function carriesNamed(world, holder, name, same) {
|
|
100
|
+
return [holder, ...itemsWithin(world, holder)].some((container) => {
|
|
101
|
+
const field = containerFieldOf(container.type);
|
|
102
|
+
return (field === undefined ? [] : textsIn(container.fields[field])).some((entry) => entryNames(world, entry).some((one) => same(one, name)));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
120
105
|
/**
|
|
121
106
|
* The kind a name means for a holder (STK-4): a kind by its name or alias, or the label of an entry of the holder or of the items it holds, as torce for [[Torch|torce]] 7;
|
|
122
107
|
* undefined when it means none.
|
|
@@ -136,21 +121,31 @@ export function kindNamed(world, holder, name) {
|
|
|
136
121
|
export function goodsNamed(world, name) {
|
|
137
122
|
const spoken = name.trim().replace(/[-_]/g, " ");
|
|
138
123
|
const names = [...new Set([spoken, spoken.replace(/es$/i, ""), spoken.replace(/s$/i, "")])];
|
|
139
|
-
return names.map((candidate) =>
|
|
124
|
+
return names.map((candidate) => pageNamedQuietly(world, candidate)).find((page) => page !== undefined && (isKind(world, page) || canCount(world, page)));
|
|
140
125
|
}
|
|
141
126
|
/** The name a kind goes by in a stack: its label, else its own name (STK-12). */
|
|
142
127
|
export function stackName(stack) {
|
|
143
128
|
return stack.label ?? stack.kind.name;
|
|
144
129
|
}
|
|
145
|
-
/**
|
|
146
|
-
function
|
|
130
|
+
/** The page a name means, or undefined when it means none or two pages share it. */
|
|
131
|
+
export function pageNamedQuietly(world, name) {
|
|
147
132
|
try {
|
|
148
|
-
return
|
|
133
|
+
return pageNamed(world, name);
|
|
149
134
|
}
|
|
150
135
|
catch {
|
|
151
136
|
return undefined;
|
|
152
137
|
}
|
|
153
138
|
}
|
|
139
|
+
/** The names an entry of a container goes by: its page's, its bases' and its label; text by itself, its count aside. */
|
|
140
|
+
function entryNames(world, entry) {
|
|
141
|
+
const read = readEntry(entry);
|
|
142
|
+
if (read.shape === "text") {
|
|
143
|
+
return [countedText(entry)?.name ?? entry.trim()];
|
|
144
|
+
}
|
|
145
|
+
const page = entryPage(world, read.page);
|
|
146
|
+
const label = "label" in read && read.label !== undefined ? [read.label] : [];
|
|
147
|
+
return [...(page === undefined ? [read.page] : [page, ...baseChain(world, page)].map((one) => one.name)), ...label];
|
|
148
|
+
}
|
|
154
149
|
/** The items a container holds as pages, those whose first container it is (CON-3). */
|
|
155
150
|
function itemsHeldBy(world, container) {
|
|
156
151
|
return heldNames(container).flatMap((name) => pagesWithName(world, name).slice(0, 1)).filter((page) => page.type === "item" && validHoldersOf(world, page)[0] === container);
|
|
@@ -160,7 +155,7 @@ function itemsWithin(world, container) {
|
|
|
160
155
|
const found = [];
|
|
161
156
|
let level = itemsHeldBy(world, container);
|
|
162
157
|
while (level.length > 0) {
|
|
163
|
-
const fresh = level.filter((page) => page !== container && !found.includes(page));
|
|
158
|
+
const fresh = level.filter((page, index) => page !== container && !found.includes(page) && level.indexOf(page) === index);
|
|
164
159
|
found.push(...fresh);
|
|
165
160
|
level = fresh.flatMap((page) => itemsHeldBy(world, page));
|
|
166
161
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Page, type World } from "
|
|
2
|
-
import type { PageChange } from "
|
|
1
|
+
import { type Page, type World } from "../world.ts";
|
|
2
|
+
import type { PageChange } from "../write-page.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A stack's count changes with change, never with write (STK-10): adding a kind the container counts already is refused, and so is taking away a stack by another count
|
|
5
5
|
* than its own, each with the change that does it.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// What write may do to the stacks of a container's list (STK-10): count only kinds, one stack of each, whose counts change only with change.
|
|
2
|
-
import { comparableText } from "
|
|
3
|
-
import { bundleOf } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { comparableText } from "../../core/text.js";
|
|
3
|
+
import { bundleOf } from "../load.js";
|
|
4
|
+
import { containerFieldOf } from "../standard-fields.js";
|
|
5
|
+
import { pageNamed, searchSystemPages, textsIn, validHoldersOf } from "../world.js";
|
|
6
|
+
import { countedText, countOf, readEntry } from "./entry.js";
|
|
7
|
+
import { canCount, entryKind, entryPage, goodsNamed, isKind, notKindReason, stacksOf } from "./kinds.js";
|
|
8
8
|
/**
|
|
9
9
|
* A stack's count changes with change, never with write (STK-10): adding a kind the container counts already is refused, and so is taking away a stack by another count
|
|
10
10
|
* than its own, each with the change that does it.
|
|
@@ -65,6 +65,32 @@ export function checkStacks(world, holder, field, before, after) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* What a count beside a link to no page means (STK-10): a name of a kind, as Arrows (20), in its units; else the system's kinds go by their English names, and a word
|
|
70
|
+
* of the campaign's language is their label, as [[Torch|torcia]] 3; only what the system lacks becomes a kind of the campaign. Said by write and validate.
|
|
71
|
+
*/
|
|
72
|
+
export function missingKindMessage(world, holder, field, read) {
|
|
73
|
+
const named = goodsNamed(world, read.page);
|
|
74
|
+
if (named !== undefined) {
|
|
75
|
+
const bundle = bundleOf(world.system?.load?.bundle, named);
|
|
76
|
+
const pieces = read.count * bundle;
|
|
77
|
+
const unit = bundle > 1 ? `counted in pieces, ${bundle} for each bought` : "counted in the units the system sells it in";
|
|
78
|
+
return `There is no page named ${read.page}, but it is a name of ${named.name}, ${unit}: write ${holder.name}, add ${field}="[[${named.name}]] ${pieces}".`;
|
|
79
|
+
}
|
|
80
|
+
const campaignKind = `Only what the system lacks becomes a kind of the campaign, written first: write "${read.page}", type item.`;
|
|
81
|
+
const near = goodsLike(world, read.page);
|
|
82
|
+
if (near.length > 0) {
|
|
83
|
+
return `There is no page named ${read.page}, so [[${read.page}]] ${read.count} counts nothing. The system has ${near.map((page) => page.name).join(", ")}: if it is one of them, `
|
|
84
|
+
+ `write ${holder.name}, add ${field}="[[${near[0].name}]] ${read.count}". ${campaignKind}`;
|
|
85
|
+
}
|
|
86
|
+
return `There is no page named ${read.page}, so [[${read.page}]] ${read.count} counts nothing. The system's kinds go by their English names, as find shows them: write the one it has `
|
|
87
|
+
+ `with your word as its label, such as write ${holder.name}, add ${field}="[[Torch|${read.page.toLowerCase()}]] ${read.count}". ${campaignKind}`;
|
|
88
|
+
}
|
|
89
|
+
/** Whether a name leads to a kind, counted as a stack of 1 when its link stands alone (STK-1). */
|
|
90
|
+
export function isKindNamed(world, name) {
|
|
91
|
+
const page = entryPage(world, name);
|
|
92
|
+
return page !== undefined && isKind(world, page);
|
|
93
|
+
}
|
|
68
94
|
/** A count beside a link counts only a kind (STK-1, STK-10): never a page with a story of its own, nor one that is not there, which the message tells how to find or make. */
|
|
69
95
|
function checkCounted(world, holder, field, read, page) {
|
|
70
96
|
if (page === undefined) {
|
|
@@ -87,27 +113,6 @@ function checkCountedText(world, holder, field, entry) {
|
|
|
87
113
|
throw new Error(`"${entry}" is a count inside a text: write ${holder.name}, add ${field}="[[${page.name}]] ${counted.count}", a stack of ${page.name}. Nothing changed.`);
|
|
88
114
|
}
|
|
89
115
|
}
|
|
90
|
-
/**
|
|
91
|
-
* What a count beside a link to no page means (STK-10): a name of a kind, as Arrows (20), in its units; else the system's kinds go by their English names, and a word
|
|
92
|
-
* of the campaign's language is their label, as [[Torch|torcia]] 3; only what the system lacks becomes a kind of the campaign. Said by write and validate.
|
|
93
|
-
*/
|
|
94
|
-
export function missingKindMessage(world, holder, field, read) {
|
|
95
|
-
const named = goodsNamed(world, read.page);
|
|
96
|
-
if (named !== undefined) {
|
|
97
|
-
const bundle = bundleOf(world.system?.load?.bundle, named);
|
|
98
|
-
const pieces = read.count * bundle;
|
|
99
|
-
const unit = bundle > 1 ? `counted in pieces, ${bundle} for each bought` : "counted in the units the system sells it in";
|
|
100
|
-
return `There is no page named ${read.page}, but it is a name of ${named.name}, ${unit}: write ${holder.name}, add ${field}="[[${named.name}]] ${pieces}".`;
|
|
101
|
-
}
|
|
102
|
-
const campaignKind = `Only what the system lacks becomes a kind of the campaign, written first: write "${read.page}", type item.`;
|
|
103
|
-
const near = goodsLike(world, read.page);
|
|
104
|
-
if (near.length > 0) {
|
|
105
|
-
return `There is no page named ${read.page}, so [[${read.page}]] ${read.count} counts nothing. The system has ${near.map((page) => page.name).join(", ")}: if it is one of them, `
|
|
106
|
-
+ `write ${holder.name}, add ${field}="[[${near[0].name}]] ${read.count}". ${campaignKind}`;
|
|
107
|
-
}
|
|
108
|
-
return `There is no page named ${read.page}, so [[${read.page}]] ${read.count} counts nothing. The system's kinds go by their English names, as find shows them: write the one it has `
|
|
109
|
-
+ `with your word as its label, such as write ${holder.name}, add ${field}="[[Torch|${read.page.toLowerCase()}]] ${read.count}". ${campaignKind}`;
|
|
110
|
-
}
|
|
111
116
|
/** The system's goods whose names hold a word, the shortest first, as Arrows for Arrow: for a refusal to name them, which saves a find (STK-10). */
|
|
112
117
|
function goodsLike(world, word) {
|
|
113
118
|
const named = searchSystemPages(world, { text: word, type: "item" }).filter((match) => match.excerpt === undefined && canCount(world, match.page)).map((match) => match.page);
|
|
@@ -122,8 +127,3 @@ function kindOfEntry(world) {
|
|
|
122
127
|
return counted && page !== undefined ? [page.name] : [];
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
|
-
/** Whether a name leads to a kind, counted as a stack of 1 when its link stands alone (STK-1). */
|
|
126
|
-
export function isKindNamed(world, name) {
|
|
127
|
-
const page = entryPage(world, name);
|
|
128
|
-
return page !== undefined && isKind(world, page);
|
|
129
|
-
}
|
|
@@ -13,21 +13,6 @@ export function declaredKind(world, field) {
|
|
|
13
13
|
const fields = world.system?.fields;
|
|
14
14
|
return fields === undefined ? undefined : kindsOf(fields).get(comparableText(field));
|
|
15
15
|
}
|
|
16
|
-
/** The kinds a system declares, by the name as it is compared, the first written winning: built once for each system, as every field read asks (D-194). */
|
|
17
|
-
function kindsOf(fields) {
|
|
18
|
-
let kinds = kindsByFields.get(fields);
|
|
19
|
-
if (kinds === undefined) {
|
|
20
|
-
kinds = new Map();
|
|
21
|
-
for (const [name, kind] of Object.entries(fields)) {
|
|
22
|
-
if (!kinds.has(comparableText(name))) {
|
|
23
|
-
kinds.set(comparableText(name), kind);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
kindsByFields.set(fields, kinds);
|
|
27
|
-
}
|
|
28
|
-
return kinds;
|
|
29
|
-
}
|
|
30
|
-
const kindsByFields = new WeakMap();
|
|
31
16
|
/** Whether the game system declares a field as something never counted: a number, text or a list, such as cr 1/4 or cost 15 gp (SYS-8). */
|
|
32
17
|
export function isDeclaredUncounted(world, field) {
|
|
33
18
|
const kind = declaredKind(world, field);
|
|
@@ -102,3 +87,18 @@ export function kindMessage(page) {
|
|
|
102
87
|
return `${page.name} is ${systemLabel(page)}, a kind and read-only: one in a fight is a copy, brought in with scene, creatures ${page.name}=1; `
|
|
103
88
|
+ `one with a name of its own is a character with creature=[[${page.name}]].`;
|
|
104
89
|
}
|
|
90
|
+
/** The kinds a system declares, by the name as it is compared, the first written winning: built once for each system, as every field read asks (D-194). */
|
|
91
|
+
function kindsOf(fields) {
|
|
92
|
+
let kinds = kindsByFields.get(fields);
|
|
93
|
+
if (kinds === undefined) {
|
|
94
|
+
kinds = new Map();
|
|
95
|
+
for (const [name, kind] of Object.entries(fields)) {
|
|
96
|
+
if (!kinds.has(comparableText(name))) {
|
|
97
|
+
kinds.set(comparableText(name), kind);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
kindsByFields.set(fields, kinds);
|
|
101
|
+
}
|
|
102
|
+
return kinds;
|
|
103
|
+
}
|
|
104
|
+
const kindsByFields = new WeakMap();
|
package/dist/pages/world.js
CHANGED
|
@@ -2,10 +2,10 @@ import { basename, join, relative, resolve, sep } from "node:path";
|
|
|
2
2
|
import { frozen } from "../core/frozen.js";
|
|
3
3
|
import { files } from "../core/store.js";
|
|
4
4
|
import { comparableText, valueNamed } from "../core/text.js";
|
|
5
|
-
import { linkedPages } from "./markdown.js";
|
|
5
|
+
import { linkedPages, links } from "./markdown.js";
|
|
6
6
|
import { readFields, splitPageFile } from "./page-file.js";
|
|
7
7
|
import { pageTypes, typeOfFolder, worldFolderName } from "./page-types.js";
|
|
8
|
-
import { readEntry } from "./
|
|
8
|
+
import { readEntry } from "./stacks/entry.js";
|
|
9
9
|
import { canHold, containerFieldOf } from "./standard-fields.js";
|
|
10
10
|
const forbiddenCharacters = /[\\/:*?"<>|#^[\]\u0000-\u001f]/;
|
|
11
11
|
const longestName = 120;
|
|
@@ -301,6 +301,12 @@ export function checkPageName(name) {
|
|
|
301
301
|
if (name === "" || name.length > longestName || name.trim() !== name || name.endsWith(".") || forbiddenCharacters.test(name)) {
|
|
302
302
|
throw new Error(`"${name}" cannot be a page name. Names become file names and links: at most ${longestName} characters, without \\ / : * ? " < > | # ^ [ ], line breaks, spaces at the ends or a final dot.`);
|
|
303
303
|
}
|
|
304
|
+
// A name that ends as a file does, as Bruna.md or Mappa.png, makes a page no link reaches (LNK-1).
|
|
305
|
+
if (links(`[[${name}]]`)[0]?.page !== name) {
|
|
306
|
+
const ending = /\.[a-z0-9]+$/i.test(name);
|
|
307
|
+
const remedy = ending ? `Give the name without its file ending, as "${name.replace(/\.[a-z0-9]+$/i, "")}".` : "Give the name without ` or %%, which make code and comments.";
|
|
308
|
+
throw new Error(`"${name}" cannot be a page name: a link to it would not reach it. ${remedy}`);
|
|
309
|
+
}
|
|
304
310
|
}
|
|
305
311
|
/** Reads one page file of the campaign in `root`, once in a call (D-194). */
|
|
306
312
|
export function readPage(root, fullPath) {
|
|
@@ -310,6 +316,22 @@ export function readPage(root, fullPath) {
|
|
|
310
316
|
}
|
|
311
317
|
return page;
|
|
312
318
|
}
|
|
319
|
+
/** The page whose file in a folder's world/ is named `name`, with the type its folder gives, found by the file's name alone without reading the pages: enough to say that a page is there. */
|
|
320
|
+
export function pageFileNamed(root, name) {
|
|
321
|
+
const worldPath = join(root, worldFolderName);
|
|
322
|
+
const wanted = comparableText(name.trim());
|
|
323
|
+
const file = files().files(worldPath, (candidate) => /\.md$/i.test(candidate) && comparableText(candidate.slice(0, -3)) === wanted)[0];
|
|
324
|
+
return file === undefined ? undefined : { name: basename(file).slice(0, -3), type: typeOfFolder(relative(worldPath, file).split(sep)[0]) };
|
|
325
|
+
}
|
|
326
|
+
/** The pages of the system's bonus lists a page names (FOR-5, D-449): an attuned ring, a feat; of a list given only while in another, only those in it too, as a ring worn (BND-4). */
|
|
327
|
+
export function bonusPages(world, fields) {
|
|
328
|
+
return (world.system?.bonusLists ?? []).flatMap((list) => {
|
|
329
|
+
const named = linksIn(valueNamed(fields, list));
|
|
330
|
+
const whileIn = world.system?.bonusWhile?.[list];
|
|
331
|
+
const held = whileIn === undefined ? undefined : linksIn(valueNamed(fields, whileIn)).map(comparableText);
|
|
332
|
+
return named.filter((name) => held === undefined || held.includes(comparableText(name))).flatMap((name) => findPage(world, name) ?? []);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
313
335
|
/** The page that the text of a file in `root` writes. */
|
|
314
336
|
function pageOf(root, fullPath, text) {
|
|
315
337
|
const path = relative(root, fullPath).split(sep).join("/");
|
|
@@ -323,14 +345,6 @@ function pageOf(root, fullPath, text) {
|
|
|
323
345
|
body: file.body,
|
|
324
346
|
};
|
|
325
347
|
}
|
|
326
|
-
/** The page whose file in a folder's world/ is named `name`, with the type its folder gives, found by the file's name alone without reading the pages: enough to say that a page is there. */
|
|
327
|
-
export function pageFileNamed(root, name) {
|
|
328
|
-
const worldPath = join(root, worldFolderName);
|
|
329
|
-
const wanted = comparableText(name.trim());
|
|
330
|
-
const file = files().files(worldPath, (candidate) => /\.md$/i.test(candidate) && comparableText(candidate.slice(0, -3)) === wanted)[0];
|
|
331
|
-
return file === undefined ? undefined : { name: basename(file).slice(0, -3), type: typeOfFolder(relative(worldPath, file).split(sep)[0]) };
|
|
332
|
-
}
|
|
333
|
-
/** The pages of a folder's world/, each marked with the game system it comes from, if any; a file that cannot be read is a problem, and the others still work. */
|
|
334
348
|
/**
|
|
335
349
|
* The pages of a game system, read once in a process: they ship with the package and are read-only, so a running server keeps those it started with, as a
|
|
336
350
|
* change to a system asks for a reconnection (D-194).
|
|
@@ -348,6 +362,7 @@ function versionPages(common, version) {
|
|
|
348
362
|
const pages = [...common.pages.filter((page) => !names.has(comparableText(page.name))), ...version.pages].sort((first, second) => (first.path < second.path ? -1 : 1));
|
|
349
363
|
return { pages, problems: [...common.problems, ...version.problems] };
|
|
350
364
|
}
|
|
365
|
+
/** The pages of a folder's world/, each marked with the game system it comes from, if any; a file that cannot be read is a problem, and the others still work. */
|
|
351
366
|
function readPages(root, system) {
|
|
352
367
|
const pages = [];
|
|
353
368
|
const problems = [];
|
|
@@ -399,12 +414,3 @@ function textExcerpt(page, text) {
|
|
|
399
414
|
function shorten(text) {
|
|
400
415
|
return text.length > 120 ? `${text.slice(0, 119)}…` : text;
|
|
401
416
|
}
|
|
402
|
-
/** The pages of the system's bonus lists a page names (FOR-5, D-449): an attuned ring, a feat; of a list given only while in another, only those in it too, as a ring worn (BND-4). */
|
|
403
|
-
export function bonusPages(world, fields) {
|
|
404
|
-
return (world.system?.bonusLists ?? []).flatMap((list) => {
|
|
405
|
-
const named = linksIn(valueNamed(fields, list));
|
|
406
|
-
const whileIn = world.system?.bonusWhile?.[list];
|
|
407
|
-
const held = whileIn === undefined ? undefined : linksIn(valueNamed(fields, whileIn)).map(comparableText);
|
|
408
|
-
return named.filter((name) => held === undefined || held.includes(comparableText(name))).flatMap((name) => findPage(world, name) ?? []);
|
|
409
|
-
});
|
|
410
|
-
}
|
package/dist/pages/write-page.js
CHANGED
|
@@ -2,12 +2,12 @@ import { join } from "node:path";
|
|
|
2
2
|
import { files } from "../core/store.js";
|
|
3
3
|
import { comparableText, withArticle } from "../core/text.js";
|
|
4
4
|
import { holdRefusal } from "./containers.js";
|
|
5
|
-
import { baseChain, baseValue, derivedPages, ownFieldChange, sameAsBase } from "./inheritance.js";
|
|
5
|
+
import { baseChain, baseFieldOf, baseValue, derivedPages, ownFieldChange, sameAsBase } from "./inheritance.js";
|
|
6
6
|
import { introductionText, partContent, readSection, repeatedNames, secretNames, sectionTitles, writeText } from "./markdown.js";
|
|
7
7
|
import { changeFields, holdsNestedList, joinPageFile, readFields, splitPageFile } from "./page-file.js";
|
|
8
8
|
import { pageTypeNames, pageTypes, worldFolderName } from "./page-types.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { isKind, notKindReason } from "./stacks/kinds.js";
|
|
10
|
+
import { checkStackEdits, checkStacks, isKindNamed } from "./stacks/writes.js";
|
|
11
11
|
import { canHold, checkStandardFields, containerFieldOf, containerFields, isFieldName, isStandardField, misspelledStandardField, newPageFields } from "./standard-fields.js";
|
|
12
12
|
import { alwaysInList, alwaysInMessage, heldSystemPageMessage, hidingMessage, readOnlyMessage, systemLabel } from "./system-pages.js";
|
|
13
13
|
import { checkPageName, findPage, heldNames, holdersOf, isCountedItem, linksIn, locate, readPage, validHoldersOf, withPage } from "./world.js";
|
|
@@ -57,6 +57,35 @@ export function writePage(world, name, type, requested) {
|
|
|
57
57
|
}
|
|
58
58
|
return { page: readPage(world.root, fullPath), created: existing === undefined, changed: true, mode, retyped };
|
|
59
59
|
}
|
|
60
|
+
/** Checks the fields of a change on a page of a type: names a field can have, no list inside a list, and each field given once. Items may be added to a list and removed from it together. */
|
|
61
|
+
export function checkFieldChange(type, change) {
|
|
62
|
+
for (const name of [...Object.keys(change.set ?? {}), ...Object.keys(change.add ?? {})]) {
|
|
63
|
+
if (!isFieldName(name)) {
|
|
64
|
+
throw new Error(`"${name}" cannot be a field name: start with a letter, and use only letters, digits, - and _.`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const [name, value] of [...Object.entries(change.set ?? {}), ...Object.entries(change.add ?? {})]) {
|
|
68
|
+
if (holdsNestedList(value)) {
|
|
69
|
+
throw new Error(`"${name}" would hold a list inside a list, which a field cannot hold. Give a list of links or text, such as ["[[A]]", "[[B]]"].`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const set = Object.keys(change.set ?? {});
|
|
73
|
+
const unset = change.unset ?? [];
|
|
74
|
+
// Removing a field in two spellings removes both, as written: only giving a value twice is unclear.
|
|
75
|
+
for (const names of [set, Object.keys(change.add ?? {}), Object.keys(change.remove ?? {})]) {
|
|
76
|
+
const [repeated] = repeatedFieldNames(type, names);
|
|
77
|
+
if (repeated !== undefined) {
|
|
78
|
+
throw new Error(`The field ${repeated} is given twice: give each field once.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// A list changed item by item counts once, however many items are added and removed; so does a field removed in several spellings.
|
|
82
|
+
const lists = new Map([...Object.keys(change.add ?? {}), ...Object.keys(change.remove ?? {})].map((name) => [fieldKey(type, name), name]));
|
|
83
|
+
const removed = new Map(unset.map((name) => [fieldKey(type, name), name]));
|
|
84
|
+
const [twice] = repeatedFieldNames(type, [...set, ...removed.values(), ...lists.values()]);
|
|
85
|
+
if (twice !== undefined) {
|
|
86
|
+
throw new Error(`The field ${twice} is given in two ways (set, unset, or add and remove): give it in one.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
60
89
|
/**
|
|
61
90
|
* A page changes type only when it still fits where it is and what it holds still fits in it (CON-1, D-159); a creature that pages derive from keeps its type,
|
|
62
91
|
* or they would derive from nothing (INH-2).
|
|
@@ -118,10 +147,11 @@ function withoutBaseValues(world, existing, page, changed, frontmatter) {
|
|
|
118
147
|
if (changed.length === 0) {
|
|
119
148
|
return frontmatter;
|
|
120
149
|
}
|
|
121
|
-
// When the
|
|
150
|
+
// When the base changes, its creature or its item, every value the page holds is checked against the new one.
|
|
122
151
|
const written = { name: existing?.name ?? page.name, type: existing?.type ?? page.type, path: page.path, fields: readFields(frontmatter, page.path), body: "" };
|
|
123
152
|
const now = withPage(world, existing, written);
|
|
124
|
-
const
|
|
153
|
+
const base = baseFieldOf(written.type);
|
|
154
|
+
const checked = base !== undefined && changed.some((field) => comparableText(field) === base) ? Object.keys(written.fields) : changed;
|
|
125
155
|
const same = checked.filter((field) => Object.hasOwn(written.fields, field) && sameAsBase(now, written, field));
|
|
126
156
|
return same.length === 0 ? frontmatter : changeFields(frontmatter, { unset: same }, page.path);
|
|
127
157
|
}
|
|
@@ -181,35 +211,6 @@ function checkUnset(world, existing, requested, written) {
|
|
|
181
211
|
}
|
|
182
212
|
});
|
|
183
213
|
}
|
|
184
|
-
/** Checks the fields of a change on a page of a type: names a field can have, no list inside a list, and each field given once. Items may be added to a list and removed from it together. */
|
|
185
|
-
export function checkFieldChange(type, change) {
|
|
186
|
-
for (const name of [...Object.keys(change.set ?? {}), ...Object.keys(change.add ?? {})]) {
|
|
187
|
-
if (!isFieldName(name)) {
|
|
188
|
-
throw new Error(`"${name}" cannot be a field name: start with a letter, and use only letters, digits, - and _.`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
for (const [name, value] of [...Object.entries(change.set ?? {}), ...Object.entries(change.add ?? {})]) {
|
|
192
|
-
if (holdsNestedList(value)) {
|
|
193
|
-
throw new Error(`"${name}" would hold a list inside a list, which a field cannot hold. Give a list of links or text, such as ["[[A]]", "[[B]]"].`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const set = Object.keys(change.set ?? {});
|
|
197
|
-
const unset = change.unset ?? [];
|
|
198
|
-
// Removing a field in two spellings removes both, as written: only giving a value twice is unclear.
|
|
199
|
-
for (const names of [set, Object.keys(change.add ?? {}), Object.keys(change.remove ?? {})]) {
|
|
200
|
-
const [repeated] = repeatedFieldNames(type, names);
|
|
201
|
-
if (repeated !== undefined) {
|
|
202
|
-
throw new Error(`The field ${repeated} is given twice: give each field once.`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// A list changed item by item counts once, however many items are added and removed; so does a field removed in several spellings.
|
|
206
|
-
const lists = new Map([...Object.keys(change.add ?? {}), ...Object.keys(change.remove ?? {})].map((name) => [fieldKey(type, name), name]));
|
|
207
|
-
const removed = new Map(unset.map((name) => [fieldKey(type, name), name]));
|
|
208
|
-
const [twice] = repeatedFieldNames(type, [...set, ...removed.values(), ...lists.values()]);
|
|
209
|
-
if (twice !== undefined) {
|
|
210
|
-
throw new Error(`The field ${twice} is given in two ways (set, unset, or add and remove): give it in one.`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
214
|
/** The names that give the same field more than once. */
|
|
214
215
|
function repeatedFieldNames(type, names) {
|
|
215
216
|
const keys = names.map((name) => fieldKey(type, name));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type Note,
|
|
1
|
+
export { type Note, readNotes, removeNote, writeNote } from "./notes.ts";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The player's notes (D-371), outside the game.
|
|
2
|
-
export {
|
|
2
|
+
export { readNotes, removeNote, writeNote } from "./notes.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wordCount } from "../core/text.js";
|
|
1
2
|
import { sameWord, searchWords } from "./search.js";
|
|
2
3
|
/**
|
|
3
4
|
* The pages a text finds, best first (LIB-6): as BM25 counts them, a word weighing more the fewer pages have it and the more a page repeats it for its length;
|
|
@@ -110,6 +111,7 @@ const lengthWeight = 0.75;
|
|
|
110
111
|
const longestTitle = 60;
|
|
111
112
|
const mostTitleWords = 6;
|
|
112
113
|
const fewestTitleLetters = 4;
|
|
114
|
+
const titleLetters = new RegExp(`\\p{L}{${fewestTitleLetters}}`, "u");
|
|
113
115
|
const fewestWords = 60;
|
|
114
116
|
// A line on this many pages of a book or more, and on one in fifty, is the page's running head, never a title.
|
|
115
117
|
const runningPages = 3;
|
|
@@ -155,7 +157,7 @@ function titleLines(lines, running) {
|
|
|
155
157
|
const capitals = trimmed.match(/\p{Lu}/gu)?.length ?? 0;
|
|
156
158
|
const short = trimmed.length <= longestTitle && trimmed.split(/\s+/).length <= mostTitleWords;
|
|
157
159
|
const goesOn = /^\s*\p{Ll}/u.test(lines[index + 1] ?? "");
|
|
158
|
-
return short && cased >= 3 && capitals >= cased * 0.7 &&
|
|
160
|
+
return short && cased >= 3 && capitals >= cased * 0.7 && titleLetters.test(trimmed) && !goesOn && !running.has(lineKey(trimmed));
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
/**
|
|
@@ -211,6 +213,3 @@ function headingAbove(headings, line) {
|
|
|
211
213
|
}
|
|
212
214
|
return undefined;
|
|
213
215
|
}
|
|
214
|
-
function wordCount(text) {
|
|
215
|
-
return text.split(/\s+/).filter((word) => word !== "").length;
|
|
216
|
-
}
|
package/dist/rules/rule-book.js
CHANGED
|
@@ -21,7 +21,7 @@ export function bookTitles(sections) {
|
|
|
21
21
|
* A byte order mark and the properties at the top (---) are not text; code blocks and %% comments hold no titles.
|
|
22
22
|
*/
|
|
23
23
|
export function ruleSections(text, file, source) {
|
|
24
|
-
const content = withoutProperties(text.replace(
|
|
24
|
+
const content = withoutProperties(text.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n"));
|
|
25
25
|
const markers = markersOf(content);
|
|
26
26
|
const firstStart = markers[0]?.start ?? content.length;
|
|
27
27
|
if (content.slice(0, firstStart).trim() !== "") {
|
package/dist/rules/search.js
CHANGED
|
@@ -39,10 +39,6 @@ export function isTitled(section, text) {
|
|
|
39
39
|
}
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
-
/** The titles a text gives, as in "Combat › Grappling" (› > or / between them), without the stop that may end one. */
|
|
43
|
-
function titlesIn(text) {
|
|
44
|
-
return text.split(/\s*[›>/]\s*/).map((title) => title.trim().replace(/[.:]$/, "")).filter((title) => title !== "");
|
|
45
|
-
}
|
|
46
42
|
/** Whether a text holds every word of a search, as search compares words: what finds a precedent. */
|
|
47
43
|
export function hasAllWords(text, search) {
|
|
48
44
|
const words = searchWords(text);
|
|
@@ -52,23 +48,6 @@ export function hasAllWords(text, search) {
|
|
|
52
48
|
export function searchWords(text) {
|
|
53
49
|
return comparableText(text).match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
54
50
|
}
|
|
55
|
-
/** The words of a section's title, of the titles above it and of its own text, each once: cut once for each section, which never changes (D-194). */
|
|
56
|
-
function wordsOf(section) {
|
|
57
|
-
let words = wordsBySection.get(section);
|
|
58
|
-
if (words === undefined) {
|
|
59
|
-
const distinct = (text) => [...new Set(searchWords(text))];
|
|
60
|
-
words = { title: distinct(section.path.at(-1) ?? ""), above: distinct(section.path.slice(0, -1).join(" ")), text: distinct(section.ownText) };
|
|
61
|
-
wordsBySection.set(section, words);
|
|
62
|
-
}
|
|
63
|
-
return words;
|
|
64
|
-
}
|
|
65
|
-
const wordsBySection = new WeakMap();
|
|
66
|
-
// A form of a word may change this many of its last letters, and must keep at least the first four (all of a shorter word).
|
|
67
|
-
const formLetters = 3;
|
|
68
|
-
const stemLetters = 4;
|
|
69
|
-
function hasForm(words, searched) {
|
|
70
|
-
return words.some((word) => sameWord(searched, word));
|
|
71
|
-
}
|
|
72
51
|
/**
|
|
73
52
|
* Whether a word of a text is a form of a word searched (RUL-4): the two differ at most in their last three letters, and share at least the first four, or all of a shorter word.
|
|
74
53
|
* Grapple finds grappled and grappling, rest finds resting but not restrained, concentration not conceal; two letters find only themselves.
|
|
@@ -86,6 +65,27 @@ export function sameWord(searched, word) {
|
|
|
86
65
|
const doubledInSearched = common > 0 && searched[common] === searched[common - 1] ? 1 : 0;
|
|
87
66
|
return word.length - common <= formLetters + doubledInWord && common >= Math.max(Math.min(searched.length, stemLetters), searched.length - formLetters - doubledInSearched);
|
|
88
67
|
}
|
|
68
|
+
/** The titles a text gives, as in "Combat › Grappling" (› > or / between them), without the stop that may end one. */
|
|
69
|
+
function titlesIn(text) {
|
|
70
|
+
return text.split(/\s*[›>/]\s*/).map((title) => title.trim().replace(/[.:]$/, "")).filter((title) => title !== "");
|
|
71
|
+
}
|
|
72
|
+
/** The words of a section's title, of the titles above it and of its own text, each once: cut once for each section, which never changes (D-194). */
|
|
73
|
+
function wordsOf(section) {
|
|
74
|
+
let words = wordsBySection.get(section);
|
|
75
|
+
if (words === undefined) {
|
|
76
|
+
const distinct = (text) => [...new Set(searchWords(text))];
|
|
77
|
+
words = { title: distinct(section.path.at(-1) ?? ""), above: distinct(section.path.slice(0, -1).join(" ")), text: distinct(section.ownText) };
|
|
78
|
+
wordsBySection.set(section, words);
|
|
79
|
+
}
|
|
80
|
+
return words;
|
|
81
|
+
}
|
|
82
|
+
const wordsBySection = new WeakMap();
|
|
83
|
+
// A form of a word may change this many of its last letters, and must keep at least the first four (all of a shorter word).
|
|
84
|
+
const formLetters = 3;
|
|
85
|
+
const stemLetters = 4;
|
|
86
|
+
function hasForm(words, searched) {
|
|
87
|
+
return words.some((word) => sameWord(searched, word));
|
|
88
|
+
}
|
|
89
89
|
/** How much of a search a section holds: the weight of each word it has, and again for each word in its title (half for the titles above it). */
|
|
90
90
|
function scoreOf(entry, searched, weights) {
|
|
91
91
|
let score = 0;
|
package/dist/rules/shown.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wordCount } from "../core/text.js";
|
|
1
2
|
// Sections shown whole when the text names none of them; the others are only named.
|
|
2
3
|
const wholeFound = 3;
|
|
3
4
|
/**
|
|
@@ -39,6 +40,3 @@ function holds(outer, inner) {
|
|
|
39
40
|
return outer.source === inner.source && outer.file === inner.file && outer.path.length <= inner.path.length && outer.path.every((title, index) => inner.path[index] === title)
|
|
40
41
|
&& outer.text.includes(inner.text);
|
|
41
42
|
}
|
|
42
|
-
function wordCount(text) {
|
|
43
|
-
return text.split(/\s+/).filter((word) => word !== "").length;
|
|
44
|
-
}
|
package/dist/saves/saves.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export interface Save {
|
|
|
6
6
|
}
|
|
7
7
|
/** A zip of files, given by their paths inside it with forward slashes, such as world/characters/Kira.md. */
|
|
8
8
|
export declare function packFiles(files: Record<string, Uint8Array>): Uint8Array;
|
|
9
|
-
/** The files a zip holds, by their paths inside it; folders are left out. */
|
|
10
|
-
export declare function unpackFiles(zip: Uint8Array): Record<string, Uint8Array>;
|
|
9
|
+
/** The files a zip holds, by their paths inside it; folders are left out. It throws before unpacking a zip that would weigh more than `most` bytes. */
|
|
10
|
+
export declare function unpackFiles(zip: Uint8Array, most?: number): Record<string, Uint8Array>;
|
|
11
11
|
/** The file name of a save: its number, then the game date and the label it has, such as "003 - day 2, 06.10 - Scontro all'ossario.zip". */
|
|
12
12
|
export declare function saveFileName(number: number, parts: (string | undefined)[]): string;
|
|
13
13
|
/** The saves among the names of the files of a folder, in the order of their numbers; other files are left out. */
|
package/dist/saves/saves.js
CHANGED
|
@@ -5,13 +5,25 @@ const saveFilePattern = /^(\d{3,}) - (.+)\.zip$/;
|
|
|
5
5
|
const notInFileNames = /[\\/:*?"<>|\u0000-\u0008\u000e-\u001f]/g;
|
|
6
6
|
// The longest label a file name takes, in characters, never cutting one in two.
|
|
7
7
|
const longestLabel = 120;
|
|
8
|
+
// The most a save unpacks to: a campaign's pages and pictures, never the memory of the computer.
|
|
9
|
+
const largestSave = 1024 * 1024 * 1024;
|
|
8
10
|
/** A zip of files, given by their paths inside it with forward slashes, such as world/characters/Kira.md. */
|
|
9
11
|
export function packFiles(files) {
|
|
10
12
|
return zipSync(files, { level: 6 });
|
|
11
13
|
}
|
|
12
|
-
/** The files a zip holds, by their paths inside it; folders are left out. */
|
|
13
|
-
export function unpackFiles(zip) {
|
|
14
|
-
|
|
14
|
+
/** The files a zip holds, by their paths inside it; folders are left out. It throws before unpacking a zip that would weigh more than `most` bytes. */
|
|
15
|
+
export function unpackFiles(zip, most = largestSave) {
|
|
16
|
+
let declared = 0;
|
|
17
|
+
const read = unzipSync(zip, {
|
|
18
|
+
filter: (file) => {
|
|
19
|
+
declared += file.originalSize;
|
|
20
|
+
if (declared > most) {
|
|
21
|
+
throw new Error(`it unpacks to more than ${Math.round(most / 1024 / 1024)} MB, more than a save may`);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return Object.fromEntries(Object.entries(read).filter(([path]) => !path.endsWith("/")));
|
|
15
27
|
}
|
|
16
28
|
/** The file name of a save: its number, then the game date and the label it has, such as "003 - day 2, 06.10 - Scontro all'ossario.zip". */
|
|
17
29
|
export function saveFileName(number, parts) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Claude Code's doorbell for the player's sentences on the dashboard (D-495): `rpg --listen`, the Stop hook init writes, waits at the dashboard of its own
|
|
2
2
|
// chat and, when the player says a sentence, tells the chat to call status. It never carries the sentence, which reaches the master in that call.
|
|
3
3
|
import { get } from "node:http";
|
|
4
|
-
import { findCampaign } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { findCampaign } from "../campaign/index.js";
|
|
5
|
+
import { samePath } from "../library/index.js";
|
|
6
|
+
import { campaignPorts } from "./dashboard/ports.js";
|
|
7
7
|
/** What the chat hears from the doorbell: never the player's words, only where to read them. */
|
|
8
8
|
export const bellLine = "The player acted on the dashboard: call status to read what they did.";
|
|
9
9
|
/** Reads the hook's input, waits for the doorbell, and ends the process as Claude Code's asyncRewake reads it: 2 with the line to wake the chat, else 0. */
|