@datasworn-community/build-tools 0.2.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.
Files changed (134) hide show
  1. package/README.md +17 -0
  2. package/dist/cli/args.d.ts +3 -0
  3. package/dist/cli/args.d.ts.map +1 -0
  4. package/dist/cli/args.js +10 -0
  5. package/dist/cli/args.js.map +1 -0
  6. package/dist/cli/datasworn-build.d.ts +3 -0
  7. package/dist/cli/datasworn-build.d.ts.map +1 -0
  8. package/dist/cli/datasworn-build.js +33 -0
  9. package/dist/cli/datasworn-build.js.map +1 -0
  10. package/dist/cli/datasworn-migrate.d.ts +3 -0
  11. package/dist/cli/datasworn-migrate.d.ts.map +1 -0
  12. package/dist/cli/datasworn-migrate.js +26 -0
  13. package/dist/cli/datasworn-migrate.js.map +1 -0
  14. package/dist/config.d.ts +3 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/config.js +10 -0
  17. package/dist/config.js.map +1 -0
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +4 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/rules-package-builder.d.ts +22 -0
  23. package/dist/rules-package-builder.d.ts.map +1 -0
  24. package/dist/rules-package-builder.js +84 -0
  25. package/dist/rules-package-builder.js.map +1 -0
  26. package/dist/schema.d.ts +8 -0
  27. package/dist/schema.d.ts.map +1 -0
  28. package/dist/schema.js +18 -0
  29. package/dist/schema.js.map +1 -0
  30. package/dist/validators.d.ts +8 -0
  31. package/dist/validators.d.ts.map +1 -0
  32. package/dist/validators.js +35 -0
  33. package/dist/validators.js.map +1 -0
  34. package/package.json +60 -0
  35. package/schema-source/schema/Assets.ts +66 -0
  36. package/schema-source/schema/Atlas.ts +20 -0
  37. package/schema-source/schema/Defs.ts +126 -0
  38. package/schema-source/schema/DelveSites.ts +3 -0
  39. package/schema-source/schema/Entities.ts +1 -0
  40. package/schema-source/schema/Generic.ts +18 -0
  41. package/schema-source/schema/Moves.ts +1 -0
  42. package/schema-source/schema/Npcs.ts +80 -0
  43. package/schema-source/schema/Oracles.ts +20 -0
  44. package/schema-source/schema/Rarities.ts +36 -0
  45. package/schema-source/schema/Root.ts +94 -0
  46. package/schema-source/schema/Rules.ts +61 -0
  47. package/schema-source/schema/RulesPackages.ts +135 -0
  48. package/schema-source/schema/Symbols.ts +30 -0
  49. package/schema-source/schema/Truths.ts +53 -0
  50. package/schema-source/schema/Utils.ts +21 -0
  51. package/schema-source/schema/assets/Ability.ts +79 -0
  52. package/schema-source/schema/assets/Enhancement.ts +62 -0
  53. package/schema-source/schema/assets/Fields.ts +285 -0
  54. package/schema-source/schema/assets/common.ts +29 -0
  55. package/schema-source/schema/common/Fields.ts +327 -0
  56. package/schema-source/schema/common/Id.ts +64 -0
  57. package/schema-source/schema/common/Inputs.ts +374 -0
  58. package/schema-source/schema/common/Metadata.ts +142 -0
  59. package/schema-source/schema/common/Player.ts +17 -0
  60. package/schema-source/schema/common/Progress.ts +63 -0
  61. package/schema-source/schema/common/Range.ts +53 -0
  62. package/schema-source/schema/common/RollableValues.ts +152 -0
  63. package/schema-source/schema/common/Rolls.ts +108 -0
  64. package/schema-source/schema/common/Text.ts +95 -0
  65. package/schema-source/schema/common/index.ts +16 -0
  66. package/schema-source/schema/delve/DelveSite.ts +121 -0
  67. package/schema-source/schema/delve/DelveSiteDomain.ts +136 -0
  68. package/schema-source/schema/delve/DelveSiteTheme.ts +97 -0
  69. package/schema-source/schema/delve/common.ts +32 -0
  70. package/schema-source/schema/entities/EntityPrompt.ts +13 -0
  71. package/schema-source/schema/entities/index.ts +1 -0
  72. package/schema-source/schema/generic/CollectableNode.ts +75 -0
  73. package/schema-source/schema/generic/CollectionNode.ts +145 -0
  74. package/schema-source/schema/generic/Dictionary.ts +39 -0
  75. package/schema-source/schema/generic/EmbedOnlyNode.ts +19 -0
  76. package/schema-source/schema/generic/Enhance.ts +38 -0
  77. package/schema-source/schema/generic/IdNode.ts +40 -0
  78. package/schema-source/schema/generic/Mixin.ts +11 -0
  79. package/schema-source/schema/generic/NonCollectableNode.ts +38 -0
  80. package/schema-source/schema/generic/PrimaryTypeNode.ts +115 -0
  81. package/schema-source/schema/generic/SourcedNode.ts +51 -0
  82. package/schema-source/schema/index.ts +23 -0
  83. package/schema-source/schema/moves/ActionRoll.ts +152 -0
  84. package/schema-source/schema/moves/EmbeddedMove.ts +24 -0
  85. package/schema-source/schema/moves/Move.ts +26 -0
  86. package/schema-source/schema/moves/MoveCategory.ts +6 -0
  87. package/schema-source/schema/moves/MoveEnhancement.ts +29 -0
  88. package/schema-source/schema/moves/ProgressRoll.ts +184 -0
  89. package/schema-source/schema/moves/Trigger.ts +193 -0
  90. package/schema-source/schema/moves/common.ts +136 -0
  91. package/schema-source/schema/moves/index.ts +13 -0
  92. package/schema-source/schema/moves/utils.ts +132 -0
  93. package/schema-source/schema/object_type/ObjectType.ts +23 -0
  94. package/schema-source/schema/oracles/EmbeddedOracleRollable.ts +28 -0
  95. package/schema-source/schema/oracles/OracleCollection.ts +140 -0
  96. package/schema-source/schema/oracles/OracleRollable.ts +207 -0
  97. package/schema-source/schema/oracles/Table.ts +94 -0
  98. package/schema-source/schema/oracles/TableRow.ts +141 -0
  99. package/schema-source/schema/root/NiceSchema.ts +15 -0
  100. package/schema-source/schema/root/Root.ts +41 -0
  101. package/schema-source/schema/root/SchemaTransform.ts +89 -0
  102. package/schema-source/schema/root/SourceData.ts +151 -0
  103. package/schema-source/schema/rules/ConditionMeterRule.ts +25 -0
  104. package/schema-source/schema/rules/ImpactRule.ts +54 -0
  105. package/schema-source/schema/rules/SpecialTrackRule.ts +29 -0
  106. package/schema-source/schema/rules/StatRule.ts +23 -0
  107. package/schema-source/schema/rules/TagRule.ts +176 -0
  108. package/schema-source/schema/rules/TagSchema.ts +161 -0
  109. package/schema-source/schema/tags/canonicalTags.ts +29 -0
  110. package/schema-source/schema/tools/build/index.ts +48 -0
  111. package/schema-source/schema/tools/i18n/index.ts +9 -0
  112. package/schema-source/schema/utils/Computed.ts +82 -0
  113. package/schema-source/schema/utils/DiscriminatedUnion.ts +255 -0
  114. package/schema-source/schema/utils/EmbeddedNode.ts +172 -0
  115. package/schema-source/schema/utils/ExtractLiteralFromEnum.ts +22 -0
  116. package/schema-source/schema/utils/FlatIntersect.ts +107 -0
  117. package/schema-source/schema/utils/IfThen.ts +50 -0
  118. package/schema-source/schema/utils/MergeEnumSchemas.ts +16 -0
  119. package/schema-source/schema/utils/NonNullable.ts +6 -0
  120. package/schema-source/schema/utils/Nullable.ts +29 -0
  121. package/schema-source/schema/utils/ObjectLiteral.ts +16 -0
  122. package/schema-source/schema/utils/ObjectProperties.ts +4 -0
  123. package/schema-source/schema/utils/OmitMeta.ts +22 -0
  124. package/schema-source/schema/utils/OmitOptional.ts +27 -0
  125. package/schema-source/schema/utils/PartialExcept.ts +26 -0
  126. package/schema-source/schema/utils/SetNullable.ts +44 -0
  127. package/schema-source/schema/utils/SetOptional.ts +48 -0
  128. package/schema-source/schema/utils/UnionEnum.ts +82 -0
  129. package/schema-source/schema/utils/UnionEnumFromRecord.ts +36 -0
  130. package/schema-source/schema/utils/UnionOneOf.ts +80 -0
  131. package/schema-source/schema/utils/generateRulesetSchemas.ts +204 -0
  132. package/schema-source/schema/utils/string.ts +15 -0
  133. package/schema-source/schema/utils/typebox.ts +141 -0
  134. package/schema-source/scripts/const.ts +55 -0
@@ -0,0 +1,152 @@
1
+ import {
2
+ type ObjectOptions,
3
+ type Static,
4
+ type TObject,
5
+ Type
6
+ } from '@sinclair/typebox'
7
+ import * as Utils from '../Utils.js'
8
+ import { Assign } from '../utils/FlatIntersect.js'
9
+ import Id from './Id.js'
10
+ import * as Player from './Player.js'
11
+ import * as Text from './Text.js'
12
+
13
+ const RollableValueType = Utils.UnionEnumFromRecord(
14
+ {
15
+ stat: 'A reference to the value of a standard player character stat.',
16
+ condition_meter:
17
+ 'A reference to the value of a standard player condition meter.',
18
+ asset_control: 'A reference to the value of an asset control.',
19
+ asset_option: 'A reference to the value of an asset option.',
20
+ custom: 'An arbitrary static integer value with a label.',
21
+ attached_asset_control:
22
+ 'A reference to the value of an attached asset control. For example, a Module asset could use this to roll using the `integrity` control of an attached Vehicle.',
23
+ attached_asset_option:
24
+ 'A reference to the value of an attached asset option.'
25
+ },
26
+ { $id: 'RollableValueType' }
27
+ )
28
+ type RollableValueType = Static<typeof RollableValueType>
29
+
30
+ function RollableValueBase<
31
+ Using extends RollableValueType,
32
+ Props extends TObject
33
+ >(using: Using, props: Props, options: ObjectOptions = {}) {
34
+ const constant = Utils.ExtractLiteralFromEnum(RollableValueType, using)
35
+ return Assign(
36
+ props,
37
+ Type.Object({
38
+ using: constant
39
+ }),
40
+ {
41
+ description: constant.description,
42
+ ...options
43
+ }
44
+ )
45
+ }
46
+
47
+ export const AssetControlValueRef = RollableValueBase(
48
+ 'asset_control',
49
+ Type.Object({
50
+ assets: Utils.Nullable(
51
+ Type.Array(Type.Ref(Id.AssetIdWildcard), { default: null }),
52
+ {
53
+ default: null,
54
+ description:
55
+ "Asset IDs (which may be wildcarded) that may provide the control field. For asset ability enhancements, `null` is used to represent the asset's own control fields."
56
+ }
57
+ ),
58
+ control: Type.Ref(Id.DictKey, {
59
+ description: 'The dictionary key of the asset control field.',
60
+ examples: ['health', 'integrity']
61
+ })
62
+ }),
63
+ { $id: 'AssetControlValueRef' }
64
+ )
65
+
66
+ export type AssetControlValueRef = Static<typeof AssetControlValueRef>
67
+
68
+ export const AttachedAssetControlValueRef = RollableValueBase(
69
+ 'attached_asset_control',
70
+ Type.Pick(AssetControlValueRef, ['control']),
71
+ { $id: 'AttachedAssetControlValueRef' }
72
+ )
73
+
74
+ export type AttachedAssetControlValueRef = Static<
75
+ typeof AttachedAssetControlValueRef
76
+ >
77
+
78
+ export const AssetOptionValueRef = RollableValueBase(
79
+ 'asset_option',
80
+ Type.Object({
81
+ assets: Utils.Nullable(Type.Array(Type.Ref(Id.AssetIdWildcard)), {
82
+ default: null,
83
+ description:
84
+ "Asset IDs (which may be wildcarded) that may provide the option field. For asset ability enhancements, `null` is used to represent the asset's own option fields."
85
+ }),
86
+ option: Type.Ref(Id.DictKey, {
87
+ description: 'The dictionary key of the asset option field.'
88
+ })
89
+ }),
90
+ { $id: 'AssetOptionValueRef' }
91
+ )
92
+
93
+ export type AssetOptionValueRef = Static<typeof AssetOptionValueRef>
94
+
95
+ export const AttachedAssetOptionValueRef = RollableValueBase(
96
+ 'attached_asset_option',
97
+ Type.Pick(AssetOptionValueRef, ['option']),
98
+ { $id: 'AttachedAssetOptionValueRef' }
99
+ )
100
+
101
+ export type AttachedAssetOptionValueRef = Static<
102
+ typeof AttachedAssetOptionValueRef
103
+ >
104
+
105
+ export const StatValueRef = RollableValueBase(
106
+ 'stat',
107
+ Type.Object({
108
+ stat: Type.Ref(Player.StatKey)
109
+ }),
110
+ { $id: 'StatValueRef' }
111
+ )
112
+
113
+ export type StatValueRef = Static<typeof StatValueRef>
114
+
115
+ export const ConditionMeterValueRef = RollableValueBase(
116
+ 'condition_meter',
117
+ Type.Object({
118
+ condition_meter: Type.Ref(Player.ConditionMeterKey)
119
+ }),
120
+ { $id: 'ConditionMeterValueRef' }
121
+ )
122
+ export type ConditionMeterValueRef = Static<typeof ConditionMeterValueRef>
123
+
124
+ export const CustomValue = RollableValueBase(
125
+ 'custom',
126
+ Type.Object({
127
+ label: Type.Ref(Text.Label),
128
+ value: Type.Integer()
129
+ }),
130
+ { $id: 'CustomValue' }
131
+ )
132
+ export type CustomValue = Static<typeof CustomValue>
133
+
134
+ export const RollableValue = Utils.DiscriminatedUnion(
135
+ {
136
+ stat: StatValueRef,
137
+ condition_meter: ConditionMeterValueRef,
138
+ asset_control: AssetControlValueRef,
139
+ asset_option: AssetOptionValueRef,
140
+ attached_asset_control: AttachedAssetControlValueRef,
141
+ attached_asset_option: AttachedAssetOptionValueRef,
142
+ custom: CustomValue
143
+ },
144
+ 'using',
145
+ {
146
+ $id: 'RollableValue',
147
+ description:
148
+ 'Provides a value like a stat, condition meter, or other number (usually for use in an action roll). The expected value is an integer, or null.'
149
+ }
150
+ )
151
+
152
+ export type RollableValue = Static<typeof RollableValue>
@@ -0,0 +1,108 @@
1
+ import { type Static, type TString, Type } from '@sinclair/typebox'
2
+ import * as Utils from '../Utils.js'
3
+ import Id from './Id.js'
4
+ import * as Text from './Text.js'
5
+
6
+ export const DiceExpression = Type.String({
7
+ pattern: /([1-9][0-9]*)d([1-9][0-9]*)([+-]([1-9][0-9]*))?/.source,
8
+ $id: 'DiceExpression',
9
+ description:
10
+ 'A simple dice roll expression with an optional (positive or negative) modifer.',
11
+ examples: ['1d100', '1d6+2', '2d10']
12
+ }) as TString & { pattern: string; static: DiceExpression }
13
+
14
+ export type DiceExpression =
15
+ | `${number}d${number}`
16
+ | `${number}d${number}${'+' | '-'}${number}`
17
+
18
+ export const OracleDuplicateBehavior = Utils.UnionEnumFromRecord(
19
+ {
20
+ reroll: 'Duplicate results should be re-rolled.',
21
+ keep: 'Duplicates results should be kept.',
22
+ make_it_worse:
23
+ 'Duplicate results should be kept, and they compound to make things worse.'
24
+ },
25
+ {
26
+ $id: 'OracleDuplicateBehavior',
27
+ description:
28
+ 'Special roll instructions to use when rolling multiple times on a single oracle.'
29
+ }
30
+ )
31
+ export type OracleDuplicateBehavior = Static<typeof OracleDuplicateBehavior>
32
+
33
+ export const OracleRoll = Type.Object(
34
+ {
35
+ oracle: Utils.Nullable(Type.Ref(Id.OracleRollableId), {
36
+ default: null,
37
+ description:
38
+ "The ID of the oracle to be rolled. A `null` value indicates that it's a roll on the same table."
39
+ }),
40
+ auto: Type.Boolean({
41
+ default: false,
42
+ description:
43
+ 'Both Ironsworn and Starforged explicitly recommend *against* rolling all details at once. That said, some oracle results only provide useful information once a secondary roll occurs, such as "Action + Theme" or "Roll twice".'
44
+ }),
45
+ duplicates: Type.Ref(OracleDuplicateBehavior, {
46
+ description:
47
+ 'Special rules on how to handle duplicate results, when rolling multiple times.',
48
+ default: 'reroll'
49
+ }),
50
+ dice: Utils.Nullable(Type.Ref(DiceExpression), {
51
+ default: null,
52
+ description:
53
+ "The dice roll to make on the oracle table. Set it to `null` if you just want the table's default."
54
+ }),
55
+ // TODO: replace with the recommended_rolls?
56
+ number_of_rolls: Type.Integer({
57
+ minimum: 1,
58
+ default: 1,
59
+ description: 'The number of times to roll.'
60
+ })
61
+ // TODO: some way to handle e.g. 1d6 rolls?
62
+ },
63
+ { $id: 'OracleRoll' }
64
+ )
65
+ export type OracleRoll = Static<typeof OracleRoll>
66
+ export type TOracleRoll = typeof OracleRoll
67
+
68
+ export const OracleRollTemplate = Type.Object(
69
+ {
70
+ text: Type.Optional(
71
+ Type.Ref(Text.MarkdownTemplateString, {
72
+ description:
73
+ 'A string template that may be used in place of OracleRollableRow#text.',
74
+ examples: [
75
+ '{{text>oracle_rollable:starforged/faction/name/affiliation}} of the {{text>oracle_rollable:starforged/faction/name/legacy}} {{text>oracle_rollable:starforged/faction/name/identity}}'
76
+ ]
77
+ })
78
+ ),
79
+ text2: Type.Optional(
80
+ Type.Ref(Text.MarkdownTemplateString, {
81
+ description:
82
+ 'A string template that may be used in place of OracleRollableRow#text2.'
83
+ })
84
+ ),
85
+ text3: Type.Optional(
86
+ Type.Ref(Text.MarkdownTemplateString, {
87
+ description:
88
+ 'A string template that may be used in place of OracleRollableRow#text3.'
89
+ })
90
+ )
91
+ },
92
+ {
93
+ $id: 'OracleRollTemplate',
94
+ releaseStage: 'experimental',
95
+ description: `Provides string templates that may be used in place of the static row text from \`OracleRollableRow#text\`, \`OracleRollableRow#text2\`, and \`OracleRollableRow#text3\`.
96
+
97
+ These strings are formatted in Markdown, but use a special syntax for their placeholders: \`{{text>some_oracle_rollable_id}}\`. The placeholder should be replaced with the value of a rolled (or selected) \`OracleRollableRow#text\` from the target oracle rollable ID.`
98
+ }
99
+ )
100
+ export type OracleRollTemplate = Static<typeof OracleRollTemplate>
101
+
102
+ export const OracleMatchBehavior = Type.Object(
103
+ {
104
+ text: Type.Ref(Text.MarkdownString)
105
+ },
106
+ { $id: 'OracleMatchBehavior' }
107
+ )
108
+ export type OracleMatchBehavior = Static<typeof OracleMatchBehavior>
@@ -0,0 +1,95 @@
1
+ import { type Static, Type } from '@sinclair/typebox'
2
+ import { UnionEnumFromRecord } from '../utils/UnionEnumFromRecord.js'
3
+
4
+ export const Documentation = Type.String({
5
+ $id: 'Documentation',
6
+ description:
7
+ 'Implementation hints or other developer-facing comments on this node. These should be omitted when representing an object for gameplay.'
8
+ })
9
+
10
+ export const Label = Type.String({
11
+ $id: 'Label',
12
+ description:
13
+ 'A localized, player-facing name or label, formatted as plain text. In some contexts it may be undesirable to render this text, but it should always be exposed to assistive technology (e.g. with `aria-label` in HTML).',
14
+ i18n: true
15
+ })
16
+ export type Label = Static<typeof Label>
17
+
18
+ export const MarkdownString = Type.String({
19
+ $id: 'MarkdownString',
20
+ description: `Localized, player-facing text, formatted in Markdown. It is *not* formatted for use "out of the box"; it uses some custom syntax, intended to be replaced in whatever way is most appropriate for your implementation.
21
+
22
+ * \`[Link text](datasworn:move:starforged/suffer/pay_the_price)\`: A link to the identified object. The ID must conform to the \`AnyId\` type; no wildcards allowed.
23
+ * \`{{table>oracle_rollable:starforged/core/action}}\`: the referenced oracle is rendered here in the source material. The ID must conform to the \`AnyOracleRollableId\` type; no wildcards allowed.
24
+ * \`{{table_columns>move:delve/delve/delve_the_depths}}\`: Render *all* direct OracleRollable children of the identified node. This can be an OracleCollectionId, or the ID of anything that can have EmbeddedOracleRollables (such as a Move or TruthOption).
25
+ `,
26
+ format: 'markdown',
27
+ i18n: true
28
+ })
29
+ export type MarkdownString = Static<typeof Label>
30
+
31
+ export const MarkdownTemplateString = Type.String({
32
+ $id: 'MarkdownTemplateString',
33
+ i18n: true,
34
+ description: `A rich text string in Markdown with replaced values from oracle roll results.
35
+
36
+ The custom syntax \`{{some_row_key>some_oracle_table_id}}\` should be replaced by the \`some_row_key\` string of a rolled oracle table. This is usually the \`text\` key, for example \`{{text>oracle_rollable:starforged/core/action}}\`
37
+ `,
38
+ format: 'markdown',
39
+ releaseStage: 'experimental'
40
+ })
41
+ export type MarkdownTemplateString = Static<typeof MarkdownTemplateString>
42
+
43
+ export const PartOfSpeech = UnionEnumFromRecord(
44
+ {
45
+ common_noun: 'A common noun.',
46
+ proper_noun: 'A proper noun.',
47
+ adjunct_common_noun:
48
+ 'A common noun used as an adjective, to modify another noun.',
49
+ adjunct_proper_noun:
50
+ 'A proper noun used as an adjective, to modify another noun.',
51
+ verb: 'A verb in present tense',
52
+ gerund:
53
+ 'Gerund or present participle of a verb, e.g. "going", "seeing", "waving". Can function as a noun, an adjective, or a progressive verb.',
54
+ adjective: 'An adjective.',
55
+ attributive_verb: 'A verb used as an adjective, to modify a noun.',
56
+ adjective_as_proper_noun: 'An adjective used as a proper noun.',
57
+ common_noun_as_proper_noun: 'An common noun used as a proper noun.'
58
+ },
59
+ { $id: 'PartOfSpeech', releaseStage: 'experimental' }
60
+ )
61
+ export type PartOfSpeech = Static<typeof PartOfSpeech>
62
+
63
+ export const I18nHint = Type.Object(
64
+ {
65
+ part_of_speech: Type.Optional(
66
+ Type.Ref(PartOfSpeech, {
67
+ description: 'The part of speech for this string.'
68
+ })
69
+ )
70
+ },
71
+ { $id: 'I18nHint', releaseStage: 'experimental' }
72
+ )
73
+ export type I18nHint = Static<typeof I18nHint>
74
+
75
+ export const I18nHints = Type.Object(
76
+ {
77
+ text: Type.Optional(Type.Ref(I18nHint)),
78
+ text2: Type.Optional(Type.Ref(I18nHint)),
79
+ text3: Type.Optional(Type.Ref(I18nHint)),
80
+ template: Type.Optional(
81
+ Type.Object({
82
+ text: Type.Optional(Type.Ref(I18nHint)),
83
+ text2: Type.Optional(Type.Ref(I18nHint)),
84
+ text3: Type.Optional(Type.Ref(I18nHint))
85
+ })
86
+ )
87
+ },
88
+ {
89
+ $id: 'I18nHints',
90
+ description:
91
+ 'Internationalization/localization hints for the text content of this object.',
92
+ releaseStage: 'experimental'
93
+ }
94
+ )
95
+ export type I18nHints = Static<typeof I18nHints>
@@ -0,0 +1,16 @@
1
+ // no dependencies
2
+
3
+ // depends on Generic
4
+ export * as Fields from './Fields.js'
5
+ export { default as Id } from './Id.js'
6
+ // depends on Fields
7
+ export * as Inputs from './Inputs.js'
8
+ export * as Metadata from './Metadata.js'
9
+ export * as Player from './Player.js'
10
+ export * as Progress from './Progress.js'
11
+ export * as Range from './Range.js'
12
+ // depends on Id, Text, Player
13
+ export * as RollableValues from './RollableValues.js'
14
+ // depends on Id or Text
15
+ export * as Rolls from './Rolls.js'
16
+ export * as Text from './Text.js'
@@ -0,0 +1,121 @@
1
+ import { type Static, Type } from '@sinclair/typebox'
2
+ import JtdType from '../../scripts/json-typedef/typedef.js'
3
+ import { toJtdElements } from '../../scripts/json-typedef/utils.js'
4
+ import Id from '../common/Id.js'
5
+ import * as Progress from '../common/Progress.js'
6
+ import { DiceRange, StaticDiceRange } from '../common/Range.js'
7
+ import * as Text from '../common/Text.js'
8
+ import { NonCollectableNode } from '../generic/NonCollectableNode.js'
9
+ import { JsonTypeDef } from '../Symbols.js'
10
+ import * as Utils from '../Utils.js'
11
+ import { EmbeddedType } from './common.js'
12
+
13
+ export const DelveSiteDenizenFrequency = Utils.UnionEnum(
14
+ ['very_common', 'common', 'uncommon', 'rare', 'unforeseen'],
15
+ { $id: 'DelveSiteDenizenFrequency' }
16
+ )
17
+ export type DelveSiteDenizenFrequency = Static<typeof DelveSiteDenizenFrequency>
18
+
19
+ export const DelveSiteDenizen = EmbeddedType(
20
+ Type.Object({
21
+ name: Type.Optional(
22
+ Type.Ref(Text.Label, {
23
+ description:
24
+ "A name for the denizen, if it's different than the `name` property of the NPC."
25
+ })
26
+ ),
27
+ npc: Type.Optional(
28
+ Type.Ref(Id.NpcId, {
29
+ description: 'The ID of the relevant NPC entry, if one is specified.'
30
+ })
31
+ ),
32
+ frequency: Type.Ref(DelveSiteDenizenFrequency),
33
+ roll: Type.Ref(DiceRange)
34
+ }),
35
+ 'delve_site',
36
+ 'denizen',
37
+ {
38
+ description:
39
+ 'Represents an entry in a delve site denizen matrix. Denizen matrices are described in Ironsworn: Delve.'
40
+ }
41
+ )
42
+
43
+ export type DelveSiteDenizen = Static<typeof DelveSiteDenizen>
44
+ function StaticDenizenRowStub<
45
+ Min extends number,
46
+ Max extends number,
47
+ Frequency extends DelveSiteDenizenFrequency
48
+ >(min: Min, max: Max, frequency: Frequency) {
49
+ return Type.Object(
50
+ {
51
+ frequency: Type.Literal(frequency),
52
+ roll: StaticDiceRange(min, max)
53
+ },
54
+ { additionalProperties: true, title: 'DelveSiteDenizenStatic' }
55
+ )
56
+ }
57
+ const DelveSiteDenizens = Type.Array(Type.Ref(DelveSiteDenizen))
58
+
59
+ export const DelveSite = NonCollectableNode(
60
+ Type.Object({
61
+ rank: Type.Ref(Progress.ChallengeRank),
62
+ region: Type.Optional(
63
+ Type.Ref(Id.AtlasEntryId, {
64
+ description:
65
+ 'The ID of an atlas entry representing the region in which this delve site is located.'
66
+ })
67
+ ),
68
+ theme: Type.Ref(Id.DelveSiteThemeId, {
69
+ description: "The ID of the site's DelveSiteTheme card."
70
+ }),
71
+ domain: Type.Ref(Id.DelveSiteDomainId, {
72
+ description: "The ID of the site's DelveSiteDomain card."
73
+ }),
74
+ extra_card: Type.Optional(
75
+ Type.Union(
76
+ [Type.Ref(Id.DelveSiteThemeId), Type.Ref(Id.DelveSiteDomainId)],
77
+ {
78
+ description:
79
+ 'An additional theme or domain card ID, for use with optional rules in Ironsworn: Delve.',
80
+ [JsonTypeDef]: { schema: JtdType.String() }
81
+ }
82
+ )
83
+ ),
84
+ description: Type.Ref(Text.MarkdownString),
85
+ denizens: Type.Intersect(
86
+ [
87
+ DelveSiteDenizens,
88
+ Type.Tuple([
89
+ StaticDenizenRowStub(1, 27, 'very_common'),
90
+ StaticDenizenRowStub(28, 41, 'common'),
91
+ StaticDenizenRowStub(42, 55, 'common'),
92
+ StaticDenizenRowStub(56, 69, 'common'),
93
+ StaticDenizenRowStub(70, 75, 'uncommon'),
94
+ StaticDenizenRowStub(76, 81, 'uncommon'),
95
+ StaticDenizenRowStub(82, 87, 'uncommon'),
96
+ StaticDenizenRowStub(88, 93, 'uncommon'),
97
+ StaticDenizenRowStub(94, 95, 'rare'),
98
+ StaticDenizenRowStub(96, 97, 'rare'),
99
+ StaticDenizenRowStub(98, 99, 'rare'),
100
+ StaticDenizenRowStub(100, 100, 'unforeseen')
101
+ ])
102
+ ],
103
+ {
104
+ [JsonTypeDef]: {
105
+ schema: toJtdElements(DelveSiteDenizens)
106
+ },
107
+ rollable: '1d100',
108
+ description:
109
+ "Represents the delve site's denizen matrix as an array of objects."
110
+ }
111
+ )
112
+ }),
113
+ 'delve_site',
114
+ {
115
+ $id: 'DelveSite',
116
+ description: 'A delve site with a theme, domain, and denizens.'
117
+ }
118
+ )
119
+
120
+ export type DelveSite = Static<typeof DelveSite>
121
+ export type TDelveSite = typeof DelveSite
@@ -0,0 +1,136 @@
1
+ import { type Static, Type } from '@sinclair/typebox'
2
+ import { toJtdElements } from '../../scripts/json-typedef/utils.js'
3
+ import Id from '../common/Id.js'
4
+ import { MarkdownString } from '../common/Text.js'
5
+ import { NonCollectableNode } from '../generic/NonCollectableNode.js'
6
+ import { OracleRollableRowText, StaticRowPartial } from '../oracles/TableRow.js'
7
+ import { JsonTypeDef } from '../Symbols.js'
8
+ import { setSourceDataSchema } from '../Utils.js'
9
+ import { EmbeddedType } from './common.js'
10
+
11
+ export const DelveSiteDomainFeature = EmbeddedType(
12
+ OracleRollableRowText,
13
+ 'delve_site_domain',
14
+ 'feature',
15
+ {
16
+ description:
17
+ 'Represents a single Feature entry from a delve site Domain card.'
18
+ }
19
+ )
20
+ export const DelveSiteDomainDanger = EmbeddedType(
21
+ OracleRollableRowText,
22
+ 'delve_site_domain',
23
+ 'danger',
24
+ {
25
+ description:
26
+ 'Represents a single Danger entry from a delve site Domain card.'
27
+ }
28
+ )
29
+
30
+ const DelveSiteDomainFeatures = Type.Array(Type.Ref(DelveSiteDomainFeature))
31
+
32
+ // const DelveSiteDomainDangers = Type.Array(Type.Ref(DelveSiteDomainDangerRow))
33
+ const DelveSiteDomainDangers = Type.Array(Type.Ref(DelveSiteDomainDanger))
34
+
35
+ export const DelveSiteDomain = setSourceDataSchema(
36
+ NonCollectableNode(
37
+ Type.Object({
38
+ summary: Type.Ref(MarkdownString, {
39
+ description: 'The text that appears below the title on the card.'
40
+ }),
41
+ descriptipn: Type.Optional(
42
+ Type.Ref(MarkdownString, {
43
+ description: 'Optional extended description text.'
44
+ })
45
+ ),
46
+ name_oracle: Type.Optional(
47
+ Type.Ref(Id.OracleRollableId, {
48
+ description:
49
+ 'An oracle table ID containing place name elements. For examples, see oracle ID `oracle_rollable:delve/site_name/place/barrow`, and its siblings in oracle collection ID `oracle_collection:delve/site_name/place`. These oracles are used by the site name oracle from Ironsworn: Delve (`oracle_rollable:delve/site_name/format`) to create random names for delve sites.'
50
+ })
51
+ ),
52
+ features: Type.Intersect(
53
+ [
54
+ DelveSiteDomainFeatures,
55
+ Type.Tuple([
56
+ StaticRowPartial(21, 43),
57
+ StaticRowPartial(44, 56),
58
+ StaticRowPartial(57, 64),
59
+ StaticRowPartial(65, 68),
60
+ StaticRowPartial(69, 72),
61
+ StaticRowPartial(73, 76),
62
+ StaticRowPartial(77, 80),
63
+ StaticRowPartial(81, 84),
64
+ StaticRowPartial(85, 88),
65
+ StaticRowPartial(
66
+ // FIXME: disabled for now because the defaults make TypeCompiler upset
67
+ 89,
68
+ 98
69
+
70
+ // {
71
+ // result: 'Something unusual or unexpected',
72
+ // suggestions: {
73
+ // oracles: [
74
+ // 'delve/oracles/feature/aspect',
75
+ // 'delve/oracles/feature/focus'
76
+ // ]
77
+ // }
78
+ // }
79
+ ),
80
+ StaticRowPartial(
81
+ 99,
82
+ 99
83
+ // {
84
+ // result: 'You transition into a new theme'
85
+ // suggestions: {
86
+ // oracles: ['delve/oracles/site_nature/theme']
87
+ // }
88
+ // }
89
+ ),
90
+ StaticRowPartial(
91
+ 100,
92
+ 100
93
+ // {
94
+ // result: 'You transition into a new domain',
95
+ // suggestions: {
96
+ // oracles: ['delve/oracles/site_nature/domain']
97
+ // }
98
+ // }
99
+ )
100
+ ])
101
+ ],
102
+ {
103
+ [JsonTypeDef]: {
104
+ schema: toJtdElements(DelveSiteDomainFeatures)
105
+ }
106
+ }
107
+ ),
108
+ dangers: Type.Intersect(
109
+ [
110
+ DelveSiteDomainDangers,
111
+ Type.Tuple([
112
+ StaticRowPartial(31, 33),
113
+ StaticRowPartial(34, 36),
114
+ StaticRowPartial(37, 39),
115
+ StaticRowPartial(40, 42),
116
+ StaticRowPartial(43, 45)
117
+ ])
118
+ ],
119
+ {
120
+ [JsonTypeDef]: {
121
+ schema: toJtdElements(DelveSiteDomainDangers)
122
+ }
123
+ }
124
+ )
125
+ }),
126
+ 'delve_site_domain',
127
+ {
128
+ $id: 'DelveSiteDomain',
129
+ description: 'A delve site Domain card.'
130
+ }
131
+ ),
132
+ (schema) => ({ ...schema, additionalProperties: false })
133
+ )
134
+
135
+ export type DelveSiteDomain = Static<typeof DelveSiteDomain>
136
+ export type TDelveSiteDomain = typeof DelveSiteDomain