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
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import type { Coin } from "../../money/index.ts";
|
|
1
3
|
import { type Page, type World } from "../../pages/index.ts";
|
|
2
4
|
import type { DamageRule, GameSystem } from "../../systems/index.ts";
|
|
5
|
+
import { counterStep } from "./amounts.ts";
|
|
6
|
+
import { type CounterHolder, type StepOutcome } from "./holder.ts";
|
|
3
7
|
/** What a page takes of an amount of damage of a type, and the note that says why when it is not the amount. */
|
|
4
8
|
export interface DamageTaken {
|
|
5
9
|
amount: number;
|
|
@@ -16,3 +20,29 @@ export declare function damageTaken(system: GameSystem, rule: DamageRule, fields
|
|
|
16
20
|
* and what its effects give, as a rage (DMG-1): an effect adds to the list, never covers it. A list written as text stays text, for damageTaken to refuse.
|
|
17
21
|
*/
|
|
18
22
|
export declare function damageLists(world: World, page: Page, rule: DamageRule): Record<string, unknown>;
|
|
23
|
+
/** The damage a page takes of the type given (DMG-1): only with by, negative, on the counter the system's damage takes from. */
|
|
24
|
+
export declare function typedDamage(system: GameSystem | undefined, fields: Record<string, unknown>, field: string, input: {
|
|
25
|
+
by?: number | string;
|
|
26
|
+
spend?: unknown;
|
|
27
|
+
to?: unknown;
|
|
28
|
+
damage?: string;
|
|
29
|
+
}, page: string): DamageTaken;
|
|
30
|
+
/**
|
|
31
|
+
* Damage of a type taken by its counter (DMG-1): the counter that shields it loses first, as temporary hit points (DAT-14), then the counter the rest; one
|
|
32
|
+
* outcome that says both, and why the damage is not the amount given.
|
|
33
|
+
*/
|
|
34
|
+
export declare function damageSteps(root: string, context: Context, world: World, target: {
|
|
35
|
+
holder: CounterHolder;
|
|
36
|
+
name: string;
|
|
37
|
+
fields: Record<string, unknown>;
|
|
38
|
+
field: string;
|
|
39
|
+
limits: Parameters<typeof counterStep>[5];
|
|
40
|
+
coins: Coin[] | undefined;
|
|
41
|
+
}, damage: DamageTaken, why: string | undefined, system: GameSystem | undefined): {
|
|
42
|
+
outcome: StepOutcome;
|
|
43
|
+
lost: number;
|
|
44
|
+
};
|
|
45
|
+
/** "Ghoul 1 has damage-immunities poison: …": for damage given without a type to a page whose lists change some (DMG-1); empty otherwise. */
|
|
46
|
+
export declare function untypedDamageNote(world: World, system: GameSystem | undefined, page: Page, field: string): string;
|
|
47
|
+
/** The counter that shields a counter, losing first, as temporary hit points (DAT-14); undefined when none does. */
|
|
48
|
+
export declare function shieldOf(system: GameSystem | undefined, field: string): string | undefined;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
// Damage of a type (D-449, DMG-1–DMG-3): what the lists of who takes it ignore, halve or double, before the counter loses it.
|
|
2
1
|
import { comparableText, valueNamed } from "../../core/text.js";
|
|
2
|
+
import { readCounter } from "../../counters/index.js";
|
|
3
3
|
import { bonusPages, inheritedFields, textsIn } from "../../pages/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { keepingLossNote } from "../shared/scene/reminders.js";
|
|
5
|
+
import { readOpenScene } from "../shared/scene/scene.js";
|
|
6
|
+
import { effectsOf } from "../shared/sheet/effect-layer.js";
|
|
7
|
+
import { counterLimits } from "../shared/sheet/worked-out.js";
|
|
8
|
+
import { counterStep } from "./amounts.js";
|
|
9
|
+
import { applyStep, holderNamed } from "./holder.js";
|
|
5
10
|
/**
|
|
6
11
|
* The damage a page takes of a type (DMG-1, DMG-2): none when its ignoring list names the type, half rounded down when its halving list does, then doubled when
|
|
7
12
|
* its doubling list does. An item that names the type with a condition, as "slashing from nonmagical attacks", waits for the master to say whether it holds
|
|
@@ -72,3 +77,69 @@ function namesWord(text, word) {
|
|
|
72
77
|
const words = (value) => ` ${comparableText(value).replace(/[^\p{L}\p{N}]+/gu, " ").trim()} `;
|
|
73
78
|
return words(text).includes(words(word));
|
|
74
79
|
}
|
|
80
|
+
/** The damage a page takes of the type given (DMG-1): only with by, negative, on the counter the system's damage takes from. */
|
|
81
|
+
export function typedDamage(system, fields, field, input, page) {
|
|
82
|
+
const rule = system?.damage;
|
|
83
|
+
if (system === undefined || rule === undefined) {
|
|
84
|
+
throw new Error(`The game system ${system?.name ?? "of the campaign"} has no damage types: give by alone, such as by -12. Nothing changed.`);
|
|
85
|
+
}
|
|
86
|
+
if (comparableText(field) !== comparableText(rule.counter)) {
|
|
87
|
+
throw new Error(`A damage type goes with ${rule.counter}, not ${field}: change ${page} ${rule.counter} --by=-12 --damage fire. Nothing changed.`);
|
|
88
|
+
}
|
|
89
|
+
const by = typeof input.by === "number" ? input.by : Number(input.by);
|
|
90
|
+
if (input.spend !== undefined || input.to !== undefined || !Number.isSafeInteger(by) || by >= 0) {
|
|
91
|
+
throw new Error(`A damage type goes with by, negative, the damage before ${page}'s lists change it, such as by -12, damage fire. Nothing changed.`);
|
|
92
|
+
}
|
|
93
|
+
return damageTaken(system, rule, fields, -by, input.damage ?? "", page);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Damage of a type taken by its counter (DMG-1): the counter that shields it loses first, as temporary hit points (DAT-14), then the counter the rest; one
|
|
97
|
+
* outcome that says both, and why the damage is not the amount given.
|
|
98
|
+
*/
|
|
99
|
+
export function damageSteps(root, context, world, target, damage, why, system) {
|
|
100
|
+
const { holder, fields, field, coins } = target;
|
|
101
|
+
const page = holder.page.name;
|
|
102
|
+
const withNote = (outcome, notes) => ({ ...outcome, note: [...notes, outcome.note].filter((part) => part !== "").join("; ") });
|
|
103
|
+
const shield = shieldOf(system, field);
|
|
104
|
+
const shieldField = shield === undefined ? undefined : Object.keys(fields).find((name) => comparableText(name) === comparableText(shield));
|
|
105
|
+
const absorbed = shieldField === undefined ? 0 : Math.min(Math.max(readCounter(fields[shieldField])?.value ?? 0, 0), damage.amount);
|
|
106
|
+
const onCounter = (current, currentHolder, amount) => applyStep(root, context, current, currentHolder, field, counterStep({ by: -amount }, fields[field], page, field, coins, target.limits), why, system).outcome;
|
|
107
|
+
if (shieldField === undefined || absorbed === 0) {
|
|
108
|
+
return { outcome: withNote(onCounter(world, holder, damage.amount), [damage.note]), lost: damage.amount };
|
|
109
|
+
}
|
|
110
|
+
const shieldStep = counterStep({ by: -absorbed }, fields[shieldField], page, shieldField, coins, counterLimits(world, fields, shieldField));
|
|
111
|
+
const first = applyStep(root, context, world, holder, shieldField, shieldStep, why, system);
|
|
112
|
+
if (absorbed === damage.amount) {
|
|
113
|
+
return { outcome: withNote(first.outcome, [damage.note]), lost: 0 };
|
|
114
|
+
}
|
|
115
|
+
const outcome = onCounter(first.world, holderNamed(root, first.world, target.name), damage.amount - absorbed);
|
|
116
|
+
const shielded = `${shieldField} ${first.outcome.before} → ${first.outcome.after} first`;
|
|
117
|
+
// What someone keeps alive reads the whole damage, the shield's part too (EFF-14).
|
|
118
|
+
const keeping = keepingLossNote(world, readOpenScene(root).scene, system, page, field, damage.amount);
|
|
119
|
+
const merged = {
|
|
120
|
+
...withNote(outcome, [damage.note, shielded]),
|
|
121
|
+
thresholds: [...first.outcome.thresholds, ...outcome.thresholds],
|
|
122
|
+
// The shield is spent, so the only reminder left is what someone keeps (DAT-14).
|
|
123
|
+
reminders: keeping === "" ? [] : [keeping],
|
|
124
|
+
due: [...first.outcome.due, ...outcome.due],
|
|
125
|
+
followers: [...new Set([...first.outcome.followers, ...outcome.followers])],
|
|
126
|
+
keepers: [...new Set([...first.outcome.keepers, ...outcome.keepers])],
|
|
127
|
+
};
|
|
128
|
+
return { outcome: merged, lost: damage.amount - absorbed };
|
|
129
|
+
}
|
|
130
|
+
/** "Ghoul 1 has damage-immunities poison: …": for damage given without a type to a page whose lists change some (DMG-1); empty otherwise. */
|
|
131
|
+
export function untypedDamageNote(world, system, page, field) {
|
|
132
|
+
const rule = system?.damage;
|
|
133
|
+
if (rule === undefined || comparableText(field) !== comparableText(rule.counter)) {
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
const lists = Object.entries(damageLists(world, page, rule)).flatMap(([list, value]) => {
|
|
137
|
+
const items = textsIn(value);
|
|
138
|
+
return items.length === 0 ? [] : [`${list} ${items.join(", ")}`];
|
|
139
|
+
});
|
|
140
|
+
return lists.length === 0 ? "" : `${page.name} has ${lists.join("; ")}: if this damage has a type, give it with damage, as rolled.`;
|
|
141
|
+
}
|
|
142
|
+
/** The counter that shields a counter, losing first, as temporary hit points (DAT-14); undefined when none does. */
|
|
143
|
+
export function shieldOf(system, field) {
|
|
144
|
+
return Object.entries(system?.shields ?? {}).find(([, shielded]) => comparableText(shielded) === comparableText(field))?.[0];
|
|
145
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import { type World } from "../../pages/index.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Dice given as by, such as -(2d6+3), rolled with the engine's dice (D-459): the sign in front is the roll's, so -(2d6+3) takes away 2d6+3, never less than 0;
|
|
5
|
+
* undefined for a number, coins or any other text.
|
|
6
|
+
*/
|
|
7
|
+
export declare function diceBy(by: number | string | undefined, context: Context): {
|
|
8
|
+
by: number;
|
|
9
|
+
taking: boolean;
|
|
10
|
+
data: {
|
|
11
|
+
notation: string;
|
|
12
|
+
total: number;
|
|
13
|
+
result: string;
|
|
14
|
+
physical: false;
|
|
15
|
+
dice: unknown;
|
|
16
|
+
};
|
|
17
|
+
} | undefined;
|
|
18
|
+
/** The dice in by, hidden: the roll's id, the fingerprint the player may ask for, and whether master-rolls hid them. */
|
|
19
|
+
export interface HiddenDice {
|
|
20
|
+
id: string;
|
|
21
|
+
fingerprint: string;
|
|
22
|
+
screened: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Why the dice in by are hidden, or undefined when shown (D-287): with their change, on a page that does not concern the player, whatever master-rolls says;
|
|
26
|
+
* behind the screen, taking away from the player character or a companion, as a foe's or a trap's do. Healing them, or dice on a copy in the scene, are shown.
|
|
27
|
+
*/
|
|
28
|
+
export declare function diceHiding(root: string, world: World, name: string, taking: boolean): "secret" | "screen" | undefined;
|
|
29
|
+
/** Logs the roll of the dice in by, sealed when hidden as roll seals one; what the master is told of it when hidden. */
|
|
30
|
+
export declare function logDiceBy(root: string, context: Context, data: {
|
|
31
|
+
result: string;
|
|
32
|
+
} & Record<string, unknown>, hiding: "secret" | "screen" | undefined): HiddenDice | undefined;
|
|
33
|
+
/** "Rolled 2d6+3 = 11 [5, 3] + 3.", or the hidden roll as roll tells it, only for the master. */
|
|
34
|
+
export declare function rolledText(rolled: string, hidden: HiddenDice | undefined): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { appendLogEntry } from "../../core/log.js";
|
|
2
|
+
import { diceProblem, rollDice } from "../../dice/index.js";
|
|
3
|
+
import { isPartyMember } from "../../pages/index.js";
|
|
4
|
+
import { screenNote, screenUp, sealHiddenRoll } from "../shared/scene/master-rolls.js";
|
|
5
|
+
import { newDatedLogEntry } from "../shared/time/time.js";
|
|
6
|
+
import { holderNamed } from "./holder.js";
|
|
7
|
+
/**
|
|
8
|
+
* Dice given as by, such as -(2d6+3), rolled with the engine's dice (D-459): the sign in front is the roll's, so -(2d6+3) takes away 2d6+3, never less than 0;
|
|
9
|
+
* undefined for a number, coins or any other text.
|
|
10
|
+
*/
|
|
11
|
+
export function diceBy(by, context) {
|
|
12
|
+
const text = typeof by === "string" ? by.replace(/\s+/g, "") : "";
|
|
13
|
+
const body = text.replace(/^[+-]/, "");
|
|
14
|
+
const bracketed = /^\((.*)\)$/.exec(body)?.[1];
|
|
15
|
+
const notation = bracketed ?? body;
|
|
16
|
+
if (!/\d*d(\d+|%|F)/i.test(notation)) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
// Dice that do not read as a roll: as -(2d6)+3, with brackets around a part, the whole roll goes in them; in brackets already, what the dice say is wrong.
|
|
20
|
+
const problem = diceProblem(notation);
|
|
21
|
+
if (problem !== undefined) {
|
|
22
|
+
throw new Error(bracketed === undefined
|
|
23
|
+
? `by ${String(by)} does not read as a roll: put the whole roll in brackets after the sign, such as by -(2d6+3), which takes away 2d6+3. Nothing changed.`
|
|
24
|
+
: `by ${String(by)} does not read as a roll: ${problem} Nothing changed.`);
|
|
25
|
+
}
|
|
26
|
+
// -1d8-2 reads as 1d8+2 taken away or as 1d8-2 taken away: a minus before more than one term asks for brackets (playtest 08).
|
|
27
|
+
if (text.startsWith("-") && bracketed === undefined && /[+-]/.test(notation)) {
|
|
28
|
+
throw new Error(`by ${String(by)} reads two ways: put the roll in brackets after the minus, such as by -(1d8+2), which takes away 1d8+2. Nothing changed.`);
|
|
29
|
+
}
|
|
30
|
+
const rolled = rollDice(notation, { random: context.random });
|
|
31
|
+
const total = Math.max(0, rolled.total);
|
|
32
|
+
return { by: text.startsWith("-") ? -total : total, taking: text.startsWith("-"), data: { notation, total: rolled.total, result: rolled.text, physical: false, dice: rolled.dice } };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Why the dice in by are hidden, or undefined when shown (D-287): with their change, on a page that does not concern the player, whatever master-rolls says;
|
|
36
|
+
* behind the screen, taking away from the player character or a companion, as a foe's or a trap's do. Healing them, or dice on a copy in the scene, are shown.
|
|
37
|
+
*/
|
|
38
|
+
export function diceHiding(root, world, name, taking) {
|
|
39
|
+
const holder = holderNamed(root, world, name);
|
|
40
|
+
if (holder.kind === "copy") {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (holder.visibility === "hidden") {
|
|
44
|
+
return "secret";
|
|
45
|
+
}
|
|
46
|
+
return taking && screenUp(root) && isPartyMember(holder.page) ? "screen" : undefined;
|
|
47
|
+
}
|
|
48
|
+
/** Logs the roll of the dice in by, sealed when hidden as roll seals one; what the master is told of it when hidden. */
|
|
49
|
+
export function logDiceBy(root, context, data, hiding) {
|
|
50
|
+
const entry = newDatedLogEntry(root, context, "roll", hiding === undefined ? "public" : "hidden", data);
|
|
51
|
+
const fingerprint = hiding === undefined ? undefined : sealHiddenRoll(entry, data.result, context);
|
|
52
|
+
appendLogEntry(root, entry);
|
|
53
|
+
return fingerprint === undefined ? undefined : { id: entry.id, fingerprint, screened: hiding === "screen" };
|
|
54
|
+
}
|
|
55
|
+
/** "Rolled 2d6+3 = 11 [5, 3] + 3.", or the hidden roll as roll tells it, only for the master. */
|
|
56
|
+
export function rolledText(rolled, hidden) {
|
|
57
|
+
const screen = hidden?.screened === true ? `. ${screenNote}` : "";
|
|
58
|
+
return hidden === undefined ? `Rolled ${rolled}.` : `Hidden roll ${hidden.id}, only for the master: ${rolled}${screen}\nIts fingerprint, only if the player asks for it: ${hidden.fingerprint}`;
|
|
59
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Coin } from "../../money/index.ts";
|
|
2
|
+
import { type Page, type World } from "../../pages/index.ts";
|
|
3
|
+
import type { GameSystem } from "../../systems/index.ts";
|
|
4
|
+
import type { CounterHolder } from "./holder.ts";
|
|
5
|
+
/**
|
|
6
|
+
* The holder's field with this name, ignoring case and how accents are written; a missing or fixed one fails with the counters and money it holds and how to add one.
|
|
7
|
+
* A field the game system never counts fails with how to write it instead, with `suggested` as its new value when the change gives one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fieldName(world: World, holder: CounterHolder, fields: Record<string, unknown>, name: string, example: string, coins: Coin[] | undefined, suggested: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The fields, with a counter the game system declares and gives no maximum at 0 when a character, a quest or a copy that no page derives from does not hold it
|
|
12
|
+
* yet, as temporary hit points: change starts it, since write never changes it once written (CNT-7, CNT-8, D-266).
|
|
13
|
+
*/
|
|
14
|
+
export declare function withDeclaredStart(world: World, holder: CounterHolder, fields: Record<string, unknown>, name: string): Record<string, unknown>;
|
|
15
|
+
/** An item a name means that may be counted though no stack counts it yet, as a kind of the campaign spent to 0 everywhere: change says how to write its stack (STK-5). */
|
|
16
|
+
export declare function countable(world: World, name: string): Page | undefined;
|
|
17
|
+
/** Whether a name is a field of the page, one the game system declares or works out (CNT-8): a field before a kind of the same name (STK-5). */
|
|
18
|
+
export declare function holdsField(world: World, fields: Record<string, unknown>, name: string): boolean;
|
|
19
|
+
/** The value a change would give a number, such as 18 for by 2 on ac 16; "<value>" when it gives none. */
|
|
20
|
+
export declare function suggestedNumber(fields: Record<string, unknown>, input: {
|
|
21
|
+
field: string;
|
|
22
|
+
by?: number | string;
|
|
23
|
+
to?: number | string;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* The value a missing counter or purse is shown with, in the hint to add one: money that the page holds, when money was asked for;
|
|
27
|
+
* a clock as given, or empty (EVT-2); 0 for a field usually at zero, such as exhaustion (DAT-2); else 12/12.
|
|
28
|
+
*/
|
|
29
|
+
export declare function exampleValue(input: {
|
|
30
|
+
by?: number | string;
|
|
31
|
+
spend?: number | string;
|
|
32
|
+
to?: number | string;
|
|
33
|
+
}, coins: Coin[] | undefined, clock: boolean, zero: boolean): string;
|
|
34
|
+
/** Whether the game system declares a field a counter and works out no maximum for it, as xp: it counts up from 0. */
|
|
35
|
+
export declare function withoutMaximum(system: GameSystem | undefined, field: string): boolean;
|
|
36
|
+
/** Whether the game system's status line shows a field only when it is not at zero, as it does exhaustion: it is usually at zero (DAT-2). */
|
|
37
|
+
export declare function usuallyZero(system: GameSystem | undefined, field: string): boolean;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Finds the field a change names, or says why it can't and how to add it
|
|
2
|
+
import { fieldsRead } from "../../core/formula.js";
|
|
3
|
+
import { comparableText, valueNamed, withArticle } from "../../core/text.js";
|
|
4
|
+
import { formatCounter, readCounter, readCounterText } from "../../counters/index.js";
|
|
5
|
+
import { formatAmount, readAmount, readSignedAmount } from "../../money/index.js";
|
|
6
|
+
import { baseChain, baseFieldOf, declaredKind, followersOf, goodsNamed, isCounterField, isDeclaredUncounted, isStandardField, stackName, stacksOf, systemPageNamed } from "../../pages/index.js";
|
|
7
|
+
import { missingSystemHint } from "../shared/campaign/world.js";
|
|
8
|
+
import { hasSheet, startingAtZero } from "../shared/sheet/system-fields.js";
|
|
9
|
+
import { computedField, computedMessage, counterLimits, maximumSources } from "../shared/sheet/worked-out.js";
|
|
10
|
+
/**
|
|
11
|
+
* The holder's field with this name, ignoring case and how accents are written; a missing or fixed one fails with the counters and money it holds and how to add one.
|
|
12
|
+
* A field the game system never counts fails with how to write it instead, with `suggested` as its new value when the change gives one.
|
|
13
|
+
*/
|
|
14
|
+
export function fieldName(world, holder, fields, name, example, coins, suggested) {
|
|
15
|
+
const keys = Object.keys(fields);
|
|
16
|
+
const found = keys.find((key) => key === name) ?? keys.find((key) => comparableText(key) === comparableText(name.trim()));
|
|
17
|
+
const page = holder.page;
|
|
18
|
+
const computed = computedField(world, name, fields);
|
|
19
|
+
if (computed !== undefined) {
|
|
20
|
+
throw new Error(`${computedMessage(world, computed, page.name)}. Nothing changed.`);
|
|
21
|
+
}
|
|
22
|
+
if (found !== undefined && isStandardField(page.type, found) && !isCounterField(page.type, found)) {
|
|
23
|
+
const what = holder.kind === "copy" && found === "creature" ? `${found} is the creature ${page.name} copies` : `${found} is a fixed field of ${page.name}`;
|
|
24
|
+
throw new Error(`${what}, not a counter${holder.kind === "page" ? ": change it with write" : ""}.`);
|
|
25
|
+
}
|
|
26
|
+
const declared = found ?? name.trim();
|
|
27
|
+
if (isDeclaredUncounted(world, declared)) {
|
|
28
|
+
throw new Error(uncountedMessage(world, page.name, declared, suggested));
|
|
29
|
+
}
|
|
30
|
+
if (found !== undefined) {
|
|
31
|
+
return found;
|
|
32
|
+
}
|
|
33
|
+
const held = keys.filter((key) => (!isStandardField(page.type, key) || isCounterField(page.type, key)) && !isDeclaredUncounted(world, key)).flatMap((key) => {
|
|
34
|
+
const counter = readCounter(fields[key]);
|
|
35
|
+
const purse = coins === undefined || declaredKind(world, key) !== undefined ? undefined : readAmount(fields[key], coins);
|
|
36
|
+
return purse !== undefined && coins !== undefined ? [`${key} ${formatAmount(purse, coins)}`] : counter === undefined ? [] : [`${key} ${formatCounter(counter)}`];
|
|
37
|
+
});
|
|
38
|
+
const hasMoney = coins !== undefined && keys.some((key) => declaredKind(world, key) === undefined && readAmount(fields[key], coins) !== undefined);
|
|
39
|
+
const listed = held.length > 0 ? `Its counters${hasMoney ? " and money" : ""}: ${held.join(", ")}.` : "It has no counters.";
|
|
40
|
+
// A counter the system gives who has what it comes from is not added by hand, as a warlock's spell-slots to a wizard (DAT-9).
|
|
41
|
+
const given = Object.keys(world.system?.formulas?.counters ?? {}).find((counter) => comparableText(counter) === comparableText(name.trim()));
|
|
42
|
+
// A maximum that reads nothing, as a track of 5, is everyone's: it is written by hand as any other counter.
|
|
43
|
+
const max = given === undefined ? undefined : world.system?.formulas?.counters[given]?.max;
|
|
44
|
+
const everyones = max !== undefined && fieldsRead(max).length === 0;
|
|
45
|
+
if (given !== undefined && !everyones && holder.kind === "page" && hasSheet(world, page)) {
|
|
46
|
+
const sources = maximumSources(world, given, fields);
|
|
47
|
+
const whence = sources.length === 0 ? `the tables of its ${world.system?.progression?.list ?? "lists"}` : sources.join(", ");
|
|
48
|
+
throw new Error(`${page.name} has no ${given}: the system ${world.system?.name ?? ""} gives it from ${whence}, and ${page.name} has none from them. ${listed}`);
|
|
49
|
+
}
|
|
50
|
+
// Goods are stacks, never a field: the stacks the page holds, and the call for the kind the name means (STK-5).
|
|
51
|
+
const stacks = holder.kind === "page" ? stacksOf(world, page).map((stack) => `${stackName(stack)} ${stack.count}`) : [];
|
|
52
|
+
const goods = goodsNamed(world, name);
|
|
53
|
+
const counted = stacks.length === 0 ? "" : `Its stacks: ${stacks.join(", ")}. `;
|
|
54
|
+
// Its maximum, everyone's, in the example: the master writes it as the system works it out (FOR-7).
|
|
55
|
+
const shown = everyones && given !== undefined ? `0/${counterLimits(world, fields, given).max ?? 0}` : example;
|
|
56
|
+
const theirs = systemCountersHeld(world, fields);
|
|
57
|
+
const how = goods === undefined ? howToAdd(world, holder, name, shown, theirs) : `Goods are a stack, changed by its kind, such as change ${page.name}, ${goods.name}, spend 1.`;
|
|
58
|
+
throw new Error(`${page.name} has no field "${name}". ${counted}${listed} ${how}`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The fields, with a counter the game system declares and gives no maximum at 0 when a character, a quest or a copy that no page derives from does not hold it
|
|
62
|
+
* yet, as temporary hit points: change starts it, since write never changes it once written (CNT-7, CNT-8, D-266).
|
|
63
|
+
*/
|
|
64
|
+
export function withDeclaredStart(world, holder, fields, name) {
|
|
65
|
+
const declared = startingAtZero(world, name);
|
|
66
|
+
const held = Object.keys(fields).some((field) => comparableText(field) === comparableText(name.trim()));
|
|
67
|
+
if (declared === undefined || held || computedField(world, declared, fields) !== undefined) {
|
|
68
|
+
return fields;
|
|
69
|
+
}
|
|
70
|
+
// Never on a place, an item or a kind: on a page others derive from, it would reach all of them, as on Ghoul instead of Ghoul 1.
|
|
71
|
+
const owner = holder.kind === "copy" || ((holder.page.type === "character" || holder.page.type === "quest") && followersOf(world, holder.page, declared).length === 0);
|
|
72
|
+
return owner ? { ...fields, [declared]: 0 } : fields;
|
|
73
|
+
}
|
|
74
|
+
/** An item a name means that may be counted though no stack counts it yet, as a kind of the campaign spent to 0 everywhere: change says how to write its stack (STK-5). */
|
|
75
|
+
export function countable(world, name) {
|
|
76
|
+
const page = goodsNamed(world, name);
|
|
77
|
+
return page !== undefined && comparableText(page.name) === comparableText(name.trim()) ? page : undefined;
|
|
78
|
+
}
|
|
79
|
+
/** Whether a name is a field of the page, one the game system declares or works out (CNT-8): a field before a kind of the same name (STK-5). */
|
|
80
|
+
export function holdsField(world, fields, name) {
|
|
81
|
+
return Object.keys(fields).some((key) => comparableText(key) === comparableText(name.trim())) || declaredKind(world, name.trim()) !== undefined || computedField(world, name, fields) !== undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* How to add a counter that neither the page nor its bases hold, on the nearest base of the campaign, since the system's are read-only (SYS-6); or why its base cannot be read.
|
|
85
|
+
*/
|
|
86
|
+
function howToAdd(world, holder, name, example, theirs) {
|
|
87
|
+
// A name the system does not have is most often one of its counters by another name, as health for hp: those first, an added field after (D-518).
|
|
88
|
+
const meant = theirs.length === 0 ? "" : `If you meant a counter of the system ${world.system?.name ?? ""}, give its name, such as ${theirs.join(", ")}`;
|
|
89
|
+
const page = holder.page;
|
|
90
|
+
const field = baseFieldOf(page.type);
|
|
91
|
+
const link = field === undefined || typeof page.fields[field] !== "string" ? undefined : page.fields[field];
|
|
92
|
+
const chain = baseChain(world, page);
|
|
93
|
+
const base = chain.find((candidate) => candidate.system === undefined);
|
|
94
|
+
if (field !== undefined && link !== undefined && chain.length === 0) {
|
|
95
|
+
const fix = holder.kind === "copy" ? "fix the creature's page, or let the copy leave the scene" : "fix the link with write";
|
|
96
|
+
return `${page.name} ${holder.kind === "copy" ? "copies" : "derives from"} ${link}, which cannot be read: no ${field} has that name, two pages share it, or it is not ${withArticle(field)}. `
|
|
97
|
+
+ `To fix it, ${fix}; validate shows why.${missingSystemHint(world)}`;
|
|
98
|
+
}
|
|
99
|
+
if (base === undefined) {
|
|
100
|
+
return meant === "" ? `To add one, use write, such as set ${name}=${example}.` : `${meant}; only one it lacks is added, with write, such as set ${name}=${example}.`;
|
|
101
|
+
}
|
|
102
|
+
// A page of the campaign named like one of the system's hides it (SYS-4): writing on it is not what the master means.
|
|
103
|
+
const hides = systemPageNamed(world, base.name) === undefined ? "" : ` But ${base.name} hides the system ${world.system?.name ?? ""}'s ${base.name}: validate says how to fix it.`;
|
|
104
|
+
const first = meant === "" ? "" : `${meant}. `;
|
|
105
|
+
if (holder.kind === "copy") {
|
|
106
|
+
return `${first}To add one to ${page.name} alone, use write, such as set ${name}=${example}. To give it to every ${base.name}, write it on ${base.name} once the scene is closed.${hides}`;
|
|
107
|
+
}
|
|
108
|
+
return `${first}${page.name} reads what it does not hold from ${base.name}: write the counter there, such as set ${name}=${example}, and everything that derives from ${base.name} takes it; or on ${page.name} alone.${hides}`;
|
|
109
|
+
}
|
|
110
|
+
/** The counters the game system declares among a page's fields, at most three, in the page's order. */
|
|
111
|
+
function systemCountersHeld(world, fields) {
|
|
112
|
+
return Object.keys(fields).filter((key) => declaredKind(world, key) === "counter" && readCounter(fields[key]) !== undefined).slice(0, 3);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A field the game system never counts, such as ac: a number for a while is an effect, for good a write (SYS-8). `suggested` is the value the change would give, when it gives one.
|
|
116
|
+
*/
|
|
117
|
+
function uncountedMessage(world, page, field, suggested) {
|
|
118
|
+
const system = world.system?.name ?? "";
|
|
119
|
+
if (!["number", "at-least"].includes(declaredKind(world, field) ?? "")) {
|
|
120
|
+
const kind = declaredKind(world, field) === "text" ? "text" : declaredKind(world, field) === "list" ? "a list" : `a ${declaredKind(world, field) ?? "field"}`;
|
|
121
|
+
return `${field} is ${kind} in the system ${system}, never counted: write it instead, such as write "${page}", set ${field}=${suggested}. Nothing changed.`;
|
|
122
|
+
}
|
|
123
|
+
return `${field} is a number in the system ${system}, never counted: for a while, effect, action add, page "${page}", set ${field}=${suggested}; `
|
|
124
|
+
+ `for good, write "${page}", set ${field}=${suggested}. Nothing changed.`;
|
|
125
|
+
}
|
|
126
|
+
/** The value a change would give a number, such as 18 for by 2 on ac 16; "<value>" when it gives none. */
|
|
127
|
+
export function suggestedNumber(fields, input) {
|
|
128
|
+
const current = valueNamed(fields, input.field.trim());
|
|
129
|
+
// From a command line a number arrives as text.
|
|
130
|
+
if (input.to !== undefined && /^[+-]?\d+$/.test(String(input.to).trim())) {
|
|
131
|
+
return String(Number(input.to));
|
|
132
|
+
}
|
|
133
|
+
return typeof current === "number" && typeof input.by === "number" ? String(current + input.by) : "<value>";
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The value a missing counter or purse is shown with, in the hint to add one: money that the page holds, when money was asked for;
|
|
137
|
+
* a clock as given, or empty (EVT-2); 0 for a field usually at zero, such as exhaustion (DAT-2); else 12/12.
|
|
138
|
+
*/
|
|
139
|
+
export function exampleValue(input, coins, clock, zero) {
|
|
140
|
+
const money = coins !== undefined && [input.by, input.spend, input.to].some((part) => typeof part === "string" && readSignedAmount(part, coins) !== undefined);
|
|
141
|
+
if (money && coins !== undefined) {
|
|
142
|
+
return `10 ${coins[0].name} (what it holds, not the price)`;
|
|
143
|
+
}
|
|
144
|
+
const given = typeof input.to === "string" ? readCounterText(input.to) : undefined;
|
|
145
|
+
return clock ? (given?.max === undefined ? "0/4" : String(formatCounter(given))) : zero ? "0" : "12/12";
|
|
146
|
+
}
|
|
147
|
+
/** Whether the game system declares a field a counter and works out no maximum for it, as xp: it counts up from 0. */
|
|
148
|
+
export function withoutMaximum(system, field) {
|
|
149
|
+
const counted = Object.entries(system?.fields ?? {}).some(([name, kind]) => kind === "counter" && comparableText(name) === comparableText(field));
|
|
150
|
+
const limits = Object.entries(system?.formulas.counters ?? {}).find(([name]) => comparableText(name) === comparableText(field))?.[1];
|
|
151
|
+
return counted && limits?.max === undefined;
|
|
152
|
+
}
|
|
153
|
+
/** Whether the game system's status line shows a field only when it is not at zero, as it does exhaustion: it is usually at zero (DAT-2). */
|
|
154
|
+
export function usuallyZero(system, field) {
|
|
155
|
+
return system?.statusLine.some((entry) => entry.whenSet && comparableText(entry.field) === comparableText(field.trim())) === true;
|
|
156
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
2
|
+
import { type LogEntry } from "../../core/log.ts";
|
|
3
|
+
import { type Page, type World } from "../../pages/index.ts";
|
|
4
|
+
import type { GameSystem } from "../../systems/index.ts";
|
|
5
|
+
import { fireEvents } from "../shared/time/events.ts";
|
|
6
|
+
import type { Step } from "./amounts.ts";
|
|
7
|
+
/** What holds a counter: a page, or a copy in the open scene, seen as a page that derives from its creature (INH-14). */
|
|
8
|
+
export interface CounterHolder {
|
|
9
|
+
page: Page;
|
|
10
|
+
kind: "page" | "copy";
|
|
11
|
+
/** Writes fields as the page names them, undefined removing one so that the page reads it from its base again (INH-9): the page as written, undefined for a copy. */
|
|
12
|
+
write(fields: Record<string, number | string | undefined>): Page | undefined;
|
|
13
|
+
visibility: LogEntry["visibility"];
|
|
14
|
+
}
|
|
15
|
+
/** What a step did to a counter or to money. */
|
|
16
|
+
export interface StepOutcome {
|
|
17
|
+
page: string;
|
|
18
|
+
field: string;
|
|
19
|
+
before: string;
|
|
20
|
+
after: string;
|
|
21
|
+
total?: string;
|
|
22
|
+
/** "in Forma d'orso; at max; again as Lupo": the effect it changed on, the limit it reached, the base whose value the page reads again. */
|
|
23
|
+
note: string;
|
|
24
|
+
effect?: string;
|
|
25
|
+
again?: string;
|
|
26
|
+
changed: boolean;
|
|
27
|
+
due: ReturnType<typeof fireEvents>["due"];
|
|
28
|
+
followers: string[];
|
|
29
|
+
keepers: string[];
|
|
30
|
+
thresholds: string[];
|
|
31
|
+
/** What the change may break that someone keeps alive, and what shields the counter it lowered (EFF-14, DAT-14). */
|
|
32
|
+
reminders: string[];
|
|
33
|
+
}
|
|
34
|
+
/** What holds the counter, given by name or as a link: a copy in the open scene first, then a page of the campaign; the field asked names the example. */
|
|
35
|
+
export declare function holderNamed(root: string, world: World, name: string, field?: string): CounterHolder;
|
|
36
|
+
/** A page as what holds its counters: written with write, its lines in the log public when it concerns the player. */
|
|
37
|
+
export declare function pageHolder(world: World, page: Page): CounterHolder;
|
|
38
|
+
/**
|
|
39
|
+
* Writes a step: on the effect that gives the field (EFF-7), else on the page, from which the field goes when it comes back to its base's value (INH-9); with
|
|
40
|
+
* its line in the log and those of the pages that read it from this one (INH-10), the events it sets off (EVT-4) and the thresholds it touches (DAT-3).
|
|
41
|
+
* Returns the world as written, for a next step.
|
|
42
|
+
*/
|
|
43
|
+
export declare function applyStep(root: string, context: Context, world: World, holder: CounterHolder, field: string, step: Step, why: string | undefined, system: GameSystem | undefined): {
|
|
44
|
+
outcome: StepOutcome;
|
|
45
|
+
world: World;
|
|
46
|
+
};
|
|
47
|
+
/** What else a step says: the thresholds it touches, the events it sets off, the pages that changed with it, and those that keep their own. */
|
|
48
|
+
export declare function stepNotes(step: StepOutcome): string[];
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { appendLogEntry } from "../../core/log.js";
|
|
2
|
+
import { comparableText } from "../../core/text.js";
|
|
3
|
+
import { formatCounter, readCounter, readCounterText } from "../../counters/index.js";
|
|
4
|
+
import { baseValue, concernsPlayer, followersOf, inheritedFields, isCounterField, isPartyMember, isPlayerCharacter, keepersOf, ownField, withPage, writePage } from "../../pages/index.js";
|
|
5
|
+
import { situationPart } from "../shared/campaign/parts.js";
|
|
6
|
+
import { followersNote, keepersNote } from "../shared/notes.js";
|
|
7
|
+
import { saveEffects } from "../shared/scene/effects.js";
|
|
8
|
+
import { keepingLossNote, shieldNotes } from "../shared/scene/reminders.js";
|
|
9
|
+
import { checkNotCopied, checkNotSystemPage, pageOrCopy, readOpenScene, updateScene } from "../shared/scene/scene.js";
|
|
10
|
+
import { effectGiving, effectiveFields, effectsOf, withValue } from "../shared/sheet/effect-layer.js";
|
|
11
|
+
import { experienceOf, levelWay, newLevelNotes, settleChoices } from "../shared/sheet/experience.js";
|
|
12
|
+
import { fallNotes, thresholdNotes } from "../shared/sheet/thresholds.js";
|
|
13
|
+
import { counterLimits } from "../shared/sheet/worked-out.js";
|
|
14
|
+
import { fireEvents, nowDueNote } from "../shared/time/events.js";
|
|
15
|
+
import { newDatedLogEntry, readPresent } from "../shared/time/time.js";
|
|
16
|
+
/** What holds the counter, given by name or as a link: a copy in the open scene first, then a page of the campaign; the field asked names the example. */
|
|
17
|
+
export function holderNamed(root, world, name, field) {
|
|
18
|
+
const open = readOpenScene(root);
|
|
19
|
+
const found = pageOrCopy(world, open, name, (page) => `a counter is a field of the page, such as page ${page}${field === undefined ? "" : `, field ${field}`}`);
|
|
20
|
+
const copy = found.copy;
|
|
21
|
+
if (copy !== undefined) {
|
|
22
|
+
const write = (fields) => {
|
|
23
|
+
updateScene(root, Object.entries(fields).map(([field, value]) => [["copies", copy, field], value]));
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
return { page: found.page, kind: "copy", write, visibility: "hidden" };
|
|
27
|
+
}
|
|
28
|
+
checkNotSystemPage(world, open, found.page);
|
|
29
|
+
checkNotCopied(world, open, found.page);
|
|
30
|
+
return pageHolder(world, found.page);
|
|
31
|
+
}
|
|
32
|
+
/** A page as what holds its counters: written with write, its lines in the log public when it concerns the player. */
|
|
33
|
+
export function pageHolder(world, page) {
|
|
34
|
+
return {
|
|
35
|
+
page,
|
|
36
|
+
kind: "page",
|
|
37
|
+
write: (fields) => {
|
|
38
|
+
const set = Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
39
|
+
const unset = Object.keys(fields).filter((field) => fields[field] === undefined);
|
|
40
|
+
return writePage(world, page.name, undefined, { set: Object.keys(set).length === 0 ? undefined : set, unset: unset.length === 0 ? undefined : unset }).page;
|
|
41
|
+
},
|
|
42
|
+
visibility: concernsPlayer(world, page) ? "public" : "hidden",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Writes a step: on the effect that gives the field (EFF-7), else on the page, from which the field goes when it comes back to its base's value (INH-9); with
|
|
47
|
+
* its line in the log and those of the pages that read it from this one (INH-10), the events it sets off (EVT-4) and the thresholds it touches (DAT-3).
|
|
48
|
+
* Returns the world as written, for a next step.
|
|
49
|
+
*/
|
|
50
|
+
export function applyStep(root, context, world, holder, field, step, why, system) {
|
|
51
|
+
const page = holder.page.name;
|
|
52
|
+
checkClock(holder.page, field, step.after);
|
|
53
|
+
const written = ownField(holder.page, field) ?? field;
|
|
54
|
+
// A value an effect gives changes on the effect, under which the page keeps its own (EFF-7).
|
|
55
|
+
const layer = effectGiving(holder.page, field);
|
|
56
|
+
// A maximum written by hand that is not the system's is put right even when the value reads the same, as validate's fix asks (FOR-6).
|
|
57
|
+
const workedMax = holder.kind === "page" && counterLimits(world, inheritedFields(world, holder.page), field).max !== undefined;
|
|
58
|
+
const stale = layer === undefined && workedMax && Object.hasOwn(holder.page.fields, written) && String(holder.page.fields[written]) !== String(storedCounter(world, holder, field, step.after));
|
|
59
|
+
const changed = String(step.after) !== String(step.before) || stale;
|
|
60
|
+
const base = layer === undefined ? baseValue(world, holder.page, field) : undefined;
|
|
61
|
+
const backToBase = changed && base !== undefined && step.same(base.value);
|
|
62
|
+
const followers = changed && holder.kind === "page" && layer === undefined ? followersOf(world, holder.page, field) : [];
|
|
63
|
+
const keepers = changed && holder.kind === "page" && layer === undefined ? keepersOf(world, holder.page, field).map((keeper) => `${keeper.name} (${field} ${String(counterOf(world, keeper, field))})`) : [];
|
|
64
|
+
let after;
|
|
65
|
+
if (changed) {
|
|
66
|
+
// Back to the base's value, the field goes in every spelling the page wrote it, so that the page reads the base's (INH-5, INH-9).
|
|
67
|
+
const spellings = Object.keys(holder.page.fields).filter((name) => comparableText(name) === comparableText(field));
|
|
68
|
+
if (layer === undefined) {
|
|
69
|
+
after = holder.write(backToBase ? Object.fromEntries(spellings.map((name) => [name, undefined])) : { [written]: storedCounter(world, holder, field, step.after) });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const effects = effectsOf(holder.page).map((effect) => (effect.name === layer.name ? withValue(effect, field, String(step.after)) : effect));
|
|
73
|
+
after = saveEffects(root, context, world, { page: holder.page, copy: holder.kind === "copy" }, effects);
|
|
74
|
+
}
|
|
75
|
+
const data = { page, copy: holder.kind === "copy" ? true : undefined, field, effect: layer?.name, before: step.before, after: step.after, ...step.amount, why };
|
|
76
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "counter-changed", holder.visibility, data));
|
|
77
|
+
logFollowers(root, world, context, followers, { field, before: step.before, after: step.after });
|
|
78
|
+
}
|
|
79
|
+
const again = backToBase ? base?.base.name : undefined;
|
|
80
|
+
const note = [layer === undefined ? "" : `in ${layer.name}`, step.note, again === undefined ? "" : `again as ${again}`].filter((part) => part !== "").join("; ");
|
|
81
|
+
const updated = after === undefined ? world : withPage(world, holder.page, after);
|
|
82
|
+
// Only an event's clock sets anything off when it changes (EVT-4).
|
|
83
|
+
const due = after !== undefined && layer === undefined && isCounterField(after.type, field) ? fireEvents(root, context, world, updated, readPresent(root).date).due : [];
|
|
84
|
+
// The rules a counter of the player character or a companion touches (DAT-3): never for a copy, nor for a page that is not in the party.
|
|
85
|
+
const touched = changed || (step.amount.beyond ?? 0) !== 0;
|
|
86
|
+
const party = holder.kind === "page" && isPartyMember(holder.page);
|
|
87
|
+
// Points that reach a new level are said with the rule to read (PRO-6).
|
|
88
|
+
const companion = holder.page.fields.role === "companion";
|
|
89
|
+
const levelUp = () => situationPart("level-up", context, system);
|
|
90
|
+
const [levelBefore, levelAfter] = [experienceOf(world, effectiveFields(world, holder.page)), after === undefined ? undefined : experienceOf(updated, effectiveFields(updated, after))];
|
|
91
|
+
if (changed && party) {
|
|
92
|
+
settleChoices(root, holder.page.name, levelBefore, levelAfter);
|
|
93
|
+
}
|
|
94
|
+
const levels = changed && party && after !== undefined ? newLevelNotes(page, levelBefore, levelAfter, companion, levelUp, levelWay(root, context, holder.page.name)) : [];
|
|
95
|
+
// The player character's own counter, never a form's, falling to the system's down value: what lethality makes of it (D-530).
|
|
96
|
+
const fall = changed && holder.kind === "page" && layer === undefined && isPlayerCharacter(holder.page) ? fallNotes(root, system, page, field, step) : [];
|
|
97
|
+
const thresholds = [...(touched && party ? thresholdNotes(root, system, field, step, layer?.name) : []), ...fall, ...levels];
|
|
98
|
+
// What the loss may break that someone keeps alive, on anyone, and what shields the counter that went down (EFF-14, DAT-14).
|
|
99
|
+
const lost = touched ? lostBy(step) : 0;
|
|
100
|
+
// What goes past 0 in an effect that gives the counter, as a beast form, may carry over to the page's own (D-454).
|
|
101
|
+
const beyond = Math.abs(Number(step.amount.beyond ?? 0));
|
|
102
|
+
const carried = layer !== undefined && lost > 0 && beyond > 0 && readCounterText(String(step.after))?.value === 0
|
|
103
|
+
? `${beyond} went past 0 in ${layer.name}: when it ends so, what goes past may carry over to ${page}'s own ${field}, as its text says.`
|
|
104
|
+
: "";
|
|
105
|
+
const reminders = [keepingLossNote(world, readOpenScene(root).scene, system, page, field, lost), ...shieldNotes(world, system, holder.page, field, lost, fellBy(step)), carried].filter((note) => note !== "");
|
|
106
|
+
const outcome = {
|
|
107
|
+
page,
|
|
108
|
+
field,
|
|
109
|
+
before: String(step.before),
|
|
110
|
+
after: String(step.after),
|
|
111
|
+
total: step.total,
|
|
112
|
+
note,
|
|
113
|
+
effect: layer?.name,
|
|
114
|
+
again,
|
|
115
|
+
changed,
|
|
116
|
+
due,
|
|
117
|
+
followers: followers.map((follower) => follower.name),
|
|
118
|
+
keepers,
|
|
119
|
+
thresholds,
|
|
120
|
+
reminders,
|
|
121
|
+
};
|
|
122
|
+
return { outcome, world: updated };
|
|
123
|
+
}
|
|
124
|
+
/** A counter as the page keeps it: with the maximum the game system works out from the page without its effects, which the reading puts back (FOR-6). */
|
|
125
|
+
function storedCounter(world, holder, field, value) {
|
|
126
|
+
const counter = readCounter(value);
|
|
127
|
+
const { max } = holder.kind === "page" ? counterLimits(world, inheritedFields(world, holder.page), field) : {};
|
|
128
|
+
return counter === undefined || max === undefined ? value : formatCounter({ value: counter.value, max });
|
|
129
|
+
}
|
|
130
|
+
/** An event's clock keeps a maximum of at least 1, as write asks (EVT-2). */
|
|
131
|
+
function checkClock(page, field, after) {
|
|
132
|
+
const counter = readCounter(after);
|
|
133
|
+
if (isCounterField(page.type, field) && (counter?.max === undefined || counter.max < 1)) {
|
|
134
|
+
throw new Error(`A clock needs a maximum of at least 1, such as 0/4: ${after} is not one. Nothing changed.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** How much a step took away: the whole of a negative by, even past a limit, as damage is taken; otherwise what the value went down. */
|
|
138
|
+
function lostBy(step) {
|
|
139
|
+
const by = step.amount.by;
|
|
140
|
+
return typeof by === "number" ? Math.max(0, -by) : fellBy(step);
|
|
141
|
+
}
|
|
142
|
+
/** How far a step's counter went down, which stops at its least. */
|
|
143
|
+
function fellBy(step) {
|
|
144
|
+
const before = readCounter(step.before)?.value;
|
|
145
|
+
const after = readCounter(step.after)?.value;
|
|
146
|
+
return before === undefined || after === undefined ? 0 : Math.max(0, before - after);
|
|
147
|
+
}
|
|
148
|
+
/** One public line for each page that changed with a base and concerns the player, with its own name only and no why: the base and the other pages may be secret (INH-10, D-93). */
|
|
149
|
+
function logFollowers(root, world, context, followers, change) {
|
|
150
|
+
for (const follower of followers.filter((page) => concernsPlayer(world, page))) {
|
|
151
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "counter-changed", "public", { page: follower.name, ...change }));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** The value a page reads for a field, written in any case. */
|
|
155
|
+
function counterOf(world, page, field) {
|
|
156
|
+
return Object.entries(inheritedFields(world, page)).find(([name]) => comparableText(name) === comparableText(field))?.[1];
|
|
157
|
+
}
|
|
158
|
+
/** What else a step says: the thresholds it touches, the events it sets off, the pages that changed with it, and those that keep their own. */
|
|
159
|
+
export function stepNotes(step) {
|
|
160
|
+
const followers = followersNote(step.followers, `since they read ${step.field} from ${step.page}`, "change", `${step.field} ${step.after}`);
|
|
161
|
+
return [...step.thresholds, ...step.reminders, nowDueNote(step.due), followers, keepersNote(step.keepers, step.field)].filter((note) => note !== "");
|
|
162
|
+
}
|