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/systems/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export { type
|
|
2
|
-
export { givenCode, type LoadedSystemCode, loadSystemCode, systemApiProblem, systemHasCode, type SystemPackage, systemPackage, systemPageModule } from "./
|
|
3
|
-
export { type SystemFolder, systemFolders } from "./
|
|
1
|
+
export { type CampaignData, campaignDataNames, type SystemLayer } from "./campaign-data.ts";
|
|
2
|
+
export { givenCode, type LoadedSystemCode, loadSystemCode, systemApiProblem, systemHasCode, type SystemPackage, systemPackage, systemPageModule } from "./code.ts";
|
|
3
|
+
export { type SystemFolder, systemFolders } from "./folders.ts";
|
|
4
|
+
export { type ActVerb, type CheckAtom, type CheckOperator, type DamageRule, type GameSystem, type GridRules, type Lifestyle, type Recipe, type Reward, rollName, rulesetSetting, type SheetEntry, type SheetGroup, type SheetVerb, type SystemCheck, systemFileName, type SystemSetting, type Threshold, type Travel, type TravelKind, type TurnUse, } from "./game-system.ts";
|
|
5
|
+
export { findCampaignSystem, findSystem, installedSystems, readableSystems, systemContentFolders, systemInFolder } from "./installed.ts";
|
|
6
|
+
export { engineOfferings, engineSettingValue, heldSettings, offeredEngineValues, playedValueOf, withSettings } from "./settings.ts";
|
|
4
7
|
export { layeredSystemWords, type SystemWords, systemWords } from "./words.ts";
|
package/dist/systems/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// The game systems installed beside the engine (D-27, SYS-1): which they are and what each declares. Their pages are read by the pages module.
|
|
2
|
-
export { campaignDataNames
|
|
3
|
-
export { givenCode, loadSystemCode, systemApiProblem, systemHasCode, systemPackage, systemPageModule } from "./
|
|
4
|
-
export { systemFolders } from "./
|
|
2
|
+
export { campaignDataNames } from "./campaign-data.js";
|
|
3
|
+
export { givenCode, loadSystemCode, systemApiProblem, systemHasCode, systemPackage, systemPageModule } from "./code.js";
|
|
4
|
+
export { systemFolders } from "./folders.js";
|
|
5
|
+
export { rollName, rulesetSetting, systemFileName, } from "./game-system.js";
|
|
6
|
+
export { findCampaignSystem, findSystem, installedSystems, readableSystems, systemContentFolders, systemInFolder } from "./installed.js";
|
|
7
|
+
export { engineOfferings, engineSettingValue, heldSettings, offeredEngineValues, playedValueOf, withSettings } from "./settings.js";
|
|
5
8
|
export { layeredSystemWords, systemWords } from "./words.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type SystemLayer } from "./campaign-data.ts";
|
|
2
|
+
import type { GameSystem } from "./game-system.ts";
|
|
3
|
+
/** The systems installed in these folders, nearest folder first: each folder in them with a system.yaml. A name found twice is the nearest one. */
|
|
4
|
+
export declare function installedSystems(folders: string[]): GameSystem[];
|
|
5
|
+
/** The installed game systems that read, for a list of them: one whose system.yaml does not read stops no list, and the campaign that plays it hears why. */
|
|
6
|
+
export declare function readableSystems(folders: string[]): GameSystem[];
|
|
7
|
+
/**
|
|
8
|
+
* The installed system with the layers over it, in order, the nearest to the campaign last and winning (CAM-2); a layer with which it does not read is left out,
|
|
9
|
+
* with why, and the others stay (CAM-3). Undefined as a system when none is installed by that name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findCampaignSystem(folders: string[], name: string, layers: SystemLayer[], ruleset?: string): {
|
|
12
|
+
system?: GameSystem;
|
|
13
|
+
refused: {
|
|
14
|
+
from: string;
|
|
15
|
+
problem: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The installed system with this name, ignoring case, from the nearest folder that has it, with the version of its rules asked, else its first (VER-2); undefined
|
|
20
|
+
* when none is. Only its own system.yaml is read, and its version's.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findSystem(folders: string[], name: string, ruleset?: string): GameSystem | undefined;
|
|
23
|
+
/** The game system in this folder by the name a campaign gives it, as installed, without a version of its rules; it throws when its system.yaml does not read. */
|
|
24
|
+
export declare function systemInFolder(folder: string, name: string): GameSystem;
|
|
25
|
+
/** The folders a system's pages, rules, words, pictures and instructions come from, in order: its own, then its version's, which wins by name (VER-3). */
|
|
26
|
+
export declare function systemContentFolders(system: {
|
|
27
|
+
folder: string;
|
|
28
|
+
version?: {
|
|
29
|
+
folder: string;
|
|
30
|
+
};
|
|
31
|
+
}): string[];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Finds the installed systems, by folder and by name, read with a campaign's layers
|
|
2
|
+
import { installedFromFolder, npmPackageName } from "../core/files.js";
|
|
3
|
+
import { comparableText } from "../core/text.js";
|
|
4
|
+
import { campaignDataNames } from "./campaign-data.js";
|
|
5
|
+
import { systemFolders } from "./folders.js";
|
|
6
|
+
import { readSystem } from "./read.js";
|
|
7
|
+
/** The systems installed in these folders, nearest folder first: each folder in them with a system.yaml. A name found twice is the nearest one. */
|
|
8
|
+
export function installedSystems(folders) {
|
|
9
|
+
const systems = [];
|
|
10
|
+
for (const found of systemFolders(folders)) {
|
|
11
|
+
if (!systems.some((system) => comparableText(system.name) === comparableText(found.name))) {
|
|
12
|
+
systems.push(readInstalled(found));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return systems;
|
|
16
|
+
}
|
|
17
|
+
/** The installed game systems that read, for a list of them: one whose system.yaml does not read stops no list, and the campaign that plays it hears why. */
|
|
18
|
+
export function readableSystems(folders) {
|
|
19
|
+
return systemFolders(folders).flatMap((found, index, all) => {
|
|
20
|
+
if (all.slice(0, index).some((before) => comparableText(before.name) === comparableText(found.name))) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return [readSystem(found.folder, found.name)];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The installed system with the layers over it, in order, the nearest to the campaign last and winning (CAM-2); a layer with which it does not read is left out,
|
|
33
|
+
* with why, and the others stay (CAM-3). Undefined as a system when none is installed by that name.
|
|
34
|
+
*/
|
|
35
|
+
export function findCampaignSystem(folders, name, layers, ruleset) {
|
|
36
|
+
const found = systemFolders(folders).find((candidate) => comparableText(candidate.name) === comparableText(name.trim()));
|
|
37
|
+
const given = layers.filter((layer) => campaignDataNames.some((key) => layer.data[key] !== undefined && layer.data[key] !== null));
|
|
38
|
+
if (found === undefined) {
|
|
39
|
+
return { refused: [] };
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
return { system: readSystem(found.folder, found.name, given, ruleset), refused: [] };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// One layer at a time, to leave out only those that do not read.
|
|
46
|
+
}
|
|
47
|
+
const kept = [];
|
|
48
|
+
const refused = [];
|
|
49
|
+
for (const layer of given) {
|
|
50
|
+
try {
|
|
51
|
+
readSystem(found.folder, found.name, [...kept, layer], ruleset);
|
|
52
|
+
kept.push(layer);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
+
refused.push({ from: layer.from, problem: message.replace(/^The game system .*? cannot be read, because .*? is not valid:\s*/s, "") });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { system: readInstalled(found, kept, ruleset), refused };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The installed system with this name, ignoring case, from the nearest folder that has it, with the version of its rules asked, else its first (VER-2); undefined
|
|
63
|
+
* when none is. Only its own system.yaml is read, and its version's.
|
|
64
|
+
*/
|
|
65
|
+
export function findSystem(folders, name, ruleset) {
|
|
66
|
+
const found = systemFolders(folders).find((candidate) => comparableText(candidate.name) === comparableText(name.trim()));
|
|
67
|
+
return found === undefined ? undefined : readInstalled(found, [], ruleset);
|
|
68
|
+
}
|
|
69
|
+
/** The game system in this folder by the name a campaign gives it, as installed, without a version of its rules; it throws when its system.yaml does not read. */
|
|
70
|
+
export function systemInFolder(folder, name) {
|
|
71
|
+
return readSystem(folder, name);
|
|
72
|
+
}
|
|
73
|
+
/** The folders a system's pages, rules, words, pictures and instructions come from, in order: its own, then its version's, which wins by name (VER-3). */
|
|
74
|
+
export function systemContentFolders(system) {
|
|
75
|
+
return system.version === undefined ? [system.folder] : [system.folder, system.version.folder];
|
|
76
|
+
}
|
|
77
|
+
/** An installed system read; one npm installed that does not read says how to get its files back, which are npm's and not the player's to fix. */
|
|
78
|
+
function readInstalled(found, layers = [], ruleset) {
|
|
79
|
+
try {
|
|
80
|
+
return readSystem(found.folder, found.name, layers, ruleset);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
84
|
+
const fromNpm = npmPackageName(found.folder);
|
|
85
|
+
throw fromNpm === undefined || installedFromFolder(found.folder)
|
|
86
|
+
? error
|
|
87
|
+
: new Error(`${message.replace(/\.?$/, ".")} It came from npm: install it again with package install ${fromNpm}, which brings its files back.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The plain maps of system.yaml data: whether a value is one, and which name it holds a key under
|
|
2
|
+
import { sameName } from "../core/text.js";
|
|
3
|
+
export function isMap(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/** The name under which a map holds this one, as names are compared. */
|
|
7
|
+
export function nameIn(map, name) {
|
|
8
|
+
return sameName(Object.keys(map), name);
|
|
9
|
+
}
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
// Reads and checks a system.yaml, with its version and layers, into a frozen GameSystem
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { formulaOf, readFormulas } from "../core/formula.js";
|
|
4
|
+
import { frozen } from "../core/frozen.js";
|
|
5
|
+
import { readParts } from "../core/instruction-parts.js";
|
|
6
|
+
import { readLength, readSpeed } from "../core/length.js";
|
|
7
|
+
import { declaredWidgets, packagePartsIssues } from "../core/packages/declarations.js";
|
|
8
|
+
import { comparableText, sameName } from "../core/text.js";
|
|
9
|
+
import { readYamlValues } from "../core/yaml-file.js";
|
|
10
|
+
import { withCampaignData } from "./campaign-data.js";
|
|
11
|
+
import { systemApiProblem, systemHasCode } from "./code.js";
|
|
12
|
+
import { actVerbs, plainRoll, rulesetSetting, systemFileName } from "./game-system.js";
|
|
13
|
+
import { isMap } from "./maps.js";
|
|
14
|
+
import { checkFieldPattern, sheetEntryPattern, systemSchema } from "./schema.js";
|
|
15
|
+
import { chosenVersion, withVersion } from "./versions.js";
|
|
16
|
+
export function readSystem(folder, name, layers = [], ruleset) {
|
|
17
|
+
const file = join(folder, systemFileName);
|
|
18
|
+
let own;
|
|
19
|
+
// The YAML's own error names only system.yaml: the system and its folder are said, so that one played is found and fixed.
|
|
20
|
+
try {
|
|
21
|
+
own = readYamlValues(file, 'what the system is, such as "title: ..."');
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new Error(`The game system ${name} cannot be read, because ${file} is not valid: ${error instanceof Error ? error.message : String(error)}`);
|
|
25
|
+
}
|
|
26
|
+
const version = chosenVersion(own, file, name, ruleset);
|
|
27
|
+
const read = version === undefined ? file : `${file} with its version ${version.name}`;
|
|
28
|
+
const path = layers.length === 0 ? read : `${read} with the additions of ${layers.map((layer) => layer.from).join(", ")}`;
|
|
29
|
+
const raw = version === undefined || !isMap(own) ? own : withVersion(own, version.data);
|
|
30
|
+
let merged = raw;
|
|
31
|
+
try {
|
|
32
|
+
merged = layers.reduce((below, layer) => withCampaignData(below, layer.data), raw);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
const parsed = systemSchema.safeParse(merged);
|
|
38
|
+
if (!parsed.success) {
|
|
39
|
+
// One made for a newer API may declare what this engine does not know yet (D-515).
|
|
40
|
+
const unread = systemApiProblem(folder);
|
|
41
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${issuesText(parsed.error)}${unread === undefined ? "" : ` Besides, ${unread}.`}`);
|
|
42
|
+
}
|
|
43
|
+
const data = parsed.data;
|
|
44
|
+
const parts = packagePartsIssues(data, "a game system")[0];
|
|
45
|
+
if (parts !== undefined) {
|
|
46
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${[...parts.path, ""].join(".").replace(/\.$/, ": ")}${parts.message}.`);
|
|
47
|
+
}
|
|
48
|
+
// What a counter shields is no limit of it: a counter with only that has none (DAT-14).
|
|
49
|
+
const limited = Object.entries(data.counters ?? {}).flatMap(([counter, { min, max, refill }]) => min === undefined && max === undefined && refill === undefined ? [] : [[counter, { min, max, refill }]]);
|
|
50
|
+
const formulas = systemFormulas({ ...data, counters: Object.fromEntries(limited) }, name, path);
|
|
51
|
+
const stray = strayOccasion(data, formulas);
|
|
52
|
+
if (stray !== undefined) {
|
|
53
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${stray}`);
|
|
54
|
+
}
|
|
55
|
+
const sheet = sheetOf(data, name, path);
|
|
56
|
+
const values = data.values ?? {};
|
|
57
|
+
const sheetValues = data["sheet-values"] ?? {};
|
|
58
|
+
const kindOf = (field) => Object.entries(data.fields ?? {}).find(([declared]) => comparableText(declared) === comparableText(field))?.[1];
|
|
59
|
+
// Closed names for a list, as the skills, or for a text, as an alignment.
|
|
60
|
+
const notList = [...Object.keys(values), ...Object.keys(sheetValues)].find((field) => kindOf(field) !== "list" && kindOf(field) !== "text");
|
|
61
|
+
if (notList !== undefined) {
|
|
62
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: values.${notList}: declare ${notList} as a list or a text in fields, or give no values to it.`);
|
|
63
|
+
}
|
|
64
|
+
// What breaks what someone keeps, and what a counter shields, read counters (EFF-14, DAT-14).
|
|
65
|
+
const counted = [
|
|
66
|
+
...(data.keeping === undefined ? [] : [{ where: "keeping.counter", field: data.keeping.counter }]),
|
|
67
|
+
...(data.damage === undefined ? [] : [{ where: "damage.counter", field: data.damage.counter }]),
|
|
68
|
+
...(data.combat === undefined ? [] : [{ where: "combat.track", field: data.combat.track }]),
|
|
69
|
+
...(data.down === undefined ? [] : [{ where: "down.at", field: data.down.at.split(" ")[0] }]),
|
|
70
|
+
...Object.entries(data.counters ?? {}).flatMap(([counter, limits]) => (limits.shields === undefined ? [] : [{ where: `counters.${counter}.shields`, field: limits.shields }])),
|
|
71
|
+
].find((entry) => kindOf(entry.field) !== "counter");
|
|
72
|
+
const unknownCondition = [
|
|
73
|
+
...(data.keeping?.conditions ?? []).map((condition) => ({ where: "keeping.conditions", condition })),
|
|
74
|
+
...(data.combat?.inactive ?? []).map((condition) => ({ where: "combat.inactive", condition })),
|
|
75
|
+
].find((entry) => !(data.conditions ?? []).some((named) => comparableText(named) === comparableText(entry.condition)));
|
|
76
|
+
if (unknownCondition !== undefined) {
|
|
77
|
+
const named = (data.conditions ?? []).length === 0 ? "" : ` (${(data.conditions ?? []).join(", ")})`;
|
|
78
|
+
const what = `${unknownCondition.where}: ${unknownCondition.condition} is not one of its conditions${named}; write it as one of them, or add it to conditions.`;
|
|
79
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${what}`);
|
|
80
|
+
}
|
|
81
|
+
const gridField = [data.grid?.speed, data.grid?.size].find((field) => field !== undefined && kindOf(field) === undefined);
|
|
82
|
+
if (gridField !== undefined) {
|
|
83
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: grid: ${gridField} is not declared in fields.`);
|
|
84
|
+
}
|
|
85
|
+
if (counted !== undefined) {
|
|
86
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${counted.where}: ${counted.field} is not declared as a counter in fields.`);
|
|
87
|
+
}
|
|
88
|
+
// A state check compares a field the system declares, written as one, and its line names only the page and such fields (CHK-2).
|
|
89
|
+
const checks = data.checks ?? [];
|
|
90
|
+
const atoms = checks.flatMap((check) => [check.when, check.needs]);
|
|
91
|
+
const miswritten = atoms.find((atom) => /[<>=!]/.test(atom) && !checkFieldPattern.test(atom.trim()));
|
|
92
|
+
const checkField = atoms.map(checkAtom).find((atom) => "field" in atom && kindOf(atom.field) === undefined);
|
|
93
|
+
const placeholder = checks.flatMap((check) => [...check.say.matchAll(/\{([^{}]+)\}/g)].map((found) => found[1])).find((named) => named !== "page" && kindOf(named) === undefined);
|
|
94
|
+
const checkProblem = miswritten !== undefined
|
|
95
|
+
? `"${miswritten}" is no comparison: write a field, one of < <= = != >= >, and a whole number, such as hp <= 0`
|
|
96
|
+
: checkField !== undefined && "field" in checkField
|
|
97
|
+
? `${checkField.field} is not declared in fields`
|
|
98
|
+
: placeholder === undefined
|
|
99
|
+
? undefined
|
|
100
|
+
: `{${placeholder}} in say is neither {page} nor a field declared in fields`;
|
|
101
|
+
if (checkProblem !== undefined) {
|
|
102
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: checks: ${checkProblem}.`);
|
|
103
|
+
}
|
|
104
|
+
// A use of a turn goes within another the system names (TRN-3).
|
|
105
|
+
const turnUses = data["turn-uses"] ?? {};
|
|
106
|
+
const looseUse = Object.entries(turnUses).find(([, rule]) => rule.within !== undefined && !Object.keys(turnUses).some((use) => comparableText(use) === comparableText(rule.within ?? "")));
|
|
107
|
+
if (looseUse !== undefined) {
|
|
108
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: turn-uses.${looseUse[0]}: ${looseUse[1].within} is not one of its turn-uses; name one, or add it.`);
|
|
109
|
+
}
|
|
110
|
+
// The lists whose types change damage are lists (DMG-1).
|
|
111
|
+
const damageLists = data.damage === undefined ? [] : ["halves", "ignores", "doubles"].map((key) => ({ where: `damage.${key}`, field: data.damage?.[key] ?? "" }));
|
|
112
|
+
const notListed = damageLists.find((entry) => kindOf(entry.field) !== "list");
|
|
113
|
+
if (notListed !== undefined) {
|
|
114
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${notListed.where}: ${notListed.field} is not declared as a list in fields.`);
|
|
115
|
+
}
|
|
116
|
+
const notMarking = [...(data.marks ?? []), ...[data.progression?.list, data.progression?.parts?.list].filter((field) => field !== undefined)].find((field) => kindOf(field) !== "list");
|
|
117
|
+
if (notMarking !== undefined) {
|
|
118
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${notMarking} is not declared as a list in fields, as marks and progression need.`);
|
|
119
|
+
}
|
|
120
|
+
// Each number rolled with dice is a declared field, and has one set of dice (D-280).
|
|
121
|
+
const rolled = Object.entries(data["sheet-dice"] ?? {}).flatMap(([dice, fields]) => fields.map((field) => [field, dice]));
|
|
122
|
+
const undeclared = rolled.find(([field]) => kindOf(field) === undefined);
|
|
123
|
+
const twice = rolled.find(([field], index) => rolled.findIndex(([other]) => comparableText(other) === comparableText(field)) !== index);
|
|
124
|
+
if (undeclared !== undefined) {
|
|
125
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-dice.${undeclared[1]}: ${undeclared[0]} is not declared in fields.`);
|
|
126
|
+
}
|
|
127
|
+
if (twice !== undefined) {
|
|
128
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-dice: ${twice[0]} is listed twice; give each field one set of dice.`);
|
|
129
|
+
}
|
|
130
|
+
const unknownKnowledge = (data["sheet-knowledge"] ?? []).find((field) => kindOf(field) === undefined);
|
|
131
|
+
if (unknownKnowledge !== undefined) {
|
|
132
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-knowledge: ${unknownKnowledge} is not declared in fields.`);
|
|
133
|
+
}
|
|
134
|
+
// The cards the dashboard places are groups of the sheet (D-295); at hand in a fight, its fields too (D-315).
|
|
135
|
+
for (const [key, names] of Object.entries(data["sheet-cards"] ?? {})) {
|
|
136
|
+
const fields = key === "at-hand" ? sheet.flatMap((group) => group.entries.map((entry) => comparableText(entry.field))) : [];
|
|
137
|
+
const stray = (names ?? []).find((group) => !sheet.some((declared) => comparableText(declared.name) === comparableText(group)) && !fields.includes(comparableText(group)));
|
|
138
|
+
if (stray !== undefined) {
|
|
139
|
+
const kinds = key === "at-hand" ? "group or field" : "group";
|
|
140
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-cards.${key}: the sheet has no ${kinds} ${stray}; its groups are ${sheet.map((group) => group.name).join(", ")}.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// The fields the player acts with are fields of the sheet (D-495).
|
|
144
|
+
const actless = Object.keys(data["sheet-actions"] ?? {}).find((field) => !sheet.some((group) => group.entries.some((entry) => entry.field === field)));
|
|
145
|
+
if (actless !== undefined) {
|
|
146
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-actions: the sheet has no field ${actless}.`);
|
|
147
|
+
}
|
|
148
|
+
// Each verb is the engine's or one the system declares, never both (D-514).
|
|
149
|
+
const ownVerbs = Object.keys(data["sheet-verbs"] ?? {});
|
|
150
|
+
const taken = ownVerbs.find((verb) => actVerbs.includes(verb));
|
|
151
|
+
const verbs = [...actVerbs, ...ownVerbs];
|
|
152
|
+
const unknownVerb = Object.entries(data["sheet-actions"] ?? {}).flatMap(([field, listed]) => listed.filter((verb) => !verbs.includes(verb)).map((verb) => `${field}: ${verb}`))[0];
|
|
153
|
+
if (taken !== undefined) {
|
|
154
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-verbs: ${taken} is one of the engine's verbs, whose words the dashboard has; leave it out.`);
|
|
155
|
+
}
|
|
156
|
+
if (unknownVerb !== undefined) {
|
|
157
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-actions.${unknownVerb} is no verb: give one of ${verbs.join(", ")}, or declare it in sheet-verbs.`);
|
|
158
|
+
}
|
|
159
|
+
// Each field the headline names is a declared one (D-288).
|
|
160
|
+
const unnamed = [...(data["sheet-headline"] ?? "").matchAll(headlineFieldPattern)].map((match) => match[1]).find((field) => kindOf(field) === undefined);
|
|
161
|
+
if (unnamed !== undefined) {
|
|
162
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-headline: ${unnamed} is not declared in fields.`);
|
|
163
|
+
}
|
|
164
|
+
// The tokens' icons read a declared field (D-414).
|
|
165
|
+
const iconField = data["token-icons"]?.field;
|
|
166
|
+
if (iconField !== undefined && kindOf(iconField) === undefined) {
|
|
167
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: token-icons.field: ${iconField} is not declared in fields.`);
|
|
168
|
+
}
|
|
169
|
+
const asking = settingsAsking(data.settings ?? {});
|
|
170
|
+
if (asking !== undefined) {
|
|
171
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: settings.${asking}.`);
|
|
172
|
+
}
|
|
173
|
+
const experience = data.progression?.experience?.table;
|
|
174
|
+
if (experience !== undefined && !Object.keys(formulas.tables).some((table) => comparableText(table) === comparableText(experience))) {
|
|
175
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: progression.experience.table: there is no table ${experience} in tables.`);
|
|
176
|
+
}
|
|
177
|
+
return frozen({
|
|
178
|
+
name,
|
|
179
|
+
folder,
|
|
180
|
+
...(version === undefined ? {} : { version: { name: version.name, ...(version.title === undefined ? {} : { title: version.title }), folder: version.folder } }),
|
|
181
|
+
code: systemHasCode(folder),
|
|
182
|
+
title: data.title,
|
|
183
|
+
language: data.language,
|
|
184
|
+
attribution: data.attribution,
|
|
185
|
+
...(data.theme === undefined ? {} : { theme: join(folder, data.theme) }),
|
|
186
|
+
fields: data.fields ?? {},
|
|
187
|
+
coins: data.coins,
|
|
188
|
+
coinMetals: data["coin-metals"] ?? {},
|
|
189
|
+
roundSeconds: data.round === undefined ? undefined : Number.parseInt(data.round, 10),
|
|
190
|
+
...(data.imperial === undefined ? {} : { imperial: { mile: readLength(data.imperial.mile) ?? 0, foot: readLength(data.imperial.foot) ?? 0 } }),
|
|
191
|
+
...(data.imperial?.pound === undefined ? {} : { pound: Number.parseFloat(data.imperial.pound) }),
|
|
192
|
+
...(data["length-unit"] === undefined ? {} : { lengthUnit: data["length-unit"] }),
|
|
193
|
+
bonusLists: data["bonus-lists"] ?? [],
|
|
194
|
+
bonusWhile: Object.fromEntries(Object.entries(data.bonds ?? {}).flatMap(([list, bond]) => (bond.while === undefined ? [] : [[list, bond.while]]))),
|
|
195
|
+
...(data.load === undefined ? {} : {
|
|
196
|
+
load: {
|
|
197
|
+
field: data.load.field,
|
|
198
|
+
// Formulas in order, the first with a value counts, as a computed field's (D-210).
|
|
199
|
+
limit: Array.isArray(data.load.limit)
|
|
200
|
+
? { kind: "first", options: data.load.limit.map((option, index) => formulaAt(String(option), `load.limit.${index}`, name, path)) }
|
|
201
|
+
: formulaAt(data.load.limit, "load.limit", name, path),
|
|
202
|
+
...(data.load.coins === undefined ? {} : { coins: data.load.coins }),
|
|
203
|
+
...(data.load.weightless === undefined ? {} : { weightless: data.load.weightless }),
|
|
204
|
+
...(data.load.bundle === undefined ? {} : { bundle: data.load.bundle }),
|
|
205
|
+
...(data.load.stages === undefined ? {} : { stages: data.load.stages.map((stage) => ({ name: stage.name, formula: formulaAt(stage.when, `load.stages.${stage.name}`, name, path) })) }),
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
...(data.travel === undefined ? {} : { travel: travelOf(data.travel) }),
|
|
209
|
+
...(data.grid === undefined ? {} : { grid: gridOf(data.grid) }),
|
|
210
|
+
sheet,
|
|
211
|
+
sheetDice: Object.fromEntries(rolled),
|
|
212
|
+
sheetKnowledge: data["sheet-knowledge"] ?? [],
|
|
213
|
+
...(data["sheet-odds"] === undefined ? {} : {
|
|
214
|
+
sheetOdds: {
|
|
215
|
+
better: data["sheet-odds"].better,
|
|
216
|
+
worse: data["sheet-odds"].worse,
|
|
217
|
+
when: data["sheet-odds"].when.map((when) => ({
|
|
218
|
+
fields: when.fields,
|
|
219
|
+
...(when.better === undefined ? {} : { better: formulaAt(when.better, "sheet-odds.when.better", name, path) }),
|
|
220
|
+
...(when.worse === undefined ? {} : { worse: formulaAt(when.worse, "sheet-odds.when.worse", name, path) }),
|
|
221
|
+
...(when.why === undefined ? {} : { why: when.why }),
|
|
222
|
+
})),
|
|
223
|
+
},
|
|
224
|
+
}),
|
|
225
|
+
rollNames: Object.fromEntries(Object.entries(data["roll-names"] ?? {}).map(([dice, names]) => [plainRoll(dice), typeof names === "string" ? { [data.language]: names } : names])),
|
|
226
|
+
...(data["sheet-headline"] === undefined ? {} : { sheetHeadline: data["sheet-headline"] }),
|
|
227
|
+
...(data["token-icons"] === undefined ? {} : { tokenIcons: data["token-icons"] }),
|
|
228
|
+
...(data["sheet-actions"] === undefined ? {} : { sheetActions: data["sheet-actions"] }),
|
|
229
|
+
sheetVerbs: Object.fromEntries(Object.entries(data["sheet-verbs"] ?? {}).map(([verb, words]) => [verb, sheetVerbOf(words)])),
|
|
230
|
+
...(data["sheet-cards"] === undefined ? {} : { sheetCards: { rail: data["sheet-cards"].rail ?? [], order: data["sheet-cards"].order ?? [], atHand: data["sheet-cards"]["at-hand"] ?? [] } }),
|
|
231
|
+
values,
|
|
232
|
+
sheetValues,
|
|
233
|
+
marks: data.marks ?? [],
|
|
234
|
+
statusLine: (data["status-line"] ?? []).map((entry) => ({ field: entry.replace(/\?$/, ""), whenSet: entry.endsWith("?") })),
|
|
235
|
+
thresholds: Object.entries(data.thresholds ?? {}).map(([key, rule]) => {
|
|
236
|
+
const [field, value] = key.split(" ");
|
|
237
|
+
return { field, value: value === undefined ? undefined : Number(value), rule };
|
|
238
|
+
}),
|
|
239
|
+
recipes: Object.entries(data.recipes ?? {}).map(([recipe, value]) => ({
|
|
240
|
+
name: recipe,
|
|
241
|
+
set: value.set ?? {},
|
|
242
|
+
regain: regainOf(value.regain ?? {}, name, path, recipe),
|
|
243
|
+
lower: Object.fromEntries(Object.entries(value.lower ?? {}).map(([field, amount]) => [field, formulaAt(String(amount), `recipes.${recipe}.lower.${field}`, name, path)])),
|
|
244
|
+
...(value.needs === undefined ? {} : { needs: value.needs }),
|
|
245
|
+
...(value["once-per"] === undefined ? {} : { oncePer: value["once-per"] }),
|
|
246
|
+
...(value.lasts === undefined ? {} : { lasts: value.lasts }),
|
|
247
|
+
spend: Object.fromEntries(Object.entries(value.spend ?? {}).map(([field, rule]) => [field, { gives: rule.gives, adds: formulaAt(String(rule.adds ?? 0), `recipes.${recipe}.spend.${field}`, name, path) }])),
|
|
248
|
+
ends: value.ends ?? [],
|
|
249
|
+
rules: value.rules ?? [],
|
|
250
|
+
})),
|
|
251
|
+
conditions: data.conditions ?? [],
|
|
252
|
+
conditionIcons: data["condition-icons"] ?? {},
|
|
253
|
+
icons: data.icons ?? {},
|
|
254
|
+
widgets: declaredWidgets(data.widgets),
|
|
255
|
+
figures: data.figures ?? {},
|
|
256
|
+
bonds: data.bonds ?? {},
|
|
257
|
+
...(data.upkeep === undefined ? {} : { upkeep: data.upkeep }),
|
|
258
|
+
burning: data.burning ?? {},
|
|
259
|
+
...(data.immune === undefined ? {} : { immune: data.immune }),
|
|
260
|
+
...(data.oracle === undefined ? {} : { oracleYes: data.oracle.yes }),
|
|
261
|
+
turnUses: Object.fromEntries(Object.entries(data["turn-uses"] ?? {}).map(([use, rule]) => [use, {
|
|
262
|
+
...(rule.most === undefined ? {} : { most: formulaAt(String(rule.most), `turn-uses.${use}.most`, name, path) }),
|
|
263
|
+
...(rule.within === undefined ? {} : { within: rule.within }),
|
|
264
|
+
...(rule.needs === undefined ? {} : { needs: formulaAt(rule.needs, `turn-uses.${use}.needs`, name, path) }),
|
|
265
|
+
anyTurn: rule["any-turn"] ?? false,
|
|
266
|
+
resets: rule.resets ?? "own turn",
|
|
267
|
+
...(rule.note === undefined ? {} : { note: rule.note }),
|
|
268
|
+
...(rule["note-when"] === undefined ? {} : { noteWhen: formulaAt(rule["note-when"], `turn-uses.${use}.note-when`, name, path) }),
|
|
269
|
+
}])),
|
|
270
|
+
atMost: Object.fromEntries(Object.entries(data["at-most"] ?? {}).map(([field, most]) => [field, formulaAt(String(most), `at-most.${field}`, name, path)])),
|
|
271
|
+
...(data.damage === undefined ? {} : { damage: data.damage }),
|
|
272
|
+
...(data.keeping === undefined ? {} : { keeping: { counter: data.keeping.counter, conditions: data.keeping.conditions ?? [], rules: data.keeping.rules } }),
|
|
273
|
+
...(data.combat === undefined ? {} : { combat: { track: data.combat.track, inWords: data.combat["in-words"] ?? [], inactive: data.combat.inactive ?? [] } }),
|
|
274
|
+
...(data.down === undefined ? {} : { down: downRule(data.down.at) }),
|
|
275
|
+
checks: (data.checks ?? []).map((check) => ({ when: checkAtom(check.when), needs: checkAtom(check.needs), say: check.say })),
|
|
276
|
+
shields: Object.fromEntries(Object.entries(data.counters ?? {}).flatMap(([counter, limits]) => (limits.shields === undefined ? [] : [[counter, limits.shields]]))),
|
|
277
|
+
formulas,
|
|
278
|
+
...(data.progression === undefined ? {} : { progression: progressionRule(data.progression) }),
|
|
279
|
+
itemFormulas: data["item-formulas"] ?? {},
|
|
280
|
+
alwaysIn: data["always-in"] ?? {},
|
|
281
|
+
uses: usesOf(data),
|
|
282
|
+
// The versions first, as the setup asks them before what they may change; one alone is no choice, and no setting (VER-1).
|
|
283
|
+
settings: [...(Object.keys(data.versions ?? {}).filter((key) => key !== "about").length < 2 ? [] : [[rulesetSetting, data.versions ?? {}]]), ...Object.entries(data.settings ?? {})].map(([setting, values]) => ({
|
|
284
|
+
name: setting,
|
|
285
|
+
...(typeof values.about === "string" ? { about: values.about } : {}),
|
|
286
|
+
values: Object.entries(values).flatMap(([value, meaning]) => typeof meaning === "string" ? [] : [{
|
|
287
|
+
value,
|
|
288
|
+
means: meaning.means,
|
|
289
|
+
...(meaning.player === undefined ? {} : { player: meaning.player }),
|
|
290
|
+
without: meaning.without ?? [],
|
|
291
|
+
engineSettings: meaning["engine-settings"] ?? {},
|
|
292
|
+
asks: meaning.asks ?? [],
|
|
293
|
+
...(meaning.suggested === true ? { suggested: true } : {}),
|
|
294
|
+
}]),
|
|
295
|
+
})),
|
|
296
|
+
engineSettings: data["engine-settings"] ?? {},
|
|
297
|
+
leftOut: [],
|
|
298
|
+
rewards: Object.entries(data.rewards ?? {}).map(([field, reward]) => {
|
|
299
|
+
const [counter, value] = reward.overcome.split(" ");
|
|
300
|
+
return { field, from: reward.from, counter, value: Number(value) };
|
|
301
|
+
}),
|
|
302
|
+
// A part of its version takes the place of its own of that name (VER-3).
|
|
303
|
+
parts: { ...readParts(folder, `The game system ${name}`), ...(version === undefined ? {} : readParts(version.folder, `The game system ${name}, its version ${version.name},`)) },
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
// A field named in the headline under a character's name: {level} (D-288).
|
|
307
|
+
const headlineFieldPattern = /\{([^{}]+)\}/g;
|
|
308
|
+
/** What is wrong in the settings a value asks, or in the value a setting suggests (DAT-17): "die.d6: asks die, which is its own setting"; undefined when nothing is. */
|
|
309
|
+
function settingsAsking(settings) {
|
|
310
|
+
const names = Object.keys(settings);
|
|
311
|
+
for (const [setting, values] of Object.entries(settings)) {
|
|
312
|
+
const shown = Object.entries(values).flatMap(([value, meaning]) => (typeof meaning === "string" ? [] : [[value, meaning]]));
|
|
313
|
+
if (shown.filter(([, meaning]) => meaning.suggested === true).length > 1) {
|
|
314
|
+
return `${setting}: suggest one value at most`;
|
|
315
|
+
}
|
|
316
|
+
for (const [value, meaning] of shown) {
|
|
317
|
+
const stray = (meaning.asks ?? []).find((asked) => comparableText(asked) === comparableText(setting) || !names.some((name) => comparableText(name) === comparableText(asked)));
|
|
318
|
+
if (stray !== undefined) {
|
|
319
|
+
return `${setting}.${value}: asks ${stray}, which is ${comparableText(stray) === comparableText(setting) ? "its own setting" : "no setting of the system"}: name another of its settings`;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* "counters.bulwark-dice: unknown key "Bulwark)", a formula with commas goes in quotes": the problems of a system's data, one after the other on
|
|
327
|
+
* a line, each at its place.
|
|
328
|
+
*/
|
|
329
|
+
function issuesText(error) {
|
|
330
|
+
return error.issues.map((issue) => {
|
|
331
|
+
const place = issue.path.map(String).join(".");
|
|
332
|
+
const keys = issue.code === "unrecognized_keys" ? issue.keys : [];
|
|
333
|
+
const quotes = keys.some((key) => /[()]/.test(key)) ? ": a formula with commas goes in quotes" : "";
|
|
334
|
+
const vague = issue.message === "Invalid input" ? "not a value it takes, as system.yaml writes it" : issue.message;
|
|
335
|
+
const message = keys.length > 0 ? `unknown ${keys.length === 1 ? "key" : "keys"} ${keys.map((key) => `"${key}"`).join(", ")}${quotes}` : vague;
|
|
336
|
+
return place === "" ? `${message}.` : `${place}: ${message}.`;
|
|
337
|
+
}).join(" ");
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* A recipe that sets kept rolls (KEP-4), or a refill on an occasion that no recipe ends, which would never bring the use back (DAT-9): where it is and why;
|
|
341
|
+
* undefined when there is none.
|
|
342
|
+
*/
|
|
343
|
+
function strayOccasion(data, formulas) {
|
|
344
|
+
const occasions = Object.values(data.recipes ?? {}).flatMap((recipe) => recipe.ends ?? []).filter((occasion, index, all) => all.findIndex((other) => comparableText(other) === comparableText(occasion)) === index);
|
|
345
|
+
// Kept rolls come back as the player rolls them again (KEP-4), never at a value a recipe gives.
|
|
346
|
+
for (const [recipe, value] of Object.entries(data.recipes ?? {})) {
|
|
347
|
+
const rolls = Object.keys(value.set ?? {}).find((field) => Object.entries(data.fields ?? {}).some(([declared, kind]) => kind === "rolls" && comparableText(declared) === comparableText(field)));
|
|
348
|
+
if (rolls !== undefined) {
|
|
349
|
+
return `recipes.${recipe}.set.${rolls}: ${rolls} keeps rolls, which come back as they are rolled again with roll and keep, not at a value.`;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
for (const [counter, limits] of Object.entries(formulas.counters)) {
|
|
353
|
+
const occasion = Object.keys(limits.refill ?? {}).find((candidate) => !occasions.some((other) => comparableText(other) === comparableText(candidate)));
|
|
354
|
+
if (occasion !== undefined) {
|
|
355
|
+
const known = occasions.length === 0 ? "no recipe ends one yet: give a recipe its ends" : `the occasions are ${occasions.join(", ")}`;
|
|
356
|
+
return `counters.${counter}.refill: ${occasion} is no occasion a recipe ends, so it would never come back; ${known}.`;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
/** The progression as the system declares it (PRO-1–PRO-4, PRO-6). */
|
|
362
|
+
function progressionRule(data) {
|
|
363
|
+
const { skip, ...rule } = data;
|
|
364
|
+
return { ...rule, skip: skip ?? [] };
|
|
365
|
+
}
|
|
366
|
+
/** The groups of a system's sheet, each with its note and its icon; a note or an icon for a group the sheet does not have is refused. */
|
|
367
|
+
function sheetOf(data, name, path) {
|
|
368
|
+
const groups = Object.entries(data.sheet ?? {});
|
|
369
|
+
const notes = Object.entries(data["sheet-notes"] ?? {});
|
|
370
|
+
const icons = Object.entries(data["sheet-icons"] ?? {});
|
|
371
|
+
const byGroup = (pairs, group) => pairs.find(([other]) => comparableText(other) === comparableText(group))?.[1];
|
|
372
|
+
for (const [key, pairs] of [["sheet-notes", notes], ["sheet-icons", icons]]) {
|
|
373
|
+
const stray = pairs.find(([group]) => !groups.some(([other]) => comparableText(other) === comparableText(group)));
|
|
374
|
+
if (stray !== undefined) {
|
|
375
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${key}.${stray[0]}: the sheet has no group ${stray[0]}; its groups are ${groups.map(([group]) => group).join(", ")}.`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return groups.map(([group, entries]) => {
|
|
379
|
+
const note = byGroup(notes, group);
|
|
380
|
+
const icon = byGroup(icons, group);
|
|
381
|
+
return {
|
|
382
|
+
name: group,
|
|
383
|
+
entries: entries.map((entry) => {
|
|
384
|
+
const [, field, optional, beside] = sheetEntryPattern.exec(entry) ?? [];
|
|
385
|
+
return { field, optional: optional === "?", ...(beside === undefined ? {} : { beside }) };
|
|
386
|
+
}),
|
|
387
|
+
...(note === undefined ? {} : { note }),
|
|
388
|
+
...(icon === undefined ? {} : { icon }),
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/** A verb of the system as the dashboard reads it (D-514): with its sentences on someone, at a square and on oneself only when it lets the player choose. */
|
|
393
|
+
function sheetVerbOf(words) {
|
|
394
|
+
const choosing = words["says-on"] === undefined ? {} : { on: words["says-on"], at: words["says-at"], self: words["says-self"] };
|
|
395
|
+
return { label: words.label, title: words.title, says: words.says, ...choosing };
|
|
396
|
+
}
|
|
397
|
+
/** How the system's map of a place counts, as the engine reads it (GRD-4): the square in metres. */
|
|
398
|
+
function gridOf(data) {
|
|
399
|
+
const { square, size, footprints, leaving, ...rest } = data;
|
|
400
|
+
return { ...rest, square: readLength(square) ?? 0, ...(size === undefined ? {} : { size }), footprints: footprints ?? {}, ...(leaving === undefined ? {} : { leaving }) };
|
|
401
|
+
}
|
|
402
|
+
/** The system's travel as the engine reads it (TRV-1–TRV-3): speeds in metres an hour, factors as numbers. */
|
|
403
|
+
function travelOf(data) {
|
|
404
|
+
const paces = Object.fromEntries(Object.entries(data.paces ?? {}).map(([name, speed]) => [name, readSpeed(speed) ?? 0]));
|
|
405
|
+
return {
|
|
406
|
+
paces,
|
|
407
|
+
pace: data.pace === undefined ? Object.keys(paces)[0] : sameName(Object.keys(paces), data.pace),
|
|
408
|
+
hours: data.hours,
|
|
409
|
+
rule: data.rule,
|
|
410
|
+
beyond: data.beyond,
|
|
411
|
+
terrain: Object.fromEntries(Object.entries(data.terrain ?? {}).map(([value, factor]) => [value, factorOf(factor)])),
|
|
412
|
+
vehicles: Object.entries(data.vehicles ?? {}).flatMap(([field, values]) => [values].flat().map((value) => ({ field, value }))),
|
|
413
|
+
kinds: Object.entries(data.kinds ?? {}).map(([name, kind]) => {
|
|
414
|
+
const [field, value] = Object.entries(kind.vehicle ?? {})[0] ?? [];
|
|
415
|
+
return {
|
|
416
|
+
name,
|
|
417
|
+
...(field === undefined || value === undefined || kind.speed === undefined ? {} : { vehicle: { field, value, speed: kind.speed } }),
|
|
418
|
+
hours: kind.hours,
|
|
419
|
+
current: kind.current === undefined ? undefined : readSpeed(kind.current),
|
|
420
|
+
};
|
|
421
|
+
}),
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
/** A factor of speed as a number: 1/2 is 0.5. */
|
|
425
|
+
function factorOf(factor) {
|
|
426
|
+
if (typeof factor === "number") {
|
|
427
|
+
return factor;
|
|
428
|
+
}
|
|
429
|
+
const [numerator, denominator] = factor.split("/").map(Number);
|
|
430
|
+
return numerator / denominator;
|
|
431
|
+
}
|
|
432
|
+
/** The counters that come back with a rest (DAT-9): those with a refill, and those a recipe sets or regains. */
|
|
433
|
+
function usesOf(data) {
|
|
434
|
+
const names = [
|
|
435
|
+
...Object.entries(data.counters ?? {}).filter(([, limits]) => limits.refill !== undefined).map(([name]) => name),
|
|
436
|
+
...Object.values(data.recipes ?? {}).flatMap((recipe) => [...Object.keys(recipe.set ?? {}), ...Object.keys(recipe.regain ?? {})]),
|
|
437
|
+
];
|
|
438
|
+
return names.filter((name, index) => names.findIndex((other) => comparableText(other) === comparableText(name)) === index);
|
|
439
|
+
}
|
|
440
|
+
/** The formulas of a recipe's regain, each read at its place (FOR-9). */
|
|
441
|
+
function regainOf(regain, name, path, recipe) {
|
|
442
|
+
return Object.fromEntries(Object.entries(regain).map(([field, amount]) => [field, formulaAt(amount, `recipes.${recipe}.regain.${field}`, name, path)]));
|
|
443
|
+
}
|
|
444
|
+
/** A formula of a system's file, refused with the key it stands at (FOR-9). */
|
|
445
|
+
function formulaAt(written, place, name, path) {
|
|
446
|
+
try {
|
|
447
|
+
return formulaOf(written);
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${place}: ${error instanceof Error ? error.message : String(error)}`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/** The formulas of a system, read once; a system whose formulas do not read cannot be read either (FOR-9). */
|
|
454
|
+
function systemFormulas(data, name, path) {
|
|
455
|
+
try {
|
|
456
|
+
return readFormulas(data);
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: ${error instanceof Error ? error.message : String(error)}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/** What a state check reads, as written (CHK-2): "hp <= 0" a field against a number, anything else an effect's name. */
|
|
463
|
+
function checkAtom(text) {
|
|
464
|
+
const field = checkFieldPattern.exec(text.trim());
|
|
465
|
+
return field === null ? { effect: text.trim() } : { field: field[1], op: field[2], value: Number(field[3]) };
|
|
466
|
+
}
|
|
467
|
+
/** When one is down as the system writes it: "hp 0" read as a field and a number. */
|
|
468
|
+
function downRule(at) {
|
|
469
|
+
const [field, value] = at.split(" ");
|
|
470
|
+
return { field, value: Number(value) };
|
|
471
|
+
}
|