rpg-engine 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adventures/source.d.ts +3 -1
- package/dist/adventures/source.js +31 -1
- package/dist/campaign/find-campaign.js +8 -4
- 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 +68 -45
- 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 +270 -0
- package/dist/commands/package/result.d.ts +89 -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 +2 -2
- 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/books/adventure-layers.d.ts +89 -0
- package/dist/commands/shared/books/adventure-layers.js +201 -0
- package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +28 -9
- package/dist/commands/shared/{adventures.js → books/adventures.js} +77 -35
- 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} +9 -6
- package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +17 -7
- 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} +10 -8
- 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} +7 -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 +9 -0
- package/dist/commands/show.js +43 -10
- package/dist/commands/status.d.ts +2 -1
- package/dist/commands/status.js +28 -22
- package/dist/commands/thoughts.d.ts +1 -0
- package/dist/commands/thoughts.js +26 -18
- 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/layers.d.ts +34 -0
- package/dist/commands/view/layers.js +44 -0
- 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 +96 -0
- package/dist/commands/view/page.d.ts +32 -0
- package/dist/commands/view/page.js +166 -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 +252 -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 +29 -292
- package/dist/commands/view/view.js +31 -536
- 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 +185 -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 +44 -0
- package/dist/commands/write/layer.js +68 -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 +2 -0
- package/dist/commands/write/write.js +36 -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/core/text.d.ts +2 -0
- package/dist/core/text.js +4 -0
- 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 +19 -1
- package/dist/dashboard/app.js +51 -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 +7 -3
- package/dist/dashboard/guide/cs.md +9 -5
- package/dist/dashboard/guide/da.md +9 -5
- package/dist/dashboard/guide/de.md +7 -3
- package/dist/dashboard/guide/el.md +9 -5
- package/dist/dashboard/guide/en.md +4 -0
- package/dist/dashboard/guide/es.md +8 -4
- package/dist/dashboard/guide/fi.md +9 -5
- package/dist/dashboard/guide/fr.md +8 -4
- package/dist/dashboard/guide/he.md +7 -3
- package/dist/dashboard/guide/hi.md +10 -6
- package/dist/dashboard/guide/hu.md +8 -4
- package/dist/dashboard/guide/is.md +9 -5
- package/dist/dashboard/guide/it.md +5 -1
- package/dist/dashboard/guide/ja.md +9 -5
- package/dist/dashboard/guide/ko.md +8 -4
- package/dist/dashboard/guide/nb.md +8 -4
- package/dist/dashboard/guide/nl.md +8 -4
- package/dist/dashboard/guide/pl.md +8 -4
- package/dist/dashboard/guide/pt.md +7 -3
- package/dist/dashboard/guide/ro.md +9 -5
- package/dist/dashboard/guide/ru.md +8 -4
- package/dist/dashboard/guide/sv.md +9 -5
- package/dist/dashboard/guide/tr.md +9 -5
- package/dist/dashboard/guide/uk.md +8 -4
- package/dist/dashboard/guide/zh.md +8 -4
- package/dist/dashboard/help/help.js +3 -3
- package/dist/dashboard/i18n/ar.json +29 -0
- package/dist/dashboard/i18n/cs.json +29 -0
- package/dist/dashboard/i18n/da.json +29 -0
- package/dist/dashboard/i18n/de.json +29 -0
- package/dist/dashboard/i18n/el.json +29 -0
- package/dist/dashboard/i18n/es.json +29 -0
- package/dist/dashboard/i18n/fi.json +29 -0
- package/dist/dashboard/i18n/fr.json +29 -0
- package/dist/dashboard/i18n/he.json +29 -0
- package/dist/dashboard/i18n/hi.json +29 -0
- package/dist/dashboard/i18n/hu.json +29 -0
- package/dist/dashboard/i18n/is.json +29 -0
- package/dist/dashboard/i18n/it.json +29 -0
- package/dist/dashboard/i18n/ja.json +30 -1
- package/dist/dashboard/i18n/ko.json +29 -0
- package/dist/dashboard/i18n/nb.json +29 -0
- package/dist/dashboard/i18n/nl.json +29 -0
- package/dist/dashboard/i18n/pl.json +29 -0
- package/dist/dashboard/i18n/pt.json +29 -0
- package/dist/dashboard/i18n/ro.json +29 -0
- package/dist/dashboard/i18n/ru.json +29 -0
- package/dist/dashboard/i18n/sv.json +29 -0
- package/dist/dashboard/i18n/tr.json +29 -0
- package/dist/dashboard/i18n/uk.json +29 -0
- package/dist/dashboard/i18n/zh.json +29 -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/changes.js +111 -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 +27 -578
- 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/parts/changed.js +37 -0
- 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} +5 -1
- package/dist/dashboard/{status.js → parts/status.js} +4 -4
- package/dist/dashboard/{widgets.js → parts/widgets.js} +5 -3
- 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} +11 -10
- 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} +27 -24
- 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 +38 -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 +288 -4
- 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 +10 -6
- 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 +52 -0
- package/dist/pages/layers.js +105 -0
- package/dist/pages/markdown.d.ts +5 -1
- package/dist/pages/markdown.js +13 -1
- 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 +23 -0
- package/dist/pages/write-layer.js +162 -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.d.ts +2 -0
- package/dist/server/dashboard/choices.js +6 -4
- package/dist/server/dashboard/files.js +5 -5
- package/dist/server/dashboard/index.d.ts +2 -2
- package/dist/server/dashboard/index.js +7 -3
- package/dist/server/dashboard/news.js +4 -3
- package/dist/server/dashboard/player.js +1 -1
- package/dist/server/dashboard/writes.d.ts +7 -0
- package/dist/server/dashboard/writes.js +48 -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/instructions/voices.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
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { numberOf } from "../../core/formula.js";
|
|
2
|
+
import { appendLogEntry } from "../../core/log.js";
|
|
3
|
+
import { valueNamed } from "../../core/text.js";
|
|
4
|
+
import { readCounter } from "../../counters/index.js";
|
|
5
|
+
import { findPage, isPartyMember, linksIn, pagesWithName, parsePageReference } from "../../pages/index.js";
|
|
6
|
+
import { sceneTypes } from "../../scene/index.js";
|
|
7
|
+
import { formatGameDate } from "../../time/index.js";
|
|
8
|
+
import { firstInChat } from "../shared/campaign/parts.js";
|
|
9
|
+
import { isTickedOpenQuest, tickedQuestNote } from "../shared/campaign/quests.js";
|
|
10
|
+
import { isPlayerDead, makeSave, saveText } from "../shared/campaign/saves.js";
|
|
11
|
+
import { campaignSystem, campaignWorld } from "../shared/campaign/world.js";
|
|
12
|
+
import { clearCopies } from "../shared/places/grids.js";
|
|
13
|
+
import { endEffects, endsWithScene, keptBy } from "../shared/scene/effects.js";
|
|
14
|
+
import { fallenLine, isFallen } from "../shared/scene/loot.js";
|
|
15
|
+
import { copyPage, rawScene, readOpenScene, saveScene } from "../shared/scene/scene.js";
|
|
16
|
+
import { effectiveFields, effectsOf } from "../shared/sheet/effect-layer.js";
|
|
17
|
+
import { hasSheet, startingAtZero } from "../shared/sheet/system-fields.js";
|
|
18
|
+
import { newDatedLogEntry, readPresent } from "../shared/time/time.js";
|
|
19
|
+
import { copyMembers, logCopies, membersText } from "./members.js";
|
|
20
|
+
/** Ends the scene; one that cannot be read is closed too, so that a scene written wrongly by hand never blocks the game. */
|
|
21
|
+
export function close(root, world, summary, context) {
|
|
22
|
+
if (summary.trim() === "") {
|
|
23
|
+
throw new Error("Give the scene a summary of one or two sentences: what happened, as the player saw it.");
|
|
24
|
+
}
|
|
25
|
+
const { scene: current, problem } = readOpenScene(root);
|
|
26
|
+
if (current === undefined && problem === undefined) {
|
|
27
|
+
throw new Error("No scene is open: there is nothing to close.");
|
|
28
|
+
}
|
|
29
|
+
const present = readPresent(root).date;
|
|
30
|
+
const closed = present === undefined ? undefined : formatGameDate(present);
|
|
31
|
+
const raw = current === undefined ? rawScene(root) : undefined;
|
|
32
|
+
// Rounds exist only in the scene: the effects counted in them end with it, on the pages; the copies go with theirs, and with what they kept alive (D-145).
|
|
33
|
+
const keptByCopy = (effect) => current !== undefined && Object.keys(current.copies).some((name) => keptBy(effect, name));
|
|
34
|
+
// What the close says is worked out before anything is written: a page it cannot find stops it with the scene still open.
|
|
35
|
+
const endless = (current?.with ?? []).flatMap((link) => {
|
|
36
|
+
const page = findPage(world, parsePageReference(link).name);
|
|
37
|
+
return page === undefined ? [] : effectsOf(page).filter((effect) => effect.end === undefined && !keptByCopy(effect)).map((effect) => `${effect.name} on ${page.name}`);
|
|
38
|
+
});
|
|
39
|
+
const rewards = current === undefined ? [] : rewardLines(world, campaignSystem(root, context), current);
|
|
40
|
+
// What the fallen carried stays where they fell, a copy's read on its creature, which ends with the scene (D-530).
|
|
41
|
+
const fallen = current === undefined ? "" : fallenLine(fallenOf(world, campaignSystem(root, context), current));
|
|
42
|
+
// A scene that ends may end the story of a quest whose goals are all ticked: the master says whether it did (D-239).
|
|
43
|
+
const quests = world.pages.filter(isTickedOpenQuest).map(tickedQuestNote);
|
|
44
|
+
const ended = endEffects(root, context, world, undefined, (effect) => endsWithScene(effect) || keptByCopy(effect), "scene closed");
|
|
45
|
+
if (current !== undefined) {
|
|
46
|
+
clearCopies(campaignWorld(root, context), current, Object.keys(current.copies));
|
|
47
|
+
}
|
|
48
|
+
saveScene(root, undefined);
|
|
49
|
+
if (current === undefined) {
|
|
50
|
+
const titled = rawTitleAndType(raw);
|
|
51
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-closed", "public", { ...titled, closed, summary: summary.trim() }));
|
|
52
|
+
return { action: "close", copies: [], unreadable: problem?.message, ended, endless: [], quests, ...endOfSceneSave(root, context, world, titled.title) };
|
|
53
|
+
}
|
|
54
|
+
logCopies(root, context, current.title, current.copies);
|
|
55
|
+
const left = current.left?.filter((name) => pagesWithName(world, name).length > 0);
|
|
56
|
+
// Who the character saw without learning their name stays so after the scene (D-416).
|
|
57
|
+
const unnamed = current.seen === undefined ? undefined : Object.keys(current.seen);
|
|
58
|
+
const data = { title: current.title, type: current.type, place: current.place, with: current.with, left: left?.length === 0 ? undefined : left, unnamed, opened: current.opened, closed, rounds: current.round, summary: summary.trim() };
|
|
59
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-closed", "public", data));
|
|
60
|
+
// The copies that left during the scene, fled or fallen, end with it too: one that may come back needs a page now, with its wounds (D-246).
|
|
61
|
+
const gone = copyMembers(world, current.gone ?? {});
|
|
62
|
+
const saved = endOfSceneSave(root, context, world, current.title);
|
|
63
|
+
return {
|
|
64
|
+
action: "close",
|
|
65
|
+
title: current.title,
|
|
66
|
+
rounds: current.round,
|
|
67
|
+
copies: copyMembers(world, current.copies),
|
|
68
|
+
gone,
|
|
69
|
+
ended,
|
|
70
|
+
endless,
|
|
71
|
+
...(rewards.length === 0 ? {} : { rewards }),
|
|
72
|
+
...(fallen === "" ? {} : { fallen }),
|
|
73
|
+
...(peakEnded(current.type) && firstInChat(context, "after-peak") ? { afterPeak } : {}),
|
|
74
|
+
quests,
|
|
75
|
+
...saved,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The save at the end of a scene, named by its title (D-55, SAV-3): none while the player character is dead, since going back is what one is for. A save that
|
|
80
|
+
* cannot be written never stops the close, which is already done: it says why.
|
|
81
|
+
*/
|
|
82
|
+
function endOfSceneSave(root, context, world, title) {
|
|
83
|
+
if (isPlayerDead(world)) {
|
|
84
|
+
return { unsaved: "No save: the player character is dead. If the player wants to go back, save load, as the campaign's saves setting allows." };
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return { saved: saveText(makeSave(root, context, title, "scene closed")) };
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
91
|
+
return { unsaved: `No save: it could not be written (${reason}). Make .saves a folder that can be written; the next scene's end saves again.` };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* What the creatures overcome in a scene give the party there (DAT-11): for each reward of the system, the copies, also those that left, and the characters
|
|
96
|
+
* outside the party at its counter's value or below, or dead, with what each gives, shared, rounded down, among the living party members who were there and
|
|
97
|
+
* keep the sheet. Said with the calls to make, never given: a character may have been an ally, and who fled or was overcome another way is the master's to judge.
|
|
98
|
+
*/
|
|
99
|
+
function rewardLines(world, system, scene) {
|
|
100
|
+
const there = [...scene.with.map((link) => parsePageReference(link).name), ...(scene.left ?? [])].flatMap((name) => findPage(world, name) ?? []);
|
|
101
|
+
const party = there.filter((page, index) => there.indexOf(page) === index && isPartyMember(page) && page.fields.status !== "dead" && hasSheet(world, page));
|
|
102
|
+
const copies = [...Object.entries(scene.copies), ...Object.entries(scene.gone ?? {})].map(([name, copy]) => ({ page: copyPage(name, copy), left: name in (scene.gone ?? {}) }));
|
|
103
|
+
const others = [...copies, ...there.filter((page) => !isPartyMember(page)).map((page) => ({ page, left: (scene.left ?? []).includes(page.name) }))];
|
|
104
|
+
const read = (fields, field) => valueNamed(fields, field);
|
|
105
|
+
return (system?.rewards ?? []).flatMap((reward) => {
|
|
106
|
+
const worth = others.flatMap(({ page, left }) => {
|
|
107
|
+
const fields = effectiveFields(world, page);
|
|
108
|
+
const value = numberOf(read(fields, reward.from));
|
|
109
|
+
const counter = readCounter(read(fields, reward.counter))?.value;
|
|
110
|
+
const down = page.fields.status === "dead" || (counter !== undefined && counter <= reward.value);
|
|
111
|
+
return [{ name: page.name, kind: linksIn(page.fields.creature)[0] ?? page.name, worth: value ?? 0, given: value !== undefined, down, left, character: page.type === "character" }];
|
|
112
|
+
});
|
|
113
|
+
const overcome = worth.filter((item) => item.down && item.worth > 0);
|
|
114
|
+
const fled = worth.filter((item) => !item.down && item.left && item.worth > 0);
|
|
115
|
+
// A creature of the campaign written without the field, as cr 2 (450 XP), would count nothing in silence.
|
|
116
|
+
const unknown = worth.filter((item) => item.down && !item.given);
|
|
117
|
+
const total = overcome.reduce((sum, item) => sum + item.worth, 0);
|
|
118
|
+
if ((total === 0 && fled.length === 0 && unknown.length === 0) || party.length === 0) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const share = Math.floor(total / party.length);
|
|
122
|
+
const to = party.length === 1 ? `${share} to ${party[0].name}` : `${share} each to ${party.map((page) => page.name).join(", ")}`;
|
|
123
|
+
// Who has no such field yet gets it written, unless change starts it at 0 (CNT-8).
|
|
124
|
+
const held = (page) => read(effectiveFields(world, page), reward.field) !== undefined || startingAtZero(world, reward.field) !== undefined;
|
|
125
|
+
const calls = party.map((page) => (held(page) ? `change ${page.name}, field ${reward.field}, by ${share}` : `write ${page.name}, set ${reward.field}=${share}`)).join("; ");
|
|
126
|
+
const kinds = [...new Set(unknown.map((item) => item.kind))];
|
|
127
|
+
const characters = overcome.filter((item) => item.character).map((item) => item.name);
|
|
128
|
+
const parts = [
|
|
129
|
+
total === 0 ? `${reward.field}:` : `${reward.field} of those overcome: ${overcome.map((item) => `${item.name} ${item.worth}`).join(", ")}, ${total} in all; ${to}: ${calls}.`,
|
|
130
|
+
characters.length === 0 ? "" : `${characters.join(", ")} ${characters.length === 1 ? "is a character" : "are characters"}: leave out any who fought on your side, and share again.`,
|
|
131
|
+
fled.length === 0 ? "" : `Fled: ${fled.map((item) => `${item.name} ${item.worth}`).join(", ")}, to count if the party overcame them.`,
|
|
132
|
+
unknown.length === 0
|
|
133
|
+
? ""
|
|
134
|
+
: `${unknown.map((item) => item.name).join(", ")} ${unknown.length === 1 ? "counts" : "count"} nothing, with no ${reward.from} on ${kinds.join(", ")}: write it, such as write ${kinds[0]}, set ${reward.from}=…, and share it.`,
|
|
135
|
+
"Leave out what the party summoned; count those overcome another way and what the story rewards, as you judge, and tell the player only what each gained.",
|
|
136
|
+
];
|
|
137
|
+
return [parts.filter((part) => part !== "").join(" ")];
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** What a fight or a challenge that ends asks of the master, once in a chat, as play's rules left the instructions for it (D-532). */
|
|
141
|
+
const afterPeak = "After a peak, give a quiet scene the player can fill: a meal, rain, a talk. Judge a challenge by what it cost, not by whether it was won: "
|
|
142
|
+
+ "after two that cost nothing, let the next rise, within what the difficulty allows.";
|
|
143
|
+
/** Whether a scene of this type is a peak: a fight or a challenge. */
|
|
144
|
+
function peakEnded(type) {
|
|
145
|
+
return type === "combat" || type === "challenge";
|
|
146
|
+
}
|
|
147
|
+
/** Who fell in a scene, dead or down: its copies, those that left during it too, each with its creature, and the characters outside the party. */
|
|
148
|
+
function fallenOf(world, system, scene) {
|
|
149
|
+
const copies = [...Object.entries(scene.copies), ...Object.entries(scene.gone ?? {})].map(([name, copy]) => ({ page: copyPage(name, copy), kind: parsePageReference(copy.creature).name }));
|
|
150
|
+
const names = [...new Set([...scene.with.map((link) => parsePageReference(link).name), ...(scene.left ?? [])])];
|
|
151
|
+
const characters = names.flatMap((name) => findPage(world, name) ?? []).map((page) => ({ page, kind: undefined }));
|
|
152
|
+
return [...copies, ...characters].filter(({ page }) => isFallen(world, system, page)).map(({ page, kind }) => ({ name: page.name, ...(kind === undefined ? {} : { kind }) }));
|
|
153
|
+
}
|
|
154
|
+
/** The title and type of a scene that cannot be read, as far as they can be, so that the log still holds a closed scene. */
|
|
155
|
+
function rawTitleAndType(raw) {
|
|
156
|
+
const fields = raw !== null && typeof raw === "object" ? raw : {};
|
|
157
|
+
const title = typeof fields.title === "string" && fields.title.trim() !== "" ? fields.title : "Untitled scene";
|
|
158
|
+
const type = typeof fields.type === "string" && sceneTypes.includes(fields.type) ? fields.type : "other";
|
|
159
|
+
return { title, type };
|
|
160
|
+
}
|
|
161
|
+
export function closedText(result) {
|
|
162
|
+
const saved = result.saved === undefined ? (result.unsaved === undefined ? "" : `\n${result.unsaved}`) : `\nSaved: ${result.saved}.`;
|
|
163
|
+
const advance = "Advance any time it took that you have not advanced yet; write on their pages what it changed for good, such as a fire put out or a door broken.";
|
|
164
|
+
const endless = result.endless.length === 0 ? "" : `\nStill there, with no end: ${result.endless.join(" · ")}. End those the scene ended, with effect end.`;
|
|
165
|
+
const ended = `${result.ended.length === 0 ? "" : `\nEnded with the scene: ${result.ended.join(" · ")}.`}${endless}`;
|
|
166
|
+
const quests = result.quests.map((line) => `\n${line}`).join("");
|
|
167
|
+
if (result.unreadable !== undefined) {
|
|
168
|
+
return `The open scene could not be read (${result.unreadable}): closed it, without its copies. ${advance}${ended}${quests}${saved}`;
|
|
169
|
+
}
|
|
170
|
+
const rounds = result.rounds === undefined ? "" : ` after ${result.rounds} ${result.rounds === 1 ? "round" : "rounds"}`;
|
|
171
|
+
const gone = result.copies.length === 0 ? "" : ` Copies gone: ${membersText(result.copies)}.`;
|
|
172
|
+
const left = (result.gone ?? []).length === 0
|
|
173
|
+
? ""
|
|
174
|
+
: `\nLeft during the scene: ${membersText(result.gone ?? [])}. A copy ends with its scene: if one may come back, give it a page now, with its wounds.`;
|
|
175
|
+
const rewards = (result.rewards ?? []).map((line) => `\n${line}`).join("");
|
|
176
|
+
const fallen = result.fallen === undefined ? "" : `\n${result.fallen}`;
|
|
177
|
+
const peak = result.afterPeak === undefined ? "" : `\n${result.afterPeak}`;
|
|
178
|
+
return `Scene closed${rounds}: ${result.title}.${gone} ${advance}${ended}${left}${fallen}${rewards}${quests}${peak}${saved}`;
|
|
179
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import { type Page, type World } from "../../pages/index.ts";
|
|
3
|
+
import type { Scene, SceneCopy } from "../../scene/index.ts";
|
|
4
|
+
import type { GameSystem } from "../../systems/index.ts";
|
|
5
|
+
import type { Member } from "./result.ts";
|
|
6
|
+
/** The names of everyone in the scene: its characters and its copies. */
|
|
7
|
+
export declare function memberNames(current: Scene): string[];
|
|
8
|
+
/** "Ennio: hp 12/12; Annegato 1: hp 22/22". */
|
|
9
|
+
export declare function membersText(members: Member[]): string;
|
|
10
|
+
/** A character in the scene, with their effects: the player character and a companion with the counters of their line (DAT-2), anyone else with all of theirs. */
|
|
11
|
+
export declare function characterMember(world: World, page: Page, system: GameSystem | undefined): Member;
|
|
12
|
+
export declare function copyMembers(world: World, copies: Record<string, SceneCopy>): Member[];
|
|
13
|
+
/** The copies and what they changed go in a hidden line: the player does not see the enemies' numbers, nor the names of creatures in disguise. */
|
|
14
|
+
export declare function logCopies(root: string, context: Context, title: string, copies: Record<string, SceneCopy>): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { appendLogEntry } from "../../core/log.js";
|
|
2
|
+
import { isPartyMember, parsePageReference } from "../../pages/index.js";
|
|
3
|
+
import { effectShown } from "../shared/scene/effects.js";
|
|
4
|
+
import { copyCounters } from "../shared/scene/scene.js";
|
|
5
|
+
import { countersText, pageCounters, partyCounters } from "../shared/sheet/counters.js";
|
|
6
|
+
import { effectsOf } from "../shared/sheet/effect-layer.js";
|
|
7
|
+
import { newDatedLogEntry } from "../shared/time/time.js";
|
|
8
|
+
/** The names of everyone in the scene: its characters and its copies. */
|
|
9
|
+
export function memberNames(current) {
|
|
10
|
+
return [...current.with.map((link) => parsePageReference(link).name), ...Object.keys(current.copies)];
|
|
11
|
+
}
|
|
12
|
+
/** "Ennio: hp 12/12; Annegato 1: hp 22/22". */
|
|
13
|
+
export function membersText(members) {
|
|
14
|
+
return members.map((member) => {
|
|
15
|
+
const shown = [countersText(member.counters), ...(member.effects ?? [])].filter((part) => part !== "").join(" · ");
|
|
16
|
+
return shown === "" ? member.name : `${member.name}: ${shown}`;
|
|
17
|
+
}).join("; ");
|
|
18
|
+
}
|
|
19
|
+
/** A character in the scene, with their effects: the player character and a companion with the counters of their line (DAT-2), anyone else with all of theirs. */
|
|
20
|
+
export function characterMember(world, page, system) {
|
|
21
|
+
const counters = isPartyMember(page) ? partyCounters(world, page, undefined, system) : pageCounters(world, page);
|
|
22
|
+
return { name: page.name, counters, effects: effectsOf(page).map((effect) => effectShown(world, effect)) };
|
|
23
|
+
}
|
|
24
|
+
export function copyMembers(world, copies) {
|
|
25
|
+
return Object.entries(copies).map(([name, copy]) => ({ name, counters: copyCounters(world, copy) }));
|
|
26
|
+
}
|
|
27
|
+
/** The copies and what they changed go in a hidden line: the player does not see the enemies' numbers, nor the names of creatures in disguise. */
|
|
28
|
+
export function logCopies(root, context, title, copies) {
|
|
29
|
+
if (Object.keys(copies).length > 0) {
|
|
30
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-changed", "hidden", { title, copies }));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import { type World } from "../../pages/index.ts";
|
|
3
|
+
import { type Scene } from "../../scene/index.ts";
|
|
4
|
+
import type { SceneInput, SceneResult } from "./result.ts";
|
|
5
|
+
export declare function openNew(root: string, world: World, input: SceneInput, context: Context, current: Scene | undefined): SceneResult;
|
|
6
|
+
export declare function addTo(root: string, world: World, input: SceneInput, context: Context, current: Scene): SceneResult;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { appendLogEntry } from "../../core/log.js";
|
|
2
|
+
import { comparableText, sameName, withArticle } from "../../core/text.js";
|
|
3
|
+
import { findPage, isInParty, isPartyMember, locate, pageNamed, pageWithPath, parsePageReference } from "../../pages/index.js";
|
|
4
|
+
import { copyNames, sceneTypes } from "../../scene/index.js";
|
|
5
|
+
import { formatGameDate } from "../../time/index.js";
|
|
6
|
+
import { metPictureNote, picturesNote } from "../shared/campaign/images.js";
|
|
7
|
+
import { campaignMode, checklistLine } from "../shared/campaign/mode.js";
|
|
8
|
+
import { situationPart } from "../shared/campaign/parts.js";
|
|
9
|
+
import { campaignSystem, missingSystemHint, systemPagesHint } from "../shared/campaign/world.js";
|
|
10
|
+
import { quotedOrders, standingOrders } from "../shared/characters/orders.js";
|
|
11
|
+
import { surroundings, surroundingsText } from "../shared/places/environment.js";
|
|
12
|
+
import { offMapNote } from "../shared/places/grids.js";
|
|
13
|
+
import { readJourney } from "../shared/places/journey.js";
|
|
14
|
+
import { movePages } from "../shared/places/moves.js";
|
|
15
|
+
import { partyLead, playersApart } from "../shared/places/roads.js";
|
|
16
|
+
import { saveScene, updateScene } from "../shared/scene/scene.js";
|
|
17
|
+
import { newDatedLogEntry, readPresent } from "../shared/time/time.js";
|
|
18
|
+
import { characterMember, copyMembers, logCopies, memberNames } from "./members.js";
|
|
19
|
+
// The most copies of one creature a scene takes.
|
|
20
|
+
const mostCopies = 50;
|
|
21
|
+
export function openNew(root, world, input, context, current) {
|
|
22
|
+
if (current !== undefined) {
|
|
23
|
+
throw new Error(`A scene is open: ${current.title}. Close it first with scene close and a summary.`);
|
|
24
|
+
}
|
|
25
|
+
if (input.title === undefined || input.title.trim() === "" || input.type === undefined) {
|
|
26
|
+
throw new Error(`Give the scene a title and a type: ${sceneTypes.join(", ")}.`);
|
|
27
|
+
}
|
|
28
|
+
checkInPlay(root, context, world);
|
|
29
|
+
const named = input.with?.map((name) => characterPage(world, name));
|
|
30
|
+
const movers = readJourney(root)?.movers ?? [];
|
|
31
|
+
const place = input.place === undefined ? defaultPlace(world, movers, named) : placePage(world, input.place);
|
|
32
|
+
const characters = [...new Set(named ?? enteringParty(world, movers, place))];
|
|
33
|
+
const copies = newCopies(world, input.creatures, characters.map((page) => page.name));
|
|
34
|
+
const brought = bringParty(root, context, world, characters, place, input.type);
|
|
35
|
+
const opened = readPresent(root).date;
|
|
36
|
+
// A scene without copies leaves the key out: an empty {} would be written on one line.
|
|
37
|
+
const seen = seenOf(world, input.seen, characters, copies);
|
|
38
|
+
const created = {
|
|
39
|
+
title: input.title.trim(),
|
|
40
|
+
type: input.type,
|
|
41
|
+
place: place === undefined ? undefined : `[[${place.name}]]`,
|
|
42
|
+
opened: opened === undefined ? undefined : formatGameDate(opened),
|
|
43
|
+
now: input.now?.trim() || undefined,
|
|
44
|
+
with: characters.map((page) => `[[${page.name}]]`),
|
|
45
|
+
copies,
|
|
46
|
+
...(seen === undefined ? {} : { seen }),
|
|
47
|
+
};
|
|
48
|
+
saveScene(root, withoutUndefined({ ...created, copies: Object.keys(copies).length === 0 ? undefined : copies }));
|
|
49
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-opened", "public", { title: created.title, type: created.type, place: created.place, with: created.with }));
|
|
50
|
+
// What the character sees, kept for the rolls of this scene once it closes (D-421); hidden, as the names it is given by are.
|
|
51
|
+
if (seen !== undefined) {
|
|
52
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-changed", "hidden", { title: created.title, seen }));
|
|
53
|
+
}
|
|
54
|
+
logCopies(root, context, created.title, copies);
|
|
55
|
+
const after = brought.world;
|
|
56
|
+
const system = campaignSystem(root, context);
|
|
57
|
+
const members = [...characters.map((page) => characterMember(after, page, system)), ...copyMembers(after, copies)];
|
|
58
|
+
const around = surroundingsText(surroundings(after, place === undefined ? undefined : pageWithPath(after, place.path)));
|
|
59
|
+
// The part of the instructions that the scene's type opens, such as how a fight is told (D-111, D-139).
|
|
60
|
+
const part = situationPart(created.type, context, system);
|
|
61
|
+
// A place without a picture, where the campaign wants one for each new place (D-308).
|
|
62
|
+
const picture = picturesNote(root, context, after, place === undefined ? undefined : pageWithPath(after, place.path));
|
|
63
|
+
const offMap = offMapNote(after, place === undefined ? undefined : pageWithPath(after, place.path), created, [...characters.map((page) => page.name), ...Object.keys(copies)]);
|
|
64
|
+
// Who enters without a picture, where the campaign wants one for each one met (D-420).
|
|
65
|
+
const met = metPictureNote(root, context, [...characters, ...copyCreatures(world, copies)]);
|
|
66
|
+
return {
|
|
67
|
+
action: "open",
|
|
68
|
+
title: created.title,
|
|
69
|
+
type: created.type,
|
|
70
|
+
opened: created.opened,
|
|
71
|
+
place: place?.name,
|
|
72
|
+
members,
|
|
73
|
+
around,
|
|
74
|
+
part,
|
|
75
|
+
moved: brought.moved,
|
|
76
|
+
notes: [...brought.notes, ...(picture === undefined ? [] : [picture]), ...(met === undefined ? [] : [met]), ...(offMap === undefined ? [] : [offMap]), ...ordersNote(root, characters)],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function addTo(root, world, input, context, current) {
|
|
80
|
+
if (input.with === undefined && input.creatures === undefined && input.seen === undefined) {
|
|
81
|
+
throw new Error("Give who enters the scene: with (characters) or creatures (such as Annegato=1); or seen, what the character sees of who is already in it.");
|
|
82
|
+
}
|
|
83
|
+
const members = memberNames(current);
|
|
84
|
+
const characters = [...new Set((input.with ?? []).map((name) => characterPage(world, name)))];
|
|
85
|
+
const already = characters.filter((page) => sameName(members, page.name) !== undefined);
|
|
86
|
+
if (already.length > 0) {
|
|
87
|
+
throw new Error(`${already.map((page) => page.name).join(", ")} ${already.length === 1 ? "is" : "are"} already in the scene.`);
|
|
88
|
+
}
|
|
89
|
+
const copies = newCopies(world, input.creatures, [...members, ...(current.left ?? []), ...characters.map((page) => page.name)], current.copies);
|
|
90
|
+
const place = current.place === undefined ? undefined : findPage(world, parsePageReference(current.place).name);
|
|
91
|
+
const brought = bringParty(root, context, world, characters, place, current.type);
|
|
92
|
+
const added = [...characters.map((page) => page.name), ...Object.keys(copies)];
|
|
93
|
+
const changes = [[["with"], [...current.with, ...characters.map((page) => `[[${page.name}]]`)]], ...Object.entries(copies).map(([name, copy]) => [["copies", name], copy])];
|
|
94
|
+
const there = current.with.flatMap((link) => findPage(world, parsePageReference(link).name) ?? []);
|
|
95
|
+
const inScene = [...there, ...characters];
|
|
96
|
+
const seen = seenOf(world, input.seen, inScene, { ...current.copies, ...copies });
|
|
97
|
+
if (seen !== undefined) {
|
|
98
|
+
changes.push([["seen"], { ...current.seen, ...seen }]);
|
|
99
|
+
}
|
|
100
|
+
if (current.order !== undefined) {
|
|
101
|
+
changes.push([["order"], [...current.order, ...added]]);
|
|
102
|
+
}
|
|
103
|
+
updateScene(root, changes);
|
|
104
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "scene-changed", "hidden", { title: current.title, added, ...(seen === undefined ? {} : { seen }) }));
|
|
105
|
+
logCopies(root, context, current.title, copies);
|
|
106
|
+
const system = campaignSystem(root, context);
|
|
107
|
+
const entered = [...characters.map((page) => characterMember(brought.world, page, system)), ...copyMembers(brought.world, copies)];
|
|
108
|
+
const offMap = offMapNote(brought.world, place === undefined ? undefined : pageWithPath(brought.world, place.path), { ...current, copies: { ...current.copies, ...copies } }, added);
|
|
109
|
+
const met = metPictureNote(root, context, [...characters, ...copyCreatures(world, copies)]);
|
|
110
|
+
return {
|
|
111
|
+
action: "add",
|
|
112
|
+
title: current.title,
|
|
113
|
+
place: place?.name,
|
|
114
|
+
members: entered,
|
|
115
|
+
ordered: current.order !== undefined,
|
|
116
|
+
...(seen === undefined ? {} : { seen }),
|
|
117
|
+
moved: brought.moved,
|
|
118
|
+
notes: [...brought.notes, ...(met === undefined ? [] : [met]), ...(offMap === undefined ? [] : [offMap]), ...(there.some(isCompanion) ? [] : ordersNote(root, characters))],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** The player's standing orders, when a companion enters among those given (D-563); none without orders or a companion. */
|
|
122
|
+
function ordersNote(root, entering) {
|
|
123
|
+
const orders = entering.some(isCompanion) ? standingOrders(root) : [];
|
|
124
|
+
return orders.length === 0 ? [] : [`Standing orders to the companions: ${quotedOrders(orders)}.`];
|
|
125
|
+
}
|
|
126
|
+
function isCompanion(page) {
|
|
127
|
+
return page.fields.role === "companion";
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Brings into the scene's place whoever of the party in the scene is elsewhere, as move does, with what that sets off (CON-6); a travel scene moves no one.
|
|
131
|
+
* Done before the scene is written, so that a move refused leaves no scene behind.
|
|
132
|
+
*/
|
|
133
|
+
function bringParty(root, context, world, characters, place, type) {
|
|
134
|
+
const away = place === undefined || type === "travel" ? [] : characters.filter((page) => isInParty(page) && !locate(world, page).chain.includes(place));
|
|
135
|
+
if (place === undefined || away.length === 0) {
|
|
136
|
+
return { moved: [], notes: [], world };
|
|
137
|
+
}
|
|
138
|
+
const done = movePages(root, context, world, away, place);
|
|
139
|
+
return { moved: done.moved.map((page) => page.name), notes: done.notes, world: done.world };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* New copies of the creatures asked for: each holds only the creature it copies, and later what changes (D-110). They are numbered after the copies in the scene,
|
|
143
|
+
* skipping the names of pages and of those in the scene, so that a copy written as a character never blocks the next ones.
|
|
144
|
+
*/
|
|
145
|
+
function newCopies(world, creatures, names, existing = {}) {
|
|
146
|
+
const copies = {};
|
|
147
|
+
const taken = [...names, ...world.pages.map((page) => page.name)];
|
|
148
|
+
for (const [creature, count] of creatureCounts(world, creatures)) {
|
|
149
|
+
const inScene = Object.values(existing).filter((copy) => comparableText(parsePageReference(copy.creature).name) === comparableText(creature.name)).length;
|
|
150
|
+
if (inScene + count > mostCopies) {
|
|
151
|
+
throw new Error(`A scene takes at most ${mostCopies} copies of ${creature.name}; it has ${inScene}.`);
|
|
152
|
+
}
|
|
153
|
+
for (const name of copyNames(creature.name, count, [...taken, ...Object.keys(existing), ...Object.keys(copies)])) {
|
|
154
|
+
copies[name] = { creature: `[[${creature.name}]]` };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return copies;
|
|
158
|
+
}
|
|
159
|
+
/** The creatures of some copies, each once. */
|
|
160
|
+
function copyCreatures(world, copies) {
|
|
161
|
+
return [...new Set(Object.values(copies).flatMap((copy) => findPage(world, parsePageReference(copy.creature).name) ?? []))];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* What the character sees of those it does not know by name (D-416), by the name of a character in the scene or of a creature with copies in it: Bandito=brigante
|
|
165
|
+
* incappucciato on the command line, {"Varro": "il mugnaio"} through MCP; none when not given.
|
|
166
|
+
*/
|
|
167
|
+
function seenOf(world, seen, characters, copies) {
|
|
168
|
+
const pairs = Array.isArray(seen)
|
|
169
|
+
? seen.map((entry) => {
|
|
170
|
+
const separator = entry.indexOf("=");
|
|
171
|
+
return separator === -1 ? [entry, ""] : [entry.slice(0, separator), entry.slice(separator + 1)];
|
|
172
|
+
})
|
|
173
|
+
: Object.entries(seen ?? {});
|
|
174
|
+
if (pairs.length === 0) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const kinds = [...new Set(Object.values(copies).map((copy) => parsePageReference(copy.creature).name))];
|
|
178
|
+
const names = [...characters.map((page) => page.name), ...kinds];
|
|
179
|
+
return Object.fromEntries(pairs.map(([name, said]) => {
|
|
180
|
+
const named = sameName(names, parsePageReference(name.trim()).name);
|
|
181
|
+
// A copy's name, as Cultista 1: seen is given by its creature, once for all its copies.
|
|
182
|
+
const kind = sameName(kinds, /^(.*\S)\s+\d+$/.exec(name.trim())?.[1] ?? "");
|
|
183
|
+
if (named === undefined && kind !== undefined) {
|
|
184
|
+
throw new Error(`seen ${name.trim()}: give it by the creature, ${kind}, once for all its copies, such as ${kind}=${said.trim() || "uomo incappucciato"}: they are numbered from those words.`);
|
|
185
|
+
}
|
|
186
|
+
if (named === undefined) {
|
|
187
|
+
throw new Error(`seen ${name.trim()}: there is no character or creature of that name in the scene. In it: ${names.length === 0 ? "no one" : names.join(", ")}.`);
|
|
188
|
+
}
|
|
189
|
+
// The party knows itself: seen is for those the character does not know by name.
|
|
190
|
+
if (characters.some((page) => page.name === named && isPartyMember(page))) {
|
|
191
|
+
throw new Error(`seen ${named}: ${named} is of the party, whom the character knows by name. Give seen only for those it does not know, such as a stranger or a creature.`);
|
|
192
|
+
}
|
|
193
|
+
if (said.trim() === "") {
|
|
194
|
+
throw new Error(`Give what the character sees of ${named}, in two or three words, such as ${named}=uomo incappucciato.`);
|
|
195
|
+
}
|
|
196
|
+
return [named, said.trim()];
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
/** Creatures and how many of each, the same creature given twice counted once: Annegato=2 or Annegato on the command line, {"Annegato": 2} through MCP. */
|
|
200
|
+
function creatureCounts(world, creatures) {
|
|
201
|
+
const pairs = Array.isArray(creatures)
|
|
202
|
+
? creatures.map((entry) => {
|
|
203
|
+
const separator = entry.lastIndexOf("=");
|
|
204
|
+
return separator === -1 ? [entry, 1] : [entry.slice(0, separator), Number(entry.slice(separator + 1).trim())];
|
|
205
|
+
})
|
|
206
|
+
: Object.entries(creatures ?? {});
|
|
207
|
+
const counts = new Map();
|
|
208
|
+
for (const [name, count] of pairs) {
|
|
209
|
+
if (name.trim().startsWith("{")) {
|
|
210
|
+
throw new Error(`Write creatures as Name=count, such as Annegato=2: an object such as {"Annegato": 2} works only through MCP.`);
|
|
211
|
+
}
|
|
212
|
+
if (!Number.isInteger(count) || count < 1 || count > mostCopies) {
|
|
213
|
+
throw new Error(`Give how many ${name.trim()} enter as a whole number from 1 to ${mostCopies}, such as ${name.trim()}=2.`);
|
|
214
|
+
}
|
|
215
|
+
const creature = creaturePage(world, parsePageReference(name).name);
|
|
216
|
+
counts.set(creature, (counts.get(creature) ?? 0) + count);
|
|
217
|
+
}
|
|
218
|
+
return [...counts];
|
|
219
|
+
}
|
|
220
|
+
function creaturePage(world, name) {
|
|
221
|
+
const page = findPage(world, name);
|
|
222
|
+
if (page?.type === "creature") {
|
|
223
|
+
return page;
|
|
224
|
+
}
|
|
225
|
+
const creatures = world.pages.filter((candidate) => candidate.type === "creature").map((candidate) => candidate.name);
|
|
226
|
+
const more = creatures.length > 10 ? `, and ${creatures.length - 10} more: find --type creature` : "";
|
|
227
|
+
const system = systemPagesHint(world, "creature");
|
|
228
|
+
const none = system === "" ? "There are no creature pages yet: create one with write, type creature." : "The campaign has no creature pages yet.";
|
|
229
|
+
const known = `${creatures.length === 0 ? none : `The campaign's creatures are: ${creatures.slice(0, 10).join(", ")}${more}.`}${system}${missingSystemHint(world)}`;
|
|
230
|
+
throw new Error(page === undefined ? `There is no creature named ${name}. ${known}` : `${page.name} is ${withArticle(page.type ?? "free page")}, not a creature: characters enter with with. ${known}`);
|
|
231
|
+
}
|
|
232
|
+
function characterPage(world, name) {
|
|
233
|
+
const reference = parsePageReference(name).name;
|
|
234
|
+
// A renamed page answers to its old name too, among its aliases (D-417).
|
|
235
|
+
const page = pageNamed(world, reference);
|
|
236
|
+
if (page === undefined) {
|
|
237
|
+
throw new Error(`There is no page named ${reference}. Create the character with write first, or bring in a creature with creatures.`);
|
|
238
|
+
}
|
|
239
|
+
if (page.type !== "character") {
|
|
240
|
+
const how = page.type === "creature" ? `creatures enter as copies, with creatures, such as ${page.name}=1` : "only characters and creatures take part in a scene";
|
|
241
|
+
throw new Error(`${page.name} is ${withArticle(page.type ?? "free page")}, not a character: ${how}.`);
|
|
242
|
+
}
|
|
243
|
+
if (page.fields.status === "dead") {
|
|
244
|
+
throw new Error(`${page.name} is dead (status dead): set their status first, if they rise.`);
|
|
245
|
+
}
|
|
246
|
+
return page;
|
|
247
|
+
}
|
|
248
|
+
function placePage(world, name) {
|
|
249
|
+
const reference = parsePageReference(name).name;
|
|
250
|
+
// A renamed page answers to its old name too, among its aliases (D-417).
|
|
251
|
+
const page = pageNamed(world, reference);
|
|
252
|
+
if (page?.type !== "place") {
|
|
253
|
+
throw new Error(page === undefined ? `There is no place named ${reference}. Create it with write, type place, or leave place out.` : `${page.name} is ${withArticle(page.type ?? "free page")}, not a place.`);
|
|
254
|
+
}
|
|
255
|
+
return page;
|
|
256
|
+
}
|
|
257
|
+
/** A scene opens only in play: the game starts once the checklists of setup and session zero are complete (D-221, MOD-6). */
|
|
258
|
+
function checkInPlay(root, context, world) {
|
|
259
|
+
const mode = campaignMode(root, world);
|
|
260
|
+
if (mode !== "play") {
|
|
261
|
+
throw new Error(`The game has not started: the campaign is in ${mode}, and scenes open in play. ${checklistLine(mode, root, context, world) ?? ""}`.trim());
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Where a scene opens without a place (SCN-2): where the player characters are; while they are apart (VIEW-12), where those it is with are, when they are
|
|
266
|
+
* together; else refused, with where each is.
|
|
267
|
+
*/
|
|
268
|
+
function defaultPlace(world, movers, named) {
|
|
269
|
+
if (named !== undefined && playersApart(world, movers) !== undefined) {
|
|
270
|
+
const places = [...new Set(named.map((page) => nearestPlace(world, page)))];
|
|
271
|
+
if (places.length > 1) {
|
|
272
|
+
throw new Error(`${named.map((page) => `${page.name}, in ${nearestPlace(world, page)?.name ?? "the open"}`).join("; ")}: a scene is in one place. Give place to bring the others there now, `
|
|
273
|
+
+ "if they can be there at once; if the way takes time, travel first, or open a scene for each group. Nothing changed.");
|
|
274
|
+
}
|
|
275
|
+
return places[0];
|
|
276
|
+
}
|
|
277
|
+
const lead = partyLead(world, movers, "Give place, where the scene is, or with, who is in it.");
|
|
278
|
+
return lead === undefined ? undefined : nearestPlace(world, lead);
|
|
279
|
+
}
|
|
280
|
+
/** The nearest place of the living player characters when they are all together; undefined when they are apart (VIEW-12), or in the open. */
|
|
281
|
+
function togetherPlace(world, movers) {
|
|
282
|
+
const lead = playersApart(world, movers) === undefined ? partyLead(world, movers, "") : undefined;
|
|
283
|
+
return lead === undefined ? undefined : nearestPlace(world, lead);
|
|
284
|
+
}
|
|
285
|
+
function nearestPlace(world, page) {
|
|
286
|
+
return locate(world, page).chain.find((holder) => holder.type === "place");
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Who of the party enters a scene when with is left out (CON-6): the living members in its place, and those where the player characters are, when they are
|
|
290
|
+
* together (VIEW-12); all of them when there is no place.
|
|
291
|
+
*/
|
|
292
|
+
function enteringParty(world, movers, place) {
|
|
293
|
+
const lead = togetherPlace(world, movers);
|
|
294
|
+
return world.pages.filter((page) => isInParty(page) && (place === undefined || locate(world, page).chain.includes(place) || (lead !== undefined && nearestPlace(world, page) === lead)));
|
|
295
|
+
}
|
|
296
|
+
function withoutUndefined(current) {
|
|
297
|
+
return Object.fromEntries(Object.entries(current).filter(([, value]) => value !== undefined));
|
|
298
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export declare const actions: readonly ["open", "add", "leave", "order", "next", "use", "now", "hostile", "calm", "close"];
|
|
2
|
+
export type Action = (typeof actions)[number];
|
|
3
|
+
export interface SceneInput {
|
|
4
|
+
action: Action;
|
|
5
|
+
title?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
place?: string;
|
|
8
|
+
with?: string[];
|
|
9
|
+
creatures?: string[] | Record<string, number>;
|
|
10
|
+
who?: string[];
|
|
11
|
+
order?: string[];
|
|
12
|
+
uses?: string;
|
|
13
|
+
by?: string;
|
|
14
|
+
now?: string;
|
|
15
|
+
summary?: string;
|
|
16
|
+
seen?: string[] | Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export type SceneResult = ({
|
|
19
|
+
action: "open";
|
|
20
|
+
title: string;
|
|
21
|
+
type: string;
|
|
22
|
+
opened?: string;
|
|
23
|
+
place?: string;
|
|
24
|
+
members: Member[];
|
|
25
|
+
around: string;
|
|
26
|
+
part: string;
|
|
27
|
+
} & Brought) | ({
|
|
28
|
+
action: "add";
|
|
29
|
+
title: string;
|
|
30
|
+
place?: string;
|
|
31
|
+
members: Member[];
|
|
32
|
+
ordered: boolean;
|
|
33
|
+
seen?: Record<string, string>;
|
|
34
|
+
} & Brought) | {
|
|
35
|
+
action: "leave";
|
|
36
|
+
left: Member[];
|
|
37
|
+
turns?: Turns;
|
|
38
|
+
noTurns: boolean;
|
|
39
|
+
ended: string[];
|
|
40
|
+
acting?: string;
|
|
41
|
+
} | ({
|
|
42
|
+
action: "order" | "next";
|
|
43
|
+
noTurn: string[];
|
|
44
|
+
ended: string[];
|
|
45
|
+
acting?: string;
|
|
46
|
+
} & Turns) | {
|
|
47
|
+
action: "now";
|
|
48
|
+
title: string;
|
|
49
|
+
now: string;
|
|
50
|
+
members: string[];
|
|
51
|
+
} | {
|
|
52
|
+
action: "use";
|
|
53
|
+
line: string;
|
|
54
|
+
} | {
|
|
55
|
+
action: "hostile" | "calm";
|
|
56
|
+
title: string;
|
|
57
|
+
marked: string[];
|
|
58
|
+
hostile: string[];
|
|
59
|
+
} | ({
|
|
60
|
+
action: "close";
|
|
61
|
+
title?: string;
|
|
62
|
+
rounds?: number;
|
|
63
|
+
copies: Member[];
|
|
64
|
+
gone?: Member[];
|
|
65
|
+
unreadable?: string;
|
|
66
|
+
ended: string[];
|
|
67
|
+
endless: string[];
|
|
68
|
+
rewards?: string[];
|
|
69
|
+
fallen?: string;
|
|
70
|
+
afterPeak?: string;
|
|
71
|
+
quests: string[];
|
|
72
|
+
} & Saved);
|
|
73
|
+
/** The order of turns, where the scene has one, and whether the turn is the player's character's. */
|
|
74
|
+
export interface Turns {
|
|
75
|
+
order: string[];
|
|
76
|
+
round: number;
|
|
77
|
+
turn: string;
|
|
78
|
+
player: boolean;
|
|
79
|
+
/** More than one living player character, each handed their turn by name (D-480 (5)). */
|
|
80
|
+
several?: true;
|
|
81
|
+
}
|
|
82
|
+
/** Someone in the scene, with their counters. */
|
|
83
|
+
export interface Member {
|
|
84
|
+
name: string;
|
|
85
|
+
counters: Record<string, unknown>;
|
|
86
|
+
/** A character's effects with their end, such as "Poisoned until day 1, 19:00". */
|
|
87
|
+
effects?: string[];
|
|
88
|
+
}
|
|
89
|
+
/** Who of the party a scene brought into its place, and what that set off (CON-6). */
|
|
90
|
+
export interface Brought {
|
|
91
|
+
moved: string[];
|
|
92
|
+
notes: string[];
|
|
93
|
+
}
|
|
94
|
+
/** The save the end of a scene made, or why it made none (SAV-3). */
|
|
95
|
+
export interface Saved {
|
|
96
|
+
saved?: string;
|
|
97
|
+
unsaved?: string;
|
|
98
|
+
}
|