rpg-engine 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +6 -0
- package/dist/campaign/settings.js +22 -1
- package/dist/cli/cli.js +1 -1
- package/dist/cli/command-line.js +1 -1
- package/dist/commands/advance.d.ts +1 -1
- package/dist/commands/advance.js +6 -6
- package/dist/commands/ask.js +7 -7
- package/dist/commands/change/amounts.d.ts +32 -0
- package/dist/commands/change/amounts.js +150 -0
- package/dist/commands/change/change.d.ts +4 -54
- package/dist/commands/change/change.js +19 -749
- package/dist/commands/change/damage.d.ts +30 -0
- package/dist/commands/change/damage.js +73 -2
- package/dist/commands/change/dice.d.ts +34 -0
- package/dist/commands/change/dice.js +59 -0
- package/dist/commands/change/fields.d.ts +37 -0
- package/dist/commands/change/fields.js +156 -0
- package/dist/commands/change/holder.d.ts +48 -0
- package/dist/commands/change/holder.js +162 -0
- package/dist/commands/change/recipe-pace.js +1 -1
- package/dist/commands/change/recipe.d.ts +58 -0
- package/dist/commands/change/recipe.js +179 -0
- package/dist/commands/choices.js +3 -3
- package/dist/commands/config/config.d.ts +15 -0
- package/dist/commands/config/config.js +355 -0
- package/dist/commands/config/custom-levels.d.ts +7 -0
- package/dist/commands/config/custom-levels.js +32 -0
- package/dist/commands/{config.d.ts → config/dashboard.d.ts} +2 -24
- package/dist/commands/config/dashboard.js +171 -0
- package/dist/commands/config/entries.d.ts +17 -0
- package/dist/commands/config/entries.js +76 -0
- package/dist/commands/config/news.d.ts +7 -0
- package/dist/commands/config/news.js +88 -0
- package/dist/commands/config/shown.d.ts +9 -0
- package/dist/commands/config/shown.js +80 -0
- package/dist/commands/config/words.d.ts +27 -0
- package/dist/commands/config/words.js +204 -0
- package/dist/commands/effect.js +9 -9
- package/dist/commands/find.js +1 -1
- package/dist/commands/image.js +6 -6
- package/dist/commands/import/import.d.ts +0 -2
- package/dist/commands/import/import.js +45 -44
- package/dist/commands/import/run.js +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/init.js +2 -2
- 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 +10 -10
- package/dist/commands/package/consent.d.ts +11 -0
- package/dist/commands/package/consent.js +52 -0
- package/dist/commands/package/here.d.ts +51 -0
- package/dist/commands/package/here.js +128 -0
- package/dist/commands/package/install.d.ts +10 -0
- package/dist/commands/package/install.js +337 -0
- package/dist/commands/package/package.d.ts +18 -0
- package/dist/commands/package/package.js +236 -0
- package/dist/commands/package/result.d.ts +90 -0
- package/dist/commands/package/result.js +1 -0
- package/dist/commands/package/uninstall.d.ts +6 -0
- package/dist/commands/package/uninstall.js +70 -0
- package/dist/commands/rename.js +3 -3
- package/dist/commands/reveal.js +5 -5
- package/dist/commands/roll/roll.js +11 -9
- package/dist/commands/roll/tables.js +1 -1
- 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 +2 -2
- package/dist/commands/scene/close.d.ts +18 -0
- package/dist/commands/scene/close.js +179 -0
- package/dist/commands/scene/members.d.ts +14 -0
- package/dist/commands/scene/members.js +32 -0
- package/dist/commands/scene/open.d.ts +6 -0
- package/dist/commands/scene/open.js +298 -0
- package/dist/commands/scene/result.d.ts +98 -0
- package/dist/commands/scene/result.js +2 -0
- package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
- package/dist/commands/scene/scene.js +210 -0
- package/dist/commands/scene/turns.d.ts +18 -0
- package/dist/commands/scene/turns.js +229 -0
- package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +5 -3
- package/dist/commands/shared/{adventures.js → books/adventures.js} +23 -19
- package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
- package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
- package/dist/commands/shared/{library.js → books/library.js} +9 -9
- package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
- package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
- package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
- package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
- package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
- package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
- package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
- package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
- package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
- package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
- package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
- package/dist/commands/shared/{mode.js → campaign/mode.js} +24 -13
- package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
- package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
- package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
- package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
- package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
- package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
- package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +3 -3
- package/dist/commands/shared/{parts.js → campaign/parts.js} +3 -3
- package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
- package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
- package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
- package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
- package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
- package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
- package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
- package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
- package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
- package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
- package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
- package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
- package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
- package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
- package/dist/commands/shared/characters/orders.d.ts +4 -0
- package/dist/commands/shared/characters/orders.js +10 -0
- package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +2 -2
- package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +3 -3
- package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
- package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
- package/dist/commands/shared/examples.js +2 -2
- package/dist/commands/shared/packages/catalog.js +2 -2
- package/dist/commands/shared/packages/code.d.ts +1 -1
- package/dist/commands/shared/packages/code.js +8 -8
- package/dist/commands/shared/packages/extensions.d.ts +1 -1
- package/dist/commands/shared/packages/extensions.js +1 -1
- package/dist/commands/shared/packages/hooks.d.ts +1 -1
- package/dist/commands/shared/packages/hooks.js +1 -1
- package/dist/commands/shared/packages/widgets.d.ts +3 -3
- package/dist/commands/shared/packages/widgets.js +3 -3
- package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
- package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
- package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
- package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
- package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
- package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
- package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
- package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
- package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
- package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
- package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
- package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
- package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
- package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
- package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
- package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
- package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
- package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
- package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
- package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
- package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
- package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
- package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
- package/dist/commands/shared/{scene.js → scene/scene.js} +7 -7
- package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
- package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
- package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
- package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
- package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
- package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
- package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
- package/dist/commands/shared/sheet/effect-values.js +69 -0
- package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
- package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
- package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
- package/dist/commands/shared/sheet/formula-problems.js +140 -0
- package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
- package/dist/commands/shared/sheet/formula-scope.js +235 -0
- package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
- package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
- package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
- package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
- package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +5 -5
- package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
- package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
- package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
- package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
- package/dist/commands/shared/sheet/system-fields.js +45 -0
- package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
- package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
- package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
- package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
- package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
- package/dist/commands/shared/sheet/worked-out.js +291 -0
- package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
- package/dist/commands/shared/sheet/worked-text.js +55 -0
- package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
- package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
- package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
- package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
- package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
- package/dist/commands/shared/{events.js → time/events.js} +10 -13
- package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
- package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
- package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
- package/dist/commands/shared/{time.js → time/time.js} +6 -6
- package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
- package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
- package/dist/commands/show.d.ts +3 -0
- package/dist/commands/show.js +28 -9
- package/dist/commands/status.d.ts +2 -1
- package/dist/commands/status.js +28 -22
- package/dist/commands/thoughts.js +3 -3
- package/dist/commands/trade.js +8 -8
- package/dist/commands/translate.d.ts +1 -1
- package/dist/commands/translate.js +3 -3
- package/dist/commands/travel/open.d.ts +1 -1
- package/dist/commands/travel/open.js +2 -2
- package/dist/commands/travel/route.js +7 -6
- package/dist/commands/travel/travel.d.ts +1 -1
- package/dist/commands/travel/travel.js +8 -8
- package/dist/commands/validate.js +3 -3
- package/dist/commands/view/journal.d.ts +2 -2
- package/dist/commands/view/journal.js +2 -2
- package/dist/commands/view/map.d.ts +1 -1
- package/dist/commands/view/map.js +6 -6
- package/dist/commands/view/memory.d.ts +16 -0
- package/dist/commands/view/memory.js +90 -0
- package/dist/commands/view/page.d.ts +32 -0
- package/dist/commands/view/page.js +163 -0
- package/dist/commands/view/place.d.ts +7 -2
- package/dist/commands/view/place.js +30 -12
- package/dist/commands/view/result.d.ts +245 -0
- package/dist/commands/view/result.js +1 -0
- package/dist/commands/view/saves.d.ts +6 -0
- package/dist/commands/view/saves.js +53 -0
- package/dist/commands/view/story.d.ts +32 -0
- package/dist/commands/view/story.js +227 -0
- package/dist/commands/view/view.d.ts +26 -292
- package/dist/commands/view/view.js +26 -534
- package/dist/commands/view/world.d.ts +1 -1
- package/dist/commands/view/world.js +3 -3
- package/dist/commands/write/checks.d.ts +42 -0
- package/dist/commands/write/checks.js +291 -0
- package/dist/commands/write/here.d.ts +1 -1
- package/dist/commands/write/here.js +5 -5
- package/dist/commands/write/inheritance.d.ts +40 -0
- package/dist/commands/write/inheritance.js +189 -0
- package/dist/commands/write/input.d.ts +29 -0
- package/dist/commands/write/input.js +124 -0
- package/dist/commands/write/layer.d.ts +36 -0
- package/dist/commands/write/layer.js +48 -0
- package/dist/commands/write/notes.d.ts +22 -0
- package/dist/commands/write/notes.js +76 -0
- package/dist/commands/write/progression.d.ts +27 -0
- package/dist/commands/write/progression.js +175 -0
- package/dist/commands/write/write.d.ts +1 -0
- package/dist/commands/write/write.js +32 -816
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +7 -0
- package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
- package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
- package/dist/core/session-store.js +3 -3
- package/dist/core/store.d.ts +2 -2
- package/dist/core/store.js +18 -4
- package/dist/dashboard/acts/acts.js +1 -1
- package/dist/dashboard/acts/sending.js +110 -0
- package/dist/dashboard/acts/sheet.js +2 -2
- package/dist/dashboard/acts/strip.js +1 -1
- package/dist/dashboard/address.js +6 -0
- package/dist/dashboard/api.js +1 -1
- package/dist/dashboard/app.js +47 -171
- package/dist/dashboard/dice/roller.js +1 -1
- package/dist/dashboard/dice/sets.js +2 -2
- package/dist/dashboard/dice/stage.js +1 -1
- package/dist/dashboard/dice/tray.js +6 -6
- package/dist/dashboard/guide/ar.md +5 -3
- package/dist/dashboard/guide/cs.md +5 -3
- package/dist/dashboard/guide/da.md +5 -3
- package/dist/dashboard/guide/de.md +5 -3
- package/dist/dashboard/guide/el.md +5 -3
- package/dist/dashboard/guide/en.md +2 -0
- package/dist/dashboard/guide/es.md +4 -2
- package/dist/dashboard/guide/fi.md +5 -3
- package/dist/dashboard/guide/fr.md +4 -2
- package/dist/dashboard/guide/he.md +4 -2
- package/dist/dashboard/guide/hi.md +6 -4
- package/dist/dashboard/guide/hu.md +4 -2
- package/dist/dashboard/guide/is.md +5 -3
- package/dist/dashboard/guide/it.md +3 -1
- package/dist/dashboard/guide/ja.md +7 -5
- package/dist/dashboard/guide/ko.md +6 -4
- package/dist/dashboard/guide/nb.md +4 -2
- package/dist/dashboard/guide/nl.md +5 -3
- package/dist/dashboard/guide/pl.md +4 -2
- package/dist/dashboard/guide/pt.md +4 -2
- package/dist/dashboard/guide/ro.md +5 -3
- package/dist/dashboard/guide/ru.md +5 -3
- package/dist/dashboard/guide/sv.md +5 -3
- package/dist/dashboard/guide/tr.md +6 -4
- package/dist/dashboard/guide/uk.md +4 -2
- package/dist/dashboard/guide/zh.md +5 -3
- package/dist/dashboard/help/help.js +3 -3
- package/dist/dashboard/i18n/ar.json +4 -0
- package/dist/dashboard/i18n/cs.json +4 -0
- package/dist/dashboard/i18n/da.json +4 -0
- package/dist/dashboard/i18n/de.json +4 -0
- package/dist/dashboard/i18n/el.json +4 -0
- package/dist/dashboard/i18n/es.json +4 -0
- package/dist/dashboard/i18n/fi.json +4 -0
- package/dist/dashboard/i18n/fr.json +4 -0
- package/dist/dashboard/i18n/he.json +4 -0
- package/dist/dashboard/i18n/hi.json +4 -0
- package/dist/dashboard/i18n/hu.json +4 -0
- package/dist/dashboard/i18n/is.json +4 -0
- package/dist/dashboard/i18n/it.json +4 -0
- package/dist/dashboard/i18n/ja.json +5 -1
- package/dist/dashboard/i18n/ko.json +4 -0
- package/dist/dashboard/i18n/nb.json +4 -0
- package/dist/dashboard/i18n/nl.json +4 -0
- package/dist/dashboard/i18n/pl.json +4 -0
- package/dist/dashboard/i18n/pt.json +4 -0
- package/dist/dashboard/i18n/ro.json +4 -0
- package/dist/dashboard/i18n/ru.json +4 -0
- package/dist/dashboard/i18n/sv.json +4 -0
- package/dist/dashboard/i18n/tr.json +4 -0
- package/dist/dashboard/i18n/uk.json +4 -0
- package/dist/dashboard/i18n/zh.json +4 -0
- package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
- package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
- package/dist/dashboard/kit.js +3 -3
- package/dist/dashboard/packages/ask-card.js +3 -3
- package/dist/dashboard/packages/catalog.js +196 -0
- package/dist/dashboard/packages/engine.js +87 -0
- package/dist/dashboard/packages/installed.js +53 -0
- package/dist/dashboard/packages/library.js +97 -0
- package/dist/dashboard/packages/outcomes.js +45 -0
- package/dist/dashboard/packages/packages.js +20 -576
- package/dist/dashboard/packages/page-code.js +15 -2
- package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
- package/dist/dashboard/packages/rows.js +84 -0
- package/dist/dashboard/packages/share.js +44 -0
- package/dist/dashboard/packages/widgets.js +3 -3
- package/dist/dashboard/{card.js → parts/card.js} +1 -1
- package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
- package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
- package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
- package/dist/dashboard/{labels.js → parts/labels.js} +2 -1
- package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
- package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
- package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
- package/dist/dashboard/{refusals.js → parts/refusals.js} +1 -1
- package/dist/dashboard/{status.js → parts/status.js} +4 -4
- package/dist/dashboard/{widgets.js → parts/widgets.js} +2 -2
- package/dist/dashboard/place/key.js +24 -0
- package/dist/dashboard/place/paper.js +67 -0
- package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
- package/dist/dashboard/place/things.js +129 -0
- package/dist/dashboard/place/tokens.js +93 -0
- package/dist/dashboard/place/view.js +124 -0
- package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
- package/dist/dashboard/{asked.js → play/asked.js} +10 -10
- package/dist/dashboard/{choices.js → play/choices.js} +9 -9
- package/dist/dashboard/{requested.js → play/requested.js} +1 -1
- package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
- package/dist/dashboard/{scene.js → play/scene.js} +14 -14
- package/dist/dashboard/{turns.js → play/turns.js} +12 -12
- package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
- package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
- package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
- package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
- package/dist/dashboard/{setup.js → settings/setup.js} +5 -5
- package/dist/dashboard/{party.js → sheet/party.js} +8 -8
- package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
- package/dist/dashboard/{sheet.js → sheet/sheet.js} +17 -17
- package/dist/dashboard/{story.js → sheet/story.js} +3 -3
- package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
- package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
- package/dist/dashboard/{master.js → shell/master.js} +2 -2
- package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
- package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
- package/dist/dashboard/shell/shown.js +37 -0
- package/dist/dashboard/{table.js → shell/table.js} +2 -2
- package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
- package/dist/dashboard/{top.js → shell/top.js} +7 -7
- package/dist/dashboard/style.css +74 -3
- package/dist/dashboard/world/calendar.js +4 -4
- package/dist/dashboard/world/drawing.js +92 -0
- package/dist/dashboard/world/key.js +21 -0
- package/dist/dashboard/world/lore.js +5 -5
- package/dist/dashboard/world/map-card.js +186 -0
- package/dist/dashboard/world/place-card.js +39 -0
- package/dist/dashboard/world/places.js +29 -0
- package/dist/dashboard/world/world.js +9 -341
- package/dist/extensions/extension.d.ts +1 -1
- package/dist/extensions/extension.js +1 -1
- package/dist/images/images.js +12 -9
- package/dist/index.d.ts +1 -1
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/packages/npm.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/pages/check.js +23 -1
- package/dist/pages/containers.d.ts +1 -1
- package/dist/pages/containers.js +1 -1
- package/dist/pages/index.d.ts +4 -2
- package/dist/pages/index.js +4 -2
- package/dist/pages/inheritance.d.ts +2 -2
- package/dist/pages/layers.d.ts +50 -0
- package/dist/pages/layers.js +97 -0
- package/dist/pages/rename-page.js +1 -1
- package/dist/pages/stacks/writes.js +48 -22
- package/dist/pages/standard-fields.d.ts +1 -1
- package/dist/pages/system-pages.d.ts +5 -3
- package/dist/pages/system-pages.js +16 -7
- package/dist/pages/world.d.ts +8 -1
- package/dist/pages/world.js +16 -4
- package/dist/pages/write-layer.d.ts +18 -0
- package/dist/pages/write-layer.js +108 -0
- package/dist/pages/write-page.d.ts +2 -2
- package/dist/pages/write-page.js +2 -2
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/index.js +1 -1
- package/dist/rules/search.d.ts +1 -1
- package/dist/rules/shown.d.ts +1 -1
- package/dist/server/dashboard/choices.js +3 -3
- package/dist/server/dashboard/files.js +5 -5
- package/dist/server/dashboard/index.d.ts +2 -2
- package/dist/server/dashboard/index.js +2 -2
- package/dist/server/dashboard/news.js +4 -3
- package/dist/server/dashboard/player.js +1 -1
- package/dist/server/dashboard/writes.js +9 -7
- package/dist/server/mcp.js +28 -13
- package/dist/systems/campaign-data.d.ts +15 -0
- package/dist/systems/campaign-data.js +85 -0
- package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
- package/dist/systems/{system-code.js → code.js} +2 -2
- package/dist/systems/game-system.d.ts +7 -61
- package/dist/systems/game-system.js +1 -984
- package/dist/systems/index.d.ts +6 -3
- package/dist/systems/index.js +6 -3
- package/dist/systems/installed.d.ts +31 -0
- package/dist/systems/installed.js +89 -0
- package/dist/systems/maps.d.ts +3 -0
- package/dist/systems/maps.js +9 -0
- package/dist/systems/read.d.ts +3 -0
- package/dist/systems/read.js +471 -0
- package/dist/systems/schema.d.ts +289 -0
- package/dist/systems/schema.js +243 -0
- package/dist/systems/settings.d.ts +19 -0
- package/dist/systems/settings.js +78 -0
- package/dist/systems/versions.d.ts +12 -0
- package/dist/systems/versions.js +52 -0
- package/dist/testing/index.js +1 -1
- package/instructions/import.md +1 -1
- package/instructions/play.md +1 -1
- package/package.json +1 -1
- package/dist/commands/config.js +0 -948
- package/dist/commands/package.d.ts +0 -143
- package/dist/commands/package.js +0 -785
- package/dist/commands/scene.js +0 -894
- package/dist/commands/shared/worked-out.js +0 -805
- package/dist/dashboard/place/map-view.js +0 -417
- /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
- /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
- /package/dist/core/{package-api.js → packages/api.js} +0 -0
- /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
- /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
- /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
- /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
- /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
- /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
- /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
- /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
- /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
- /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
- /package/dist/languages/{language-pack.js → pack.js} +0 -0
- /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
- /package/dist/pages/{page-file.js → file.js} +0 -0
- /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
- /package/dist/pages/{page-types.js → types.js} +0 -0
- /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
- /package/dist/rules/{rule-book.js → book.js} +0 -0
- /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
- /package/dist/systems/{system-folders.js → folders.js} +0 -0
package/dist/commands/package.js
DELETED
|
@@ -1,785 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { changeExtensions, findCampaign, readTextSetting, requireCampaign } from "../campaign/index.js";
|
|
4
|
-
import { plainText } from "../confirm/index.js";
|
|
5
|
-
import { engineSystemsFolder } from "../core/context.js";
|
|
6
|
-
import { neutralExamples } from "../core/examples.js";
|
|
7
|
-
import { installedFromFolder } from "../core/files.js";
|
|
8
|
-
import { appendLogEntry } from "../core/log.js";
|
|
9
|
-
import { apiProblem, ourSystems, packageApi, readsApi } from "../core/package-declarations.js";
|
|
10
|
-
import { Refusal } from "../core/refusal.js";
|
|
11
|
-
import { defineCommand } from "../core/registry.js";
|
|
12
|
-
import { files, FileStore, isInside, withFiles } from "../core/store.js";
|
|
13
|
-
import { comparableText } from "../core/text.js";
|
|
14
|
-
import { isNewerVersion } from "../core/version.js";
|
|
15
|
-
import { dropConsent, findExtension, installedExtensions, readExtension, recordConsent, shortName } from "../extensions/index.js";
|
|
16
|
-
import { installedLanguages, languagePackProblems, readLanguagePack } from "../languages/index.js";
|
|
17
|
-
import { isLocalSpec, isPackageName, issuesPage, isTarball, isVerified, verifiedScope } from "../packages/index.js";
|
|
18
|
-
import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder, systemWords } from "../systems/index.js";
|
|
19
|
-
import { exportAdventure, installAdventure, installedAdventures, isAdventureSpec, readAdventureSpec, removeAdventure, storyTouching } from "./shared/adventures.js";
|
|
20
|
-
import { campaignExamples } from "./shared/examples.js";
|
|
21
|
-
import { campaignMode } from "./shared/mode.js";
|
|
22
|
-
import { loadCampaignCode, loadNewSystemCode, packageCommandNames, packagesInstalled } from "./shared/packages/code.js";
|
|
23
|
-
import { listedExtensions, runsCode } from "./shared/packages/extensions.js";
|
|
24
|
-
import { newDatedLogEntry } from "./shared/time.js";
|
|
25
|
-
import { campaignWorld } from "./shared/world.js";
|
|
26
|
-
/** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
|
|
27
|
-
export class YesRefused extends Refusal {
|
|
28
|
-
constructor(message, code, values = {}) {
|
|
29
|
-
super(message, code, values);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export const packageCommand = defineCommand({
|
|
33
|
-
name: "package",
|
|
34
|
-
description: "The packages of the campaign: extensions such as weather, from npm, and adventures, as a .zip, a folder or a link with adventure.yaml. "
|
|
35
|
-
+ "list says those on this computer and those the campaign uses; available, those npm has, and updates. install adds or updates one, on this computer and in the campaign, "
|
|
36
|
-
+ "only once the player wants it; one not published by RPG Engine (@rpgengine/…) is someone else's: the player is asked in the host's form, or in a window of their computer. "
|
|
37
|
-
+ "An adventure is installed when you bring its hook into the story, once the player wants it as the next. "
|
|
38
|
-
+ "remove takes one out of the campaign; uninstall takes it off this computer; export writes the campaign's world, as it was at its start, as an adventure. "
|
|
39
|
-
+ "Example: package install weather.",
|
|
40
|
-
group: "campaign",
|
|
41
|
-
positionals: ["action", "name"],
|
|
42
|
-
slow: true,
|
|
43
|
-
input: z.object({
|
|
44
|
-
action: z.enum(["list", "available", "install", "remove", "uninstall", "export"]).describe("list, available, install, remove, uninstall or export"),
|
|
45
|
-
name: z.string().optional().describe("the package: its name alone for one of ours, such as weather; another's npm name with its scope, or npm:name without one, its version if wanted; a folder or a .tgz "
|
|
46
|
-
+ "file on this computer; an adventure's .zip, folder or https link; an adventure's title to remove it"),
|
|
47
|
-
author: z.string().min(1).optional().describe("export: who wrote the adventure, as the player wants it credited"),
|
|
48
|
-
license: z.string().min(1).optional().describe("export: the licence the player gives it, such as CC BY 4.0; without one, all rights are reserved"),
|
|
49
|
-
}),
|
|
50
|
-
async run(input, context) {
|
|
51
|
-
const root = requireCampaign(context.folder);
|
|
52
|
-
if (input.action === "list") {
|
|
53
|
-
return listed(root, context);
|
|
54
|
-
}
|
|
55
|
-
if (input.action === "available") {
|
|
56
|
-
return await available(context);
|
|
57
|
-
}
|
|
58
|
-
if (input.action === "export") {
|
|
59
|
-
return { kind: "exported", ...exportAdventure(root, context, { author: input.author, license: input.license }) };
|
|
60
|
-
}
|
|
61
|
-
const name = input.name?.trim();
|
|
62
|
-
if (name === undefined || name === "") {
|
|
63
|
-
throw new Error(`Give the package to ${input.action}, such as package ${input.action} weather.`);
|
|
64
|
-
}
|
|
65
|
-
if (input.action === "install") {
|
|
66
|
-
return isAdventureSpec(name) ? await adventureInstalled(root, context, name) : await installed(root, context, name);
|
|
67
|
-
}
|
|
68
|
-
const adventure = installedAdventures(root).find((one) => comparableText(one.title) === comparableText(name));
|
|
69
|
-
if (input.action === "remove" && adventure !== undefined) {
|
|
70
|
-
removeAdventure(root, context, adventure);
|
|
71
|
-
return { kind: "adventure-removed", title: adventure.title };
|
|
72
|
-
}
|
|
73
|
-
return input.action === "remove" ? removed(root, context, name) : await uninstalled(root, context, name);
|
|
74
|
-
},
|
|
75
|
-
format(result) {
|
|
76
|
-
if (result.kind === "adventure-installed") {
|
|
77
|
-
return adventureText(result);
|
|
78
|
-
}
|
|
79
|
-
if (result.kind === "adventure-removed") {
|
|
80
|
-
return `${result.title} is out of the campaign, with the files it wrote.`;
|
|
81
|
-
}
|
|
82
|
-
if (result.kind === "exported") {
|
|
83
|
-
return exportText(result);
|
|
84
|
-
}
|
|
85
|
-
if (result.kind === "language-installed") {
|
|
86
|
-
const { language } = result;
|
|
87
|
-
return [
|
|
88
|
-
`Installed ${language.name} (${language.code}) ${language.version}, the dashboard's words made by hand${language.verified ? "" : ", by someone else"}, for every campaign on this computer.`,
|
|
89
|
-
result.replaced === undefined ? "" : `It takes the place of ${result.replaced}.`,
|
|
90
|
-
result.missing === 0 ? "" : `The ${result.missing} phrases it lacks stay as the dashboard has them, its own or translated on the fly.`,
|
|
91
|
-
].filter((line) => line !== "").join(" ");
|
|
92
|
-
}
|
|
93
|
-
if (result.kind === "system-installed") {
|
|
94
|
-
const { system } = result;
|
|
95
|
-
return [
|
|
96
|
-
`Installed the game system ${system.name}${system.version === undefined ? "" : ` ${system.version}`}, ${system.title}${system.verified ? "" : ", not verified: at the player's risk"}.`,
|
|
97
|
-
// In a setup with no system yet, the one just installed is chosen next (D-513 (1)).
|
|
98
|
-
system.used
|
|
99
|
-
? "The campaign plays it."
|
|
100
|
-
: result.plays === undefined
|
|
101
|
-
? `The campaign has no system yet: if the player chose this one, set it with config, setting system, value ${system.name}.`
|
|
102
|
-
: `It is for a new campaign, chosen in its setup: this one plays ${result.plays}.`,
|
|
103
|
-
!system.code ? "" : result.plays === undefined ? "Its code runs once config sets it." : codeText(result.loaded),
|
|
104
|
-
].filter((line) => line !== "").join(" ");
|
|
105
|
-
}
|
|
106
|
-
if (result.kind === "removed") {
|
|
107
|
-
return `The campaign no longer uses ${result.name}: its commands and its parts of your instructions are gone; what it kept in the campaign stays, and comes back if it is installed again.`;
|
|
108
|
-
}
|
|
109
|
-
if (result.kind === "uninstalled") {
|
|
110
|
-
return result.extension
|
|
111
|
-
? `${result.name} is off this computer${result.wasUsed ? ", and the campaign no longer uses it" : ""}: another campaign that lists it asks to install it again.`
|
|
112
|
-
: `${result.name} is off this computer.`;
|
|
113
|
-
}
|
|
114
|
-
if (result.kind === "installed") {
|
|
115
|
-
const { extension } = result;
|
|
116
|
-
const what = `${extension.name} ${extension.version}${result.verified ? ", verified" : ", not verified: at the player's risk"}`;
|
|
117
|
-
const said = [
|
|
118
|
-
`${result.already ? `The campaign already uses ${what}` : `Installed ${what}, and the campaign uses it`}: ${extension.about}.`,
|
|
119
|
-
result.codeLeftOut ? "Its code is not used: the player's yes holds for another version or other files; install it again for their yes." : "",
|
|
120
|
-
result.commands.length === 0 ? "" : `Its commands: ${result.commands.join(", ")}.${result.tools === "" ? "" : ` ${result.tools}`}`,
|
|
121
|
-
Object.keys(extension.parts).length === 0 ? "" : `Its parts of your instructions are given when they apply: ${Object.keys(extension.parts).join(", ")}.`,
|
|
122
|
-
].filter((line) => line !== "").join(" ");
|
|
123
|
-
return result.part === undefined ? said : `${said}\n\nIts part for now:\n\n${result.part}`;
|
|
124
|
-
}
|
|
125
|
-
if (result.kind === "available") {
|
|
126
|
-
if (result.failed !== undefined) {
|
|
127
|
-
return `npm could not be asked: ${result.failed}.`;
|
|
128
|
-
}
|
|
129
|
-
const lines = result.packages.map((one) => {
|
|
130
|
-
const here = one.installed === undefined ? "" : one.update ? `, installed ${one.installed}: an update` : ", installed";
|
|
131
|
-
const by = one.author === undefined ? "" : ` by ${one.author}`;
|
|
132
|
-
const newer = one.newer === undefined ? "" : ` (its ${one.newer.version} needs ${one.newer.engine === undefined ? "a newer rpg-engine" : `rpg-engine ${one.newer.engine}`})`;
|
|
133
|
-
return `${one.name} ${one.version}${one.verified ? "" : " (not verified)"}${by}${here}${newer}${one.description === undefined ? "" : `: ${one.description.replace(/\.$/, "")}`}`;
|
|
134
|
-
});
|
|
135
|
-
return `On npm: ${lines.length === 0 ? "none" : lines.join("; ")}.`;
|
|
136
|
-
}
|
|
137
|
-
const installedLines = result.installed.map((one) => "broken" in one ? `${one.name} (broken: ${one.broken}; install it again)` : `${one.name} ${one.version}${one.verified ? "" : " (not verified)"}${one.used ? ", used by the campaign" : ""}`);
|
|
138
|
-
return [
|
|
139
|
-
`On this computer: ${installedLines.length === 0 ? "none" : installedLines.join("; ")}.`,
|
|
140
|
-
result.missing.length === 0 ? "" : `The campaign lists, not installed here: ${result.missing.join(", ")}; install each with package install.`,
|
|
141
|
-
result.adventures.length === 0 ? "" : `Its adventures: ${result.adventures.map((one) => `${one.title} ${one.version}${one.since === undefined ? "" : `, since ${one.since}`}`).join("; ")}.`,
|
|
142
|
-
"package available says those npm has, and updates.",
|
|
143
|
-
].filter((line) => line !== "").join("\n");
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
/**
|
|
147
|
-
* Installs the game system the campaign in this context's folder plays, when it is one of ours that is not on this computer, as package install does, from
|
|
148
|
-
* npm's cache when the registry does not answer, then loads its code (SYS-10, D-514 (3)); once for each system, as `tried` keeps them. The line that says
|
|
149
|
-
* so to the master, or why it could not; undefined when there is no campaign or nothing to install, and for a system not ours, which asks the player's yes.
|
|
150
|
-
*/
|
|
151
|
-
export async function installCampaignSystem(context, tried) {
|
|
152
|
-
const packages = context.packages;
|
|
153
|
-
return packages === undefined ? undefined : await withFiles(context.files ?? new FileStore(context.systemFolders), async () => {
|
|
154
|
-
const root = findCampaign(context.folder);
|
|
155
|
-
const name = root === undefined ? undefined : readTextSetting(root, "system");
|
|
156
|
-
const ours = name === undefined ? undefined : ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
|
|
157
|
-
// Each system is looked for once: one here stays, as package uninstall keeps the one the campaign plays.
|
|
158
|
-
if (root === undefined || ours === undefined || tried.has(ours.name)) {
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
tried.add(ours.name);
|
|
162
|
-
if (isSystemHere(context, ours.name)) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
let result;
|
|
166
|
-
try {
|
|
167
|
-
// As package install, which loads the code of the system the campaign plays.
|
|
168
|
-
result = await installed(root, context, ours.package);
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
// npm's why, without what package install adds for the master, and without its period: the master tells the player, and the player chooses (D-514 (3)).
|
|
172
|
-
const why = (error instanceof Error ? error.message : String(error)).replace(/^\S+ could not be installed: /, "").replace(/\s*Nothing changed[^.]*\.$/, "").replace(/\.$/, "");
|
|
173
|
-
return `The campaign's game system, ${ours.name}, is not on this computer, and could not be installed: ${why}. Tell the player off-game, in brackets and in a table's words, `
|
|
174
|
-
+ `that this computer lacks the ${ours.name} rules and could not download them: once it is online, you install them with package install ${ours.name}, no yes needed. `
|
|
175
|
-
+ "Until then you play without its pages and the sheet's worked-out numbers, or wait, as the player chooses.";
|
|
176
|
-
}
|
|
177
|
-
const version = result.kind === "system-installed" && result.system.version !== undefined ? ` ${result.system.version}` : "";
|
|
178
|
-
return `The campaign's game system, ${ours.name}, was not on this computer: RPG Engine installed it, ${ours.package}${version}, one of its own. Its pages and rules are there from now.`
|
|
179
|
-
+ namesNote(root, context, ours.name);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
/** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
|
|
183
|
-
export function isInstalledPackage(context, name) {
|
|
184
|
-
const asked = name.startsWith("npm:") ? name.slice(4) : name.startsWith("@") ? name : `${verifiedScope}${name}`;
|
|
185
|
-
// An npm name only, never a path that climbs to npm's own folder (D-510).
|
|
186
|
-
return [asked, name].some((one) => isPackageName(one) && installedExtensionFolder(context, one) !== undefined);
|
|
187
|
-
}
|
|
188
|
-
/** What the master hears of an adventure installed (D-483 (5)): what it is in a few lines, then what to read and where it starts, never its text. */
|
|
189
|
-
export function adventureText(result) {
|
|
190
|
-
const { manifest } = result;
|
|
191
|
-
const by = manifest.author === undefined ? "" : ` by ${manifest.author}`;
|
|
192
|
-
const rights = manifest.license ?? "all rights reserved";
|
|
193
|
-
const counts = Object.entries(result.counts).map(([kind, count]) => `${count} ${kind}`).join(", ");
|
|
194
|
-
const levels = manifest.levels === undefined ? undefined : manifest.levels.from === manifest.levels.to ? `level ${manifest.levels.from}` : `levels ${manifest.levels.from}-${manifest.levels.to}`;
|
|
195
|
-
const start = result.start === undefined
|
|
196
|
-
? ""
|
|
197
|
-
: result.start.placed
|
|
198
|
-
? ` It starts in [[${result.start.name}]].`
|
|
199
|
-
: ` It starts in [[${result.start.name}]], in no place of the world yet: write it into the place that holds it, or give it a position, and a road from where it is reached.`;
|
|
200
|
-
const read = manifest.opening === undefined ? "Read its places and quests" : `Show [[${manifest.opening}]] and the pages it says to read first`;
|
|
201
|
-
return [
|
|
202
|
-
`${result.already ? "The campaign already has" : "Installed"} the adventure ${manifest.title} ${manifest.version}${by} (${rights}): ${manifest.about.replace(/\.$/, "")}. ${counts}.`,
|
|
203
|
-
levels === undefined ? "" : `It is written for ${levels}: adapt it to the party's.`,
|
|
204
|
-
manifest.content.length === 0 ? "" : `Its content: ${manifest.content.join(", ")}; keep to the player's lines and veils.`,
|
|
205
|
-
result.firstDate === undefined
|
|
206
|
-
? ""
|
|
207
|
-
: result.shift === 0
|
|
208
|
-
? `Its first date: [[${result.firstDate.page}]], on ${result.firstDate.date}.`
|
|
209
|
-
: `Its dates moved ${result.shift} days: the first, [[${result.firstDate.page}]], on ${result.firstDate.date}.`,
|
|
210
|
-
result.textDates === 0 ? "" : result.textDates === 1 ? "1 date in its text stays as written: count it from today." : `${result.textDates} dates in its text stay as written: count them from today.`,
|
|
211
|
-
result.shadows.length === 0 ? "" : `Its pages take the place of the game system's: ${result.shadows.join(", ")}.`,
|
|
212
|
-
result.covers.length === 0 ? "" : `Its rules take the place of the game system's: ${result.covers.join(", ")}.`,
|
|
213
|
-
result.ignored.length === 0 ? "" : `Left out, no part of an adventure: ${result.ignored.join(", ")}.`,
|
|
214
|
-
`${read} before you narrate.${start} Bring a hook into the story: the adventure begins when the player takes it.`,
|
|
215
|
-
].filter((line) => line !== "").join(" ");
|
|
216
|
-
}
|
|
217
|
-
/** The packages on this computer, and those the campaign lists and does not find there: at once, without npm (D-442). */
|
|
218
|
-
function listed(root, context) {
|
|
219
|
-
const used = Object.keys(listedExtensions(root));
|
|
220
|
-
const here = installedExtensions(context.extensionFolders ?? []).map((found) => {
|
|
221
|
-
const issues = issuesOf(found.folder);
|
|
222
|
-
try {
|
|
223
|
-
const extension = readExtension(found.folder);
|
|
224
|
-
return {
|
|
225
|
-
name: extension.name,
|
|
226
|
-
package: extension.package,
|
|
227
|
-
version: extension.version,
|
|
228
|
-
title: extension.title,
|
|
229
|
-
about: extension.about,
|
|
230
|
-
verified: isVerified(extension.package, extension.linked),
|
|
231
|
-
used: used.includes(extension.package),
|
|
232
|
-
...issues,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
return { name: shortName(found.package), package: found.package, broken: error instanceof Error ? error.message : String(error), ...issues };
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
const adventures = installedAdventures(root).map((one) => ({ title: one.title, version: one.version, ...(one.since === undefined ? {} : { since: one.since }), removable: storyTouching(root, one) === undefined }));
|
|
240
|
-
return { kind: "list", installed: here, missing: used.filter((name) => !here.some((one) => one.package === name)), adventures, systems: systemsHere(root, context), languages: languagesHere(context) };
|
|
241
|
-
}
|
|
242
|
-
/** The extensions npm has for this rpg-engine's API, ours first, each with the version installed here and whether npm has a newer one (D-442). */
|
|
243
|
-
async function available(context) {
|
|
244
|
-
const searched = context.packages === undefined ? { failed: "only the game's server and the command line reach npm" } : await context.packages.search();
|
|
245
|
-
if ("failed" in searched) {
|
|
246
|
-
return { kind: "available", packages: [], failed: searched.failed };
|
|
247
|
-
}
|
|
248
|
-
const here = installedExtensions(context.extensionFolders ?? []);
|
|
249
|
-
const packages = searched.filter((one) => one.kind === "extension" && readsApi(one.api, "extension")).map((one) => {
|
|
250
|
-
const installed = here.find((found) => found.package === one.name);
|
|
251
|
-
const copy = installed === undefined ? undefined : usable(context, one.name);
|
|
252
|
-
const version = copy?.version;
|
|
253
|
-
return {
|
|
254
|
-
name: shortName(one.name),
|
|
255
|
-
package: one.name,
|
|
256
|
-
version: one.version,
|
|
257
|
-
...(one.description === undefined ? {} : { description: one.description }),
|
|
258
|
-
...(one.author === undefined ? {} : { author: one.author }),
|
|
259
|
-
// What npm has is ours by its scope; the copy here is not, when a file or a folder of this computer took its place (D-452).
|
|
260
|
-
verified: isVerified(one.name, copy?.linked ?? false),
|
|
261
|
-
...(installed === undefined ? {} : { installed: version ?? "broken" }),
|
|
262
|
-
update: version !== undefined && isNewerVersion(one.version, version),
|
|
263
|
-
...(one.newer === undefined ? {} : { newer: one.newer }),
|
|
264
|
-
};
|
|
265
|
-
});
|
|
266
|
-
return { kind: "available", packages: packages.sort((first, second) => Number(second.verified) - Number(first.verified) || first.name.localeCompare(second.name)) };
|
|
267
|
-
}
|
|
268
|
-
/** The npm names of ours a name alone may be, with its version if given: an extension's, then a game system's; a system of the engine's list first (D-513). */
|
|
269
|
-
function ourNames(name) {
|
|
270
|
-
const names = [`${verifiedScope}${name}`, `${verifiedScope}system-${name}`];
|
|
271
|
-
const bare = name.replace(/(?<=.)@[^@/]*$/, "");
|
|
272
|
-
return ourSystems.some((system) => comparableText(system.name) === comparableText(bare)) ? [names[1], names[0]] : names;
|
|
273
|
-
}
|
|
274
|
-
/** Installs a package on this computer and adds it to the campaign (D-27, D-428, D-441): ours, or another once the player wants it; an extension, for this game. */
|
|
275
|
-
async function installed(root, context, name) {
|
|
276
|
-
const packages = context.packages;
|
|
277
|
-
if (packages === undefined) {
|
|
278
|
-
throw new Error("Packages are installed only by the game's server or the command line, which reach npm.");
|
|
279
|
-
}
|
|
280
|
-
// A name alone is one of ours: weather is @rpgengine/weather, never a stranger's of that name, which is given as npm:weather; or our game system's, as 5e
|
|
281
|
-
// is @rpgengine/system-5e (D-513).
|
|
282
|
-
const [first, second] = name.startsWith("npm:") ? [name.slice(4)] : isLocalSpec(name) || name.startsWith("@") ? [name] : ourNames(name);
|
|
283
|
-
const tried = await packages.describe(first);
|
|
284
|
-
const other = second !== undefined && "failed" in tried && tried.missing === true ? await packages.describe(second) : undefined;
|
|
285
|
-
const [asked, described] = second !== undefined && other !== undefined && !("failed" in other && other.missing === true) ? [second, other] : [first, tried];
|
|
286
|
-
if ("failed" in described) {
|
|
287
|
-
const message = `${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`;
|
|
288
|
-
throw isLocalSpec(asked)
|
|
289
|
-
? new Refusal(message, "not-on-computer", { name })
|
|
290
|
-
: described.missing === true
|
|
291
|
-
? new Refusal(message, "not-found", { name })
|
|
292
|
-
: new Refusal(message, "npm-failed", { name, why: described.failed });
|
|
293
|
-
}
|
|
294
|
-
// npm is given the version described, which the player's yes was for: by its name alone, npm would keep the exact version it saved before.
|
|
295
|
-
const spec = isLocalSpec(asked) ? asked : `${described.name}@${described.version}`;
|
|
296
|
-
if (described.kind === "system") {
|
|
297
|
-
return await systemInstalled(root, context, spec, name, described);
|
|
298
|
-
}
|
|
299
|
-
if (described.kind === "language") {
|
|
300
|
-
return await languageInstalled(root, context, spec, described);
|
|
301
|
-
}
|
|
302
|
-
if (described.kind !== "extension") {
|
|
303
|
-
throw described.kind === undefined
|
|
304
|
-
? new Refusal(`${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed.`, "not-ours", { name: described.name })
|
|
305
|
-
: new Refusal(`${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed.`, "other-kind", {
|
|
306
|
-
name: described.name,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
const unread = apiProblem(described.api, "extension");
|
|
310
|
-
if (unread !== undefined) {
|
|
311
|
-
throw apiRefusal(described, unread);
|
|
312
|
-
}
|
|
313
|
-
const local = isLocalSpec(spec);
|
|
314
|
-
const before = usable(context, described.name);
|
|
315
|
-
if (!isVerified(described.name, local)) {
|
|
316
|
-
// A file or a folder says what it holds, and when it takes the place of a copy from npm, which is one for the whole computer (D-452).
|
|
317
|
-
const holds = local ? ` (${described.name} ${described.version}${described.author === undefined ? "" : `, by ${described.author}`})` : "";
|
|
318
|
-
const replaces = local && before !== undefined && !before.linked ? ` It takes the place of ${before.package} ${before.version} from npm, in every campaign on this computer.` : "";
|
|
319
|
-
await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, holds, replaces);
|
|
320
|
-
}
|
|
321
|
-
// A copy from a file or a folder never stands for the one npm has: asked by its name, npm's comes back.
|
|
322
|
-
// Another's whose code may not run is installed again before its yes is kept: the yes goes to npm's files, never to files changed since (D-478, D-510).
|
|
323
|
-
const reinstall = before === undefined || before.version !== described.version || local || before.linked || (!isVerified(described.name, local) && !runsCode(before));
|
|
324
|
-
if (reinstall) {
|
|
325
|
-
const why = await packages.install(spec);
|
|
326
|
-
if (why !== undefined) {
|
|
327
|
-
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed in the campaign.`, "install-failed", { name: described.name, why });
|
|
328
|
-
}
|
|
329
|
-
// npm wrote there: what the call read of those folders is read again, and the code anew.
|
|
330
|
-
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
331
|
-
packagesInstalled();
|
|
332
|
-
}
|
|
333
|
-
// By its whole name: another's skies is not ours, nor ours another's.
|
|
334
|
-
const installed = installedAs(context, described.name);
|
|
335
|
-
const extension = "extension" in installed ? installed.extension : undefined;
|
|
336
|
-
// What npm installed is not what the player said yes to, or no extension: it goes off this computer again, and never runs.
|
|
337
|
-
if (extension === undefined || extension.version !== described.version) {
|
|
338
|
-
await packages.uninstall(described.name);
|
|
339
|
-
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
340
|
-
const why = extension !== undefined
|
|
341
|
-
? `it is the version ${extension.version}, not the ${described.version} the player said yes to`
|
|
342
|
-
: "unread" in installed
|
|
343
|
-
? `its extension does not read: ${installed.unread}`
|
|
344
|
-
: "no extension of that name is where npm put it";
|
|
345
|
-
throw new Refusal(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`, "taken-off", {
|
|
346
|
-
name: described.name,
|
|
347
|
-
why,
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
// The player's yes holds for this version and these files, on this computer: its code runs on the server and in the page (D-478, D-510).
|
|
351
|
-
if (!isVerified(described.name, local) && !extension.linked) {
|
|
352
|
-
recordConsent(extension.folder, extension.package, extension.version);
|
|
353
|
-
}
|
|
354
|
-
const system = readTextSetting(root, "system");
|
|
355
|
-
if (extension.needs.system !== undefined && comparableText(extension.needs.system) !== comparableText(system ?? "")) {
|
|
356
|
-
throw new Refusal(`${extension.name} is installed on this computer, but it is for the game system ${extension.needs.system}, and the campaign plays ${system ?? "none"}: the campaign does not use it.`, "other-system", { name: extension.name, system: extension.needs.system, plays: system ?? "" });
|
|
357
|
-
}
|
|
358
|
-
// Its state, widgets and pictures go by its name, which the system's would share (D-514).
|
|
359
|
-
if (comparableText(extension.name) === comparableText(system ?? "")) {
|
|
360
|
-
throw new Refusal(`${extension.name} is installed on this computer, but it has the name of the game system the campaign plays: the campaign does not use it. Nothing changed in the campaign.`, "system-name", { name: extension.name });
|
|
361
|
-
}
|
|
362
|
-
const others = Object.keys(listedExtensions(root)).filter((other) => other !== extension.package && shortName(other) === extension.name);
|
|
363
|
-
if (others.length > 0) {
|
|
364
|
-
throw new Refusal(`The campaign uses ${others[0]}, with the same name, ${extension.name}: take it away with package remove ${others[0]} first. Nothing changed in the campaign.`, "same-name", {
|
|
365
|
-
name: extension.name,
|
|
366
|
-
other: others[0],
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
// Its code is checked before the campaign lists it: a package that would not work is never added.
|
|
370
|
-
const commands = runsCode(extension)
|
|
371
|
-
? await packageCommandNames(extension, context).catch((error) => {
|
|
372
|
-
const why = error instanceof Error ? error.message : String(error);
|
|
373
|
-
throw new Refusal(`The code of ${extension.package} cannot be used: ${why}. Nothing changed in the campaign.`, "code-broken", { name: extension.package, why });
|
|
374
|
-
})
|
|
375
|
-
: [];
|
|
376
|
-
const listedBefore = listedExtensions(root);
|
|
377
|
-
const already = listedBefore[extension.package] === extension.version && !reinstall;
|
|
378
|
-
const verified = isVerified(extension.package, extension.linked);
|
|
379
|
-
if (listedBefore[extension.package] !== extension.version) {
|
|
380
|
-
changeExtensions(root, { ...listedBefore, [extension.package]: extension.version });
|
|
381
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: extension.package, version: extension.version, verified }));
|
|
382
|
-
}
|
|
383
|
-
// The campaign's code anew, the new one's included: their hooks are called at the next change, never skipped (D-514).
|
|
384
|
-
await loadCampaignCode(context);
|
|
385
|
-
return {
|
|
386
|
-
kind: "installed",
|
|
387
|
-
extension,
|
|
388
|
-
verified,
|
|
389
|
-
commands,
|
|
390
|
-
codeLeftOut: (extension.code !== undefined || extension.page !== undefined) && !runsCode(extension),
|
|
391
|
-
already,
|
|
392
|
-
...modePart(root, context, extension),
|
|
393
|
-
tools: toolsNote(context),
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Installs a game system on this computer (D-485), for a new campaign: the campaign keeps the one its setup chose. One not ours only with the player's yes,
|
|
398
|
-
* as an extension (D-441, D-478); a system that does not read is no system, whatever npm installed.
|
|
399
|
-
*/
|
|
400
|
-
async function systemInstalled(root, context, spec, name, described) {
|
|
401
|
-
const local = isLocalSpec(spec);
|
|
402
|
-
const named = shortName(described.name).replace(/^system-/, "");
|
|
403
|
-
const unread = apiProblem(described.api, "system");
|
|
404
|
-
if (unread !== undefined) {
|
|
405
|
-
throw apiRefusal(described, unread);
|
|
406
|
-
}
|
|
407
|
-
const taken = systemsHere(root, context).find((one) => comparableText(one.name) === comparableText(named) && one.package !== described.name);
|
|
408
|
-
if (taken !== undefined) {
|
|
409
|
-
throw new Refusal(`There is already a game system named ${taken.name} on this computer${taken.package === undefined ? ", the engine's own" : `, from ${taken.package}`}: ${described.name} would take its name. Nothing changed.`, "system-taken", { name: described.name, system: taken.name });
|
|
410
|
-
}
|
|
411
|
-
if (!isVerified(described.name, local)) {
|
|
412
|
-
await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, local ? ` (${described.name} ${described.version})` : "");
|
|
413
|
-
}
|
|
414
|
-
const why = await context.packages.install(spec);
|
|
415
|
-
if (why !== undefined) {
|
|
416
|
-
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
|
|
417
|
-
}
|
|
418
|
-
[...context.systemFolders, ...(context.extensionFolders ?? [])].forEach((folder) => files().refresh(folder));
|
|
419
|
-
const installed = installedExtensionFolder(context, described.name);
|
|
420
|
-
// The player's yes holds for this version and these files: its code runs at the next start of the game's server (D-478, D-511).
|
|
421
|
-
if (!isVerified(described.name, local) && !local && installed !== undefined) {
|
|
422
|
-
recordConsent(installed, described.name, described.version);
|
|
423
|
-
}
|
|
424
|
-
const system = systemsHere(root, context).find((one) => one.package === described.name);
|
|
425
|
-
if (system === undefined) {
|
|
426
|
-
throw new Refusal(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`, "system-unread", {
|
|
427
|
-
name: described.name,
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: system.verified, kind: "system" }));
|
|
431
|
-
const plays = readTextSetting(root, "system");
|
|
432
|
-
const loaded = system.used && system.code ? await loadedNow(context, system.name) : undefined;
|
|
433
|
-
return { kind: "system-installed", system, ...(plays === undefined ? {} : { plays }), ...(loaded === undefined ? {} : { loaded }) };
|
|
434
|
-
}
|
|
435
|
-
/** The code of the system the campaign plays, installed now, loaded at once when the process has none of it yet, as config system does (D-513 (1)). */
|
|
436
|
-
async function loadedNow(context, name) {
|
|
437
|
-
// A version the process has already loaded runs until it starts again.
|
|
438
|
-
const code = context.systemCode;
|
|
439
|
-
if (code === undefined || Object.hasOwn(code, name)) {
|
|
440
|
-
return undefined;
|
|
441
|
-
}
|
|
442
|
-
await loadNewSystemCode(context);
|
|
443
|
-
const loaded = code[name];
|
|
444
|
-
return loaded === undefined ? undefined : "code" in loaded ? { runs: true } : { why: "refused" in loaded ? `it ${loaded.refused}` : loaded.problem };
|
|
445
|
-
}
|
|
446
|
-
/** When the code of the system just installed runs, for the campaign that plays it. */
|
|
447
|
-
function codeText(loaded) {
|
|
448
|
-
return loaded === undefined ? "Its code runs from the next start of the game's server." : "runs" in loaded ? "Its code runs from now." : `Its code does not run: ${loaded.why.replace(/\.$/, "")}.`;
|
|
449
|
-
}
|
|
450
|
-
/** The game systems on this computer, those shipped with the engine first, with the package each came in when npm installed it (D-485). */
|
|
451
|
-
function systemsHere(root, context) {
|
|
452
|
-
const plays = readTextSetting(root, "system") ?? "";
|
|
453
|
-
const language = readTextSetting(root, "language");
|
|
454
|
-
const folders = systemFolders(context.systemFolders);
|
|
455
|
-
return readableSystems(context.systemFolders).map((system) => {
|
|
456
|
-
const manifest = packageOf(folders.find((one) => one.name === system.name)?.folder ?? system.folder);
|
|
457
|
-
// The engine's own have no package of their own here; one npm installed is ours only by our scope, and never from a folder (D-441).
|
|
458
|
-
const shipped = isInside(engineSystemsFolder, system.folder);
|
|
459
|
-
const linked = installedFromFolder(system.folder);
|
|
460
|
-
return {
|
|
461
|
-
name: system.name,
|
|
462
|
-
title: language === undefined ? system.title : titleIn(system.folder, system.title, language),
|
|
463
|
-
...(manifest === undefined ? {} : { version: manifest.version }),
|
|
464
|
-
...(manifest === undefined || shipped ? {} : { package: manifest.name }),
|
|
465
|
-
verified: shipped || (manifest !== undefined && isVerified(manifest.name, linked)),
|
|
466
|
-
used: comparableText(system.name) === comparableText(plays),
|
|
467
|
-
code: systemHasCode(system.folder),
|
|
468
|
-
// The engine's own are reported where the engine is: its package.json is in the folder above its systems.
|
|
469
|
-
...issuesOf(shipped ? join(engineSystemsFolder, "..") : system.folder),
|
|
470
|
-
};
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
/** A system's title in the campaign's language, as its own words give it; as it is where they do not, or do not read. */
|
|
474
|
-
function titleIn(folder, title, language) {
|
|
475
|
-
try {
|
|
476
|
-
return systemWords(folder, language)?.words[title] ?? title;
|
|
477
|
-
}
|
|
478
|
-
catch {
|
|
479
|
-
return title;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
/** Where the package in this folder takes reports of its problems, as its package.json says; nothing when it says none or has none that reads. */
|
|
483
|
-
function issuesOf(folder) {
|
|
484
|
-
try {
|
|
485
|
-
const issues = issuesPage(JSON.parse(files().text(join(folder, "package.json")) ?? ""));
|
|
486
|
-
return issues === undefined ? {} : { issues };
|
|
487
|
-
}
|
|
488
|
-
catch {
|
|
489
|
-
return {};
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
/** The name and the version a package.json in this folder gives; undefined when it has none that reads. */
|
|
493
|
-
function packageOf(folder) {
|
|
494
|
-
try {
|
|
495
|
-
const read = JSON.parse(files().text(join(folder, "package.json")) ?? "");
|
|
496
|
-
return typeof read.name === "string" && typeof read.version === "string" ? { name: read.name, version: read.version } : undefined;
|
|
497
|
-
}
|
|
498
|
-
catch {
|
|
499
|
-
return undefined;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Installs a language package on this computer (D-485 (3)): texts the dashboard shows, never code, so no yes is asked; refused, and taken off again, when its
|
|
504
|
-
* phrases lose a {name} or turn the order of a text. It takes the place of another package of the same language.
|
|
505
|
-
*/
|
|
506
|
-
async function languageInstalled(root, context, spec, described) {
|
|
507
|
-
if (described.code === true || described.dependencies === true) {
|
|
508
|
-
throw new Refusal(`${described.name} says it is a language, and brings code or needs other packages: a language package is texts only. Nothing changed.`, "language-code", {
|
|
509
|
-
name: described.name,
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
const before = installedLanguages(context.extensionFolders ?? []);
|
|
513
|
-
const packages = context.packages;
|
|
514
|
-
const why = await packages.install(spec);
|
|
515
|
-
if (why !== undefined) {
|
|
516
|
-
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
|
|
517
|
-
}
|
|
518
|
-
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
519
|
-
const folder = installedExtensionFolder(context, described.name);
|
|
520
|
-
let checked;
|
|
521
|
-
let pack;
|
|
522
|
-
try {
|
|
523
|
-
pack = readLanguagePack(folder ?? "");
|
|
524
|
-
checked = languagePackProblems(pack, Object.keys(pagePhrases(context)));
|
|
525
|
-
}
|
|
526
|
-
catch (error) {
|
|
527
|
-
checked = { problems: [error instanceof Error ? error.message : String(error)], missing: 0 };
|
|
528
|
-
pack = { package: described.name, version: described.version, folder: folder ?? "", code: "", name: described.name };
|
|
529
|
-
}
|
|
530
|
-
if (checked.problems.length > 0) {
|
|
531
|
-
await packages.uninstall(described.name);
|
|
532
|
-
// An update refused leaves the version that was there before.
|
|
533
|
-
const earlier = before.find((one) => one.package === described.name);
|
|
534
|
-
const back = earlier === undefined || isLocalSpec(spec) ? undefined : await packages.install(`${earlier.package}@${earlier.version}`).then((why) => (why === undefined ? earlier.version : undefined));
|
|
535
|
-
(context.extensionFolders ?? []).forEach((one) => files().refresh(one));
|
|
536
|
-
const why = checked.problems.join("; ");
|
|
537
|
-
const message = `${described.name} cannot be used: ${why}. ${back === undefined ? "It was taken off this computer." : `Version ${back} stays.`}`;
|
|
538
|
-
throw back === undefined ? new Refusal(message, "language-refused", { name: described.name, why }) : new Refusal(message, "language-kept", { name: described.name, why, version: back });
|
|
539
|
-
}
|
|
540
|
-
// One language, one package: the one before for the same code goes (D-485 (3)).
|
|
541
|
-
const replaced = before.find((one) => one.code.toLowerCase() === pack.code.toLowerCase() && one.package !== described.name);
|
|
542
|
-
if (replaced !== undefined) {
|
|
543
|
-
await packages.uninstall(replaced.package);
|
|
544
|
-
(context.extensionFolders ?? []).forEach((one) => files().refresh(one));
|
|
545
|
-
}
|
|
546
|
-
const language = languagesHere(context).find((one) => one.package === described.name);
|
|
547
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: language.verified, kind: "language" }));
|
|
548
|
-
return { kind: "language-installed", language, ...(replaced === undefined ? {} : { replaced: replaced.package }), missing: checked.missing };
|
|
549
|
-
}
|
|
550
|
-
/** The language packages on this computer, one for each language (D-485 (3)). */
|
|
551
|
-
function languagesHere(context) {
|
|
552
|
-
return installedLanguages(context.extensionFolders ?? []).map((pack) => ({
|
|
553
|
-
code: pack.code,
|
|
554
|
-
name: pack.name,
|
|
555
|
-
package: pack.package,
|
|
556
|
-
version: pack.version,
|
|
557
|
-
verified: isVerified(pack.package, installedFromFolder(pack.folder)),
|
|
558
|
-
...issuesOf(pack.folder),
|
|
559
|
-
}));
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* The names of a system just installed in the chat, which the host's list of tools may not have yet (D-518): its counter, its rest and its coins, those that
|
|
563
|
-
* are not the neutral ones; nothing when it names none of them.
|
|
564
|
-
*/
|
|
565
|
-
function namesNote(root, context, system) {
|
|
566
|
-
let examples;
|
|
567
|
-
try {
|
|
568
|
-
examples = campaignExamples(root, context);
|
|
569
|
-
}
|
|
570
|
-
catch {
|
|
571
|
-
return "";
|
|
572
|
-
}
|
|
573
|
-
const own = (name) => (examples[name] === neutralExamples[name] ? undefined : examples[name]);
|
|
574
|
-
const coins = [own("coin"), own("smallCoin")].filter((coin) => coin !== undefined).join(" and ");
|
|
575
|
-
const counter = own("counter");
|
|
576
|
-
const names = [counter === undefined ? undefined : `${counter} for damage`, own("rest"), coins === "" ? undefined : coins].filter((name) => name !== undefined);
|
|
577
|
-
return names.length === 0 ? "" : ` The commands' descriptions may keep neutral examples until a new chat: in ${system} use its own names, such as ${names.join(", ")}.`;
|
|
578
|
-
}
|
|
579
|
-
/** Whether a game system by this name is on this computer; one whose system.yaml does not read is there too, and validate says why. */
|
|
580
|
-
function isSystemHere(context, name) {
|
|
581
|
-
try {
|
|
582
|
-
return findSystem(context.systemFolders, name) !== undefined;
|
|
583
|
-
}
|
|
584
|
-
catch {
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
/** The folder npm installed a package in, among the extensions' folders; undefined when it is not there. */
|
|
589
|
-
function installedExtensionFolder(context, name) {
|
|
590
|
-
return (context.extensionFolders ?? []).map((folder) => join(folder, ...name.split("/"))).find((folder) => files().exists(join(folder, "package.json")));
|
|
591
|
-
}
|
|
592
|
-
/** The dashboard's phrases, by their English, as its curated Italian lists them all; none where the built page is not here. */
|
|
593
|
-
function pagePhrases(context) {
|
|
594
|
-
try {
|
|
595
|
-
return JSON.parse(files().text(join(context.pageFolder ?? "", "i18n", "it.json")) ?? "{}");
|
|
596
|
-
}
|
|
597
|
-
catch {
|
|
598
|
-
return {};
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* The player's own yes to a package not ours (D-441, D-478), where the master cannot give it with its own tools: the host's form first, never the dashboard's
|
|
603
|
-
* page, whose click a local program can forge; else a window of their operating system; else none, and it throws.
|
|
604
|
-
*/
|
|
605
|
-
async function playerYes(context, name, pack, local, holds = "", replaces = "") {
|
|
606
|
-
// A no in a window holds for the package npm describes, however it was written, until the server starts again (D-510).
|
|
607
|
-
if (context.declined?.has(pack) === true) {
|
|
608
|
-
throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined", { name: pack });
|
|
609
|
-
}
|
|
610
|
-
// Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510). The package's own words cut short, so
|
|
611
|
-
// that a window, which shows so much at most, never loses the warning to them.
|
|
612
|
-
const clean = (text, most) => plainText(text.replace(/\s+/g, " "), most);
|
|
613
|
-
[name, holds] = [clean(name, 120), holds.trim() === "" ? "" : ` ${clean(holds, 160)}`];
|
|
614
|
-
const from = context.actor === "player" ? "the dashboard" : context.host === undefined ? "the command line" : "the chat";
|
|
615
|
-
const can = "Its code runs on this computer with your permissions, and in the dashboard, where it can see the whole campaign, its secrets included, and press buttons and speak to the master for you.";
|
|
616
|
-
const warning = local
|
|
617
|
-
? `Not verified by RPG Engine: ${name}${holds}, ${isTarball(name) ? "a file" : "a folder"} of this computer, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.${replaces}`
|
|
618
|
-
: `Not verified by RPG Engine: ${name}, from npm, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.`;
|
|
619
|
-
const question = `Install ${name}? ${warning}`;
|
|
620
|
-
const title = "A package not ours";
|
|
621
|
-
const answer = context.player === undefined ? "unavailable" : await context.player.choose(question, title, ["Install it, at my risk", "Do not install it"], context.signal);
|
|
622
|
-
if (answer === 0) {
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
if (answer === 1 || (typeof answer === "object" && answer !== null)) {
|
|
626
|
-
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
|
|
627
|
-
}
|
|
628
|
-
// Closed without an answer is no yes, never a reason to ask again some other way.
|
|
629
|
-
if (answer === undefined) {
|
|
630
|
-
throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined", { name });
|
|
631
|
-
}
|
|
632
|
-
const window = context.confirm === undefined ? "none" : await context.confirm.ask(title, question, context.signal);
|
|
633
|
-
if (window === "yes") {
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (window === "no") {
|
|
637
|
-
context.declined?.add(pack);
|
|
638
|
-
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
|
|
639
|
-
}
|
|
640
|
-
throw new YesRefused(`${warning} Only the player can say yes to it, in the host's form or in a window of their computer, and neither can be shown here (no desktop, as over SSH; `
|
|
641
|
-
+ `on Linux zenity or kdialog shows it): install it where one can be. Nothing changed.`, "no-window");
|
|
642
|
-
}
|
|
643
|
-
/** A package made for an API this engine does not read: one newer than the engine, which an update of the engine reads, or one older, which a newer version of it fixes. */
|
|
644
|
-
function apiRefusal(described, unread) {
|
|
645
|
-
const newer = described.api !== undefined && described.api > packageApi;
|
|
646
|
-
return new Refusal(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`, newer ? "engine-too-old" : "package-too-old", {
|
|
647
|
-
name: described.name,
|
|
648
|
-
version: described.version,
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
/** The installed extension of this package, when it reads; undefined when it is missing or broken. */
|
|
652
|
-
function usable(context, name) {
|
|
653
|
-
try {
|
|
654
|
-
return findExtension(context.extensionFolders ?? [], name);
|
|
655
|
-
}
|
|
656
|
-
catch {
|
|
657
|
-
return undefined;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
/** The extension npm installed by this whole name, or why it is none: not there under that name, or not read, with what is wrong. */
|
|
661
|
-
function installedAs(context, name) {
|
|
662
|
-
const found = installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name);
|
|
663
|
-
if (found === undefined) {
|
|
664
|
-
return { missing: true };
|
|
665
|
-
}
|
|
666
|
-
try {
|
|
667
|
-
return { extension: readExtension(found.folder) };
|
|
668
|
-
}
|
|
669
|
-
catch (error) {
|
|
670
|
-
return { unread: error instanceof Error ? error.message : String(error) };
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
/** Why a system npm installed is not among those that read: its system.yaml does not, or it has none. */
|
|
674
|
-
function unreadSystemWhy(folder, name) {
|
|
675
|
-
if (folder === undefined || !files().exists(join(folder, "system.yaml"))) {
|
|
676
|
-
return "it has no system.yaml: it is no game system";
|
|
677
|
-
}
|
|
678
|
-
try {
|
|
679
|
-
systemInFolder(folder, shortName(name).replace(/^system-/, ""));
|
|
680
|
-
return "it does not read as a game system";
|
|
681
|
-
}
|
|
682
|
-
catch (error) {
|
|
683
|
-
return `its system.yaml does not read: ${error instanceof Error ? error.message : String(error)}`;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
/** The extension's part of the instructions for the mode the campaign is in, which the chat going on has not been given. */
|
|
687
|
-
function modePart(root, context, extension) {
|
|
688
|
-
const mode = campaignMode(root, campaignWorld(root, context)).replace(" ", "-");
|
|
689
|
-
const part = extension.parts[mode]?.text;
|
|
690
|
-
return part === undefined ? {} : { part };
|
|
691
|
-
}
|
|
692
|
-
/** When the master can call the new commands: on the command line at once; in a chat, as the app in use hears new tools. */
|
|
693
|
-
function toolsNote(context) {
|
|
694
|
-
const host = context.host?.() ?? "";
|
|
695
|
-
if (context.host === undefined) {
|
|
696
|
-
return "";
|
|
697
|
-
}
|
|
698
|
-
if (/codex/i.test(host)) {
|
|
699
|
-
return "Codex sees them only once it is closed and opened again: tell the player.";
|
|
700
|
-
}
|
|
701
|
-
if (/claude-ai|claude desktop/i.test(host)) {
|
|
702
|
-
return "This app sees them only once it is closed and opened again: tell the player.";
|
|
703
|
-
}
|
|
704
|
-
return "They are yours from the player's next message.";
|
|
705
|
-
}
|
|
706
|
-
/** Takes an extension out of the campaign; it stays on this computer, for other campaigns. */
|
|
707
|
-
function removed(root, context, name) {
|
|
708
|
-
const listed = listedExtensions(root);
|
|
709
|
-
const found = Object.keys(listed).find((candidate) => candidate === name || comparableText(shortName(candidate)) === comparableText(name));
|
|
710
|
-
if (found === undefined) {
|
|
711
|
-
const names = Object.keys(listed).map(shortName);
|
|
712
|
-
throw new Refusal(`The campaign does not use ${name}${names.length === 0 ? ": it uses no package" : `; it uses ${names.join(", ")}`}. Nothing changed.`, "not-used", { name });
|
|
713
|
-
}
|
|
714
|
-
const rest = Object.fromEntries(Object.entries(listed).filter(([candidate]) => candidate !== found));
|
|
715
|
-
changeExtensions(root, rest);
|
|
716
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "package-removed", "public", { package: found }));
|
|
717
|
-
return { kind: "removed", name: shortName(found) };
|
|
718
|
-
}
|
|
719
|
-
/** Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. */
|
|
720
|
-
async function uninstalled(root, context, name) {
|
|
721
|
-
const packages = context.packages;
|
|
722
|
-
const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === name || comparableText(one.name) === comparableText(name)));
|
|
723
|
-
if (system?.used === true) {
|
|
724
|
-
throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
|
|
725
|
-
}
|
|
726
|
-
const other = system?.package ?? languagesHere(context).find((one) => one.package === name || comparableText(one.code) === comparableText(name))?.package;
|
|
727
|
-
const found = other === undefined
|
|
728
|
-
? installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name || comparableText(shortName(one.package)) === comparableText(name))
|
|
729
|
-
: { package: other };
|
|
730
|
-
// A package that reads as nothing, as a system whose system.yaml is broken, is still npm's to take away by its folder, under its npm name.
|
|
731
|
-
const npmName = name.startsWith("npm:") ? name.slice(4) : name;
|
|
732
|
-
if (found === undefined && packages !== undefined && isPackageName(npmName) && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0)) {
|
|
733
|
-
const why = await packages.uninstall(npmName);
|
|
734
|
-
if (why !== undefined) {
|
|
735
|
-
throw new Refusal(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`, "uninstall-failed", { name: npmName, why });
|
|
736
|
-
}
|
|
737
|
-
return { kind: "uninstalled", name: npmName, wasUsed: false, extension: false };
|
|
738
|
-
}
|
|
739
|
-
if (found === undefined) {
|
|
740
|
-
const here = installedExtensions(context.extensionFolders ?? []).map((one) => shortName(one.package));
|
|
741
|
-
throw new Refusal(`${name} is not on this computer${here.length === 0 ? ": no package is" : `; these are: ${here.join(", ")}`}. Nothing changed.`, "not-here", { name });
|
|
742
|
-
}
|
|
743
|
-
if (packages === undefined) {
|
|
744
|
-
throw new Error("Packages are uninstalled only by the game's server or the command line, which reach npm.");
|
|
745
|
-
}
|
|
746
|
-
const folder = installedExtensionFolder(context, found.package);
|
|
747
|
-
const why = await packages.uninstall(found.package);
|
|
748
|
-
if (why !== undefined) {
|
|
749
|
-
throw new Refusal(`${found.package} could not be uninstalled: ${why}. Nothing changed.`, "uninstall-failed", { name: found.package, why });
|
|
750
|
-
}
|
|
751
|
-
// Off this computer, its yes goes with it: installed again, it is asked again.
|
|
752
|
-
if (folder !== undefined) {
|
|
753
|
-
dropConsent(folder, found.package);
|
|
754
|
-
}
|
|
755
|
-
[...context.systemFolders, ...(context.extensionFolders ?? [])].forEach((folder) => files().refresh(folder));
|
|
756
|
-
const listed = listedExtensions(root);
|
|
757
|
-
const wasUsed = Object.hasOwn(listed, found.package);
|
|
758
|
-
if (wasUsed) {
|
|
759
|
-
changeExtensions(root, Object.fromEntries(Object.entries(listed).filter(([candidate]) => candidate !== found.package)));
|
|
760
|
-
}
|
|
761
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "package-uninstalled", "public", { package: found.package }));
|
|
762
|
-
return { kind: "uninstalled", name: shortName(found.package), wasUsed, extension: other === undefined };
|
|
763
|
-
}
|
|
764
|
-
/** Installs an adventure from a .zip, a folder or a link (D-483): no npm, no code, and the same refusals wherever it comes from. */
|
|
765
|
-
async function adventureInstalled(root, context, spec) {
|
|
766
|
-
const adventure = await readAdventureSpec(spec, context);
|
|
767
|
-
return { kind: "adventure-installed", ...installAdventure(root, context, adventure, spec) };
|
|
768
|
-
}
|
|
769
|
-
/** What the master hears of an export (ADV-7): the file, what it came from and what stayed out. */
|
|
770
|
-
function exportText(result) {
|
|
771
|
-
const out = [
|
|
772
|
-
result.leftOut.characters.length === 0 ? "" : `the player characters (${result.leftOut.characters.join(", ")})`,
|
|
773
|
-
result.leftOut.adventures.length === 0 ? "" : `the adventures it installed (${result.leftOut.adventures.join(", ")})`,
|
|
774
|
-
].filter((part) => part !== "");
|
|
775
|
-
return [
|
|
776
|
-
`Wrote ${result.file}: ${result.pages} pages, from ${result.from}${out.length === 0 ? "" : `, without ${out.join(" and ")}`}.`,
|
|
777
|
-
result.opening === undefined
|
|
778
|
-
? "It has no opening page: one tagged opening, with the situation, the hooks, what happens if no one steps in and the pages to read first, and its start, makes it ready."
|
|
779
|
-
: `Its opening is [[${result.opening}]].`,
|
|
780
|
-
result.sourced === undefined
|
|
781
|
-
? "The player shares it as a file, and only what they have the right to share."
|
|
782
|
-
: `${result.sourced.length} of its pages come from the player's own documents (source:): ${result.sourced.slice(0, 5).join(", ")}${result.sourced.length > 5 ? "…" : ""}. `
|
|
783
|
-
+ "So it says personal use only. Ask the player whether they may share it: only with the document's own license, or their rights to it; if so, export again with that license.",
|
|
784
|
-
].join(" ");
|
|
785
|
-
}
|