@optolith/entity-descriptions 0.2.1 → 0.3.2

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 (191) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/lib/creator.d.ts +32 -0
  3. package/lib/creator.js +72 -0
  4. package/lib/entities/activatable.d.ts +52 -0
  5. package/lib/entities/activatable.js +609 -0
  6. package/lib/entities/alternativeRule.d.ts +7 -0
  7. package/lib/entities/alternativeRule.js +21 -0
  8. package/lib/entities/attribute.d.ts +6 -0
  9. package/lib/entities/attribute.js +15 -0
  10. package/lib/entities/combatTechnique.d.ts +5 -7
  11. package/lib/entities/combatTechnique.js +34 -24
  12. package/lib/entities/condition.d.ts +12 -0
  13. package/lib/entities/condition.js +63 -0
  14. package/lib/entities/culture.d.ts +8 -0
  15. package/lib/entities/culture.js +309 -0
  16. package/lib/entities/curriculum.d.ts +11 -0
  17. package/lib/entities/curriculum.js +266 -0
  18. package/lib/entities/derivedCharacteristic.d.ts +9 -0
  19. package/lib/entities/derivedCharacteristic.js +91 -0
  20. package/lib/entities/disease.d.ts +9 -0
  21. package/lib/entities/disease.js +88 -0
  22. package/lib/entities/elixir.d.ts +10 -0
  23. package/lib/entities/elixir.js +76 -0
  24. package/lib/entities/equipment.d.ts +24 -0
  25. package/lib/entities/equipment.js +605 -0
  26. package/lib/entities/equipmentPackage.d.ts +8 -0
  27. package/lib/entities/equipmentPackage.js +300 -0
  28. package/lib/entities/experienceLevel.d.ts +3 -2
  29. package/lib/entities/experienceLevel.js +33 -28
  30. package/lib/entities/focusRule.d.ts +3 -4
  31. package/lib/entities/focusRule.js +13 -5
  32. package/lib/entities/influence.d.ts +11 -0
  33. package/lib/entities/influence.js +43 -0
  34. package/lib/entities/liturgicalChant.d.ts +13 -23
  35. package/lib/entities/liturgicalChant.js +171 -131
  36. package/lib/entities/optionalRule.d.ts +3 -2
  37. package/lib/entities/optionalRule.js +4 -3
  38. package/lib/entities/partial/activatableNameChunks.d.ts +58 -0
  39. package/lib/entities/partial/activatableNameChunks.js +356 -0
  40. package/lib/entities/partial/adventurePointsValue.d.ts +9 -0
  41. package/lib/entities/partial/adventurePointsValue.js +243 -0
  42. package/lib/entities/partial/animalTypes.d.ts +11 -0
  43. package/lib/entities/partial/animalTypes.js +13 -0
  44. package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.d.ts +16 -0
  45. package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.js +40 -0
  46. package/lib/entities/partial/dice.d.ts +10 -0
  47. package/lib/entities/partial/dice.js +13 -0
  48. package/lib/entities/partial/enhancements.d.ts +7 -0
  49. package/lib/entities/partial/enhancements.js +26 -0
  50. package/lib/entities/partial/herbary.d.ts +28 -0
  51. package/lib/entities/partial/herbary.js +65 -0
  52. package/lib/entities/partial/map.d.ts +49 -0
  53. package/lib/entities/partial/map.js +43 -0
  54. package/lib/entities/partial/mathOperation.d.ts +36 -0
  55. package/lib/entities/partial/mathOperation.js +107 -0
  56. package/lib/entities/partial/prerequisites/displayOption.d.ts +7 -0
  57. package/lib/entities/partial/prerequisites/displayOption.js +19 -0
  58. package/lib/entities/partial/prerequisites/index.d.ts +67 -0
  59. package/lib/entities/partial/prerequisites/index.js +189 -0
  60. package/lib/entities/partial/prerequisites/part.d.ts +26 -0
  61. package/lib/entities/partial/prerequisites/part.js +88 -0
  62. package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +65 -0
  63. package/lib/entities/partial/prerequisites/prerequisiteGroups.js +278 -0
  64. package/lib/entities/partial/prerequisites/single/activatable.d.ts +18 -0
  65. package/lib/entities/partial/prerequisites/single/activatable.js +40 -0
  66. package/lib/entities/partial/prerequisites/single/animistPower.d.ts +8 -0
  67. package/lib/entities/partial/prerequisites/single/animistPower.js +23 -0
  68. package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +7 -0
  69. package/lib/entities/partial/prerequisites/single/blessedTradition.js +32 -0
  70. package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +6 -0
  71. package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.js +19 -0
  72. package/lib/entities/partial/prerequisites/single/culture.d.ts +8 -0
  73. package/lib/entities/partial/prerequisites/single/culture.js +20 -0
  74. package/lib/entities/partial/prerequisites/single/enhancement.d.ts +8 -0
  75. package/lib/entities/partial/prerequisites/single/enhancement.js +41 -0
  76. package/lib/entities/partial/prerequisites/single/influence.d.ts +8 -0
  77. package/lib/entities/partial/prerequisites/single/influence.js +17 -0
  78. package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +7 -0
  79. package/lib/entities/partial/prerequisites/single/magicalTradition.js +27 -0
  80. package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +6 -0
  81. package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.js +8 -0
  82. package/lib/entities/partial/prerequisites/single/pact.d.ts +8 -0
  83. package/lib/entities/partial/prerequisites/single/pact.js +30 -0
  84. package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +8 -0
  85. package/lib/entities/partial/prerequisites/single/personalityTrait.js +28 -0
  86. package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +7 -0
  87. package/lib/entities/partial/prerequisites/single/primaryAttribute.js +15 -0
  88. package/lib/entities/partial/prerequisites/single/profession.d.ts +8 -0
  89. package/lib/entities/partial/prerequisites/single/profession.js +19 -0
  90. package/lib/entities/partial/prerequisites/single/publication.d.ts +8 -0
  91. package/lib/entities/partial/prerequisites/single/publication.js +19 -0
  92. package/lib/entities/partial/prerequisites/single/race.d.ts +8 -0
  93. package/lib/entities/partial/prerequisites/single/race.js +20 -0
  94. package/lib/entities/partial/prerequisites/single/rated.d.ts +8 -0
  95. package/lib/entities/partial/prerequisites/single/rated.js +41 -0
  96. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +8 -0
  97. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +89 -0
  98. package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +8 -0
  99. package/lib/entities/partial/prerequisites/single/ratedSum.js +21 -0
  100. package/lib/entities/partial/prerequisites/single/rule.d.ts +7 -0
  101. package/lib/entities/partial/prerequisites/single/rule.js +4 -0
  102. package/lib/entities/partial/prerequisites/single/sex.d.ts +7 -0
  103. package/lib/entities/partial/prerequisites/single/sex.js +19 -0
  104. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +7 -0
  105. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.js +21 -0
  106. package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +8 -0
  107. package/lib/entities/partial/prerequisites/single/socialStatus.js +21 -0
  108. package/lib/entities/partial/prerequisites/single/state.d.ts +8 -0
  109. package/lib/entities/partial/prerequisites/single/state.js +20 -0
  110. package/lib/entities/partial/prerequisites/single/text.d.ts +7 -0
  111. package/lib/entities/partial/prerequisites/single/text.js +9 -0
  112. package/lib/entities/partial/professions.d.ts +15 -0
  113. package/lib/entities/partial/professions.js +19 -0
  114. package/lib/entities/partial/rated/activatable/castingTime.d.ts +16 -7
  115. package/lib/entities/partial/rated/activatable/castingTime.js +35 -20
  116. package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +18 -3
  117. package/lib/entities/partial/rated/activatable/checkResultBased.js +18 -10
  118. package/lib/entities/partial/rated/activatable/cost.d.ts +88 -8
  119. package/lib/entities/partial/rated/activatable/cost.js +183 -115
  120. package/lib/entities/partial/rated/activatable/duration.d.ts +36 -13
  121. package/lib/entities/partial/rated/activatable/duration.js +72 -61
  122. package/lib/entities/partial/rated/activatable/effect.d.ts +4 -4
  123. package/lib/entities/partial/rated/activatable/effect.js +32 -25
  124. package/lib/entities/partial/rated/activatable/index.d.ts +31 -27
  125. package/lib/entities/partial/rated/activatable/index.js +63 -28
  126. package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +5 -6
  127. package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +8 -5
  128. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +2 -4
  129. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +7 -42
  130. package/lib/entities/partial/rated/activatable/range.d.ts +22 -14
  131. package/lib/entities/partial/rated/activatable/range.js +54 -54
  132. package/lib/entities/partial/rated/activatable/speed.d.ts +11 -2
  133. package/lib/entities/partial/rated/activatable/speed.js +14 -1
  134. package/lib/entities/partial/rated/activatable/targetCategory.d.ts +4 -5
  135. package/lib/entities/partial/rated/activatable/targetCategory.js +19 -24
  136. package/lib/entities/partial/rated/improvementCost.d.ts +8 -4
  137. package/lib/entities/partial/rated/improvementCost.js +9 -4
  138. package/lib/entities/partial/rated/skillCheck.d.ts +20 -17
  139. package/lib/entities/partial/rated/skillCheck.js +56 -54
  140. package/lib/entities/partial/reader.d.ts +266 -0
  141. package/lib/entities/partial/reader.js +175 -0
  142. package/lib/entities/partial/responsiveText.d.ts +10 -5
  143. package/lib/entities/partial/responsiveText.js +19 -3
  144. package/lib/entities/partial/units/energy.d.ts +5 -8
  145. package/lib/entities/partial/units/energy.js +5 -23
  146. package/lib/entities/partial/units/length.d.ts +20 -2
  147. package/lib/entities/partial/units/length.js +24 -5
  148. package/lib/entities/partial/units/timeSpan.d.ts +25 -4
  149. package/lib/entities/partial/units/timeSpan.js +27 -15
  150. package/lib/entities/partial/unknown.d.ts +5 -1
  151. package/lib/entities/partial/unknown.js +5 -1
  152. package/lib/entities/personalityTrait.d.ts +7 -0
  153. package/lib/entities/personalityTrait.js +56 -0
  154. package/lib/entities/poison.d.ts +12 -0
  155. package/lib/entities/poison.js +368 -0
  156. package/lib/entities/profession.d.ts +12 -0
  157. package/lib/entities/profession.js +585 -0
  158. package/lib/entities/race.d.ts +9 -0
  159. package/lib/entities/race.js +146 -0
  160. package/lib/entities/sexPractice.d.ts +6 -0
  161. package/lib/entities/sexPractice.js +33 -0
  162. package/lib/entities/skill.d.ts +9 -9
  163. package/lib/entities/skill.js +124 -91
  164. package/lib/entities/spell.d.ts +86 -26
  165. package/lib/entities/spell.js +842 -147
  166. package/lib/entities/state.d.ts +6 -0
  167. package/lib/entities/state.js +17 -0
  168. package/lib/helpers/enums.d.ts +11 -0
  169. package/lib/helpers/enums.js +6 -0
  170. package/lib/helpers/getTypes.d.ts +12 -482
  171. package/lib/helpers/getTypes.js +1 -0
  172. package/lib/helpers/identifiers.d.ts +314 -0
  173. package/lib/helpers/identifiers.js +333 -0
  174. package/lib/helpers/locale.d.ts +21 -2
  175. package/lib/helpers/translate.d.ts +47 -5
  176. package/lib/helpers/translate.js +13 -6
  177. package/lib/index.d.ts +854 -21
  178. package/lib/index.js +182 -17
  179. package/lib/references/index.d.ts +6 -3
  180. package/lib/references/index.js +25 -33
  181. package/lib/references/page.d.ts +1 -1
  182. package/lib/references/page.js +14 -14
  183. package/lib/references/pageRange.d.ts +1 -5
  184. package/lib/references/pageRange.js +7 -16
  185. package/lib/tsconfig.tsbuildinfo +1 -0
  186. package/package.json +31 -10
  187. package/.prettierrc.yml +0 -1
  188. package/lib/entities/partial/rated/activatable/entity.d.ts +0 -11
  189. package/lib/entities/partial/rated/activatable/entity.js +0 -12
  190. package/lib/references/occurrence.d.ts +0 -4
  191. package/lib/references/occurrence.js +0 -3
@@ -0,0 +1,368 @@
1
+ import { ensureNonEmpty } from "@elyukai/utils/array/nonEmpty";
2
+ import { isNotNullish, mapNullable } from "@elyukai/utils/nullable";
3
+ import { sign } from "@elyukai/utils/string/number";
4
+ import { assertExhaustive } from "@elyukai/utils/typeSafety";
5
+ import { createEntityDescriptionCreator } from "../creator.js";
6
+ import { renderDice, renderDiceAndFlat } from "./partial/dice.js";
7
+ import { renderAlternativeNames, renderChance, renderLaboratoryLevel, renderResistance, } from "./partial/herbary.js";
8
+ import { renderMathOperation } from "./partial/mathOperation.js";
9
+ import { printPlainGeneralPrerequisites } from "./partial/prerequisites/index.js";
10
+ import { parensIf } from "./partial/rated/activatable/parensIf.js";
11
+ import { ResponsiveTextSize } from "./partial/responsiveText.js";
12
+ import { formatTimeSpan } from "./partial/units/timeSpan.js";
13
+ import { MISSING_VALUE, UNHANDLED_VALUE } from "./partial/unknown.js";
14
+ const renderApplicationType = (translate, localeJoin, localeCompare, applicationType) => translate("{$types} poison", {
15
+ types: localeJoin(applicationType
16
+ .map(type => {
17
+ switch (type.kind) {
18
+ case "Weapon":
19
+ return translate("Weapon (poison)");
20
+ case "Ingestion":
21
+ return translate("Ingestion (poison)");
22
+ case "Inhalation":
23
+ return translate("Inhalation (poison)");
24
+ case "Contact":
25
+ return translate("Contact (poison)");
26
+ default:
27
+ return assertExhaustive(type);
28
+ }
29
+ })
30
+ .toSorted(localeCompare)
31
+ .map((type, index, arr) => index === arr.length - 1 && type.at(-1) === "-" ? type.slice(0, -1) : type), "conjunction"),
32
+ });
33
+ const renderLevel = (translate, translateMap, level) => {
34
+ switch (level.kind) {
35
+ case "QualityLevel":
36
+ return translate("QL");
37
+ case "Constant":
38
+ return typeof level.Constant === "number" ? level.Constant : level.Constant.value;
39
+ case "BySubtype":
40
+ return level.BySubtype.map(subtype => `${subtype.value} (${translateMap(subtype.translations)?.name ?? MISSING_VALUE})`).join(", ");
41
+ default:
42
+ return assertExhaustive(level);
43
+ }
44
+ };
45
+ const renderAddiction = (translate, translateMap, getInstanceById, addiction) => [
46
+ ensureNonEmpty([
47
+ mapNullable(renderChance(translate, translateMap, addiction), chance => chance +
48
+ parensIf(addiction.check === undefined
49
+ ? undefined
50
+ : addiction.check.onlySameMonth === true
51
+ ? translate(".input {$count :number} {{check required every {$count}. application in the same month}}", { count: addiction.check.interval })
52
+ : translate(".input {$count :number} {{check required every {$count}. application}}", { count: addiction.check.interval }))),
53
+ mapNullable(addiction.disease, diseaseId => {
54
+ const disease = getInstanceById("Disease", diseaseId);
55
+ const diseaseTranslation = translateMap(disease?.translations);
56
+ return translate("see {$link}", {
57
+ link: diseaseTranslation?.name ?? MISSING_VALUE,
58
+ });
59
+ }),
60
+ ].filter(isNotNullish))?.join(", "),
61
+ mapNullable(addiction.withdrawalPrevention, withdrawalPrevention => translate(".input {$value :number} {{{$value} applications every {$interval}}}", {
62
+ value: withdrawalPrevention.amount,
63
+ interval: formatTimeSpan(translate, ResponsiveTextSize.Full, { kind: "Days" }, (() => {
64
+ switch (withdrawalPrevention.interval.kind) {
65
+ case "Constant":
66
+ return withdrawalPrevention.interval.Constant.value;
67
+ case "DiceBased":
68
+ return renderDice(translate, withdrawalPrevention.interval.DiceBased.dice);
69
+ default:
70
+ return assertExhaustive(withdrawalPrevention.interval);
71
+ }
72
+ })()),
73
+ })),
74
+ ]
75
+ .filter(isNotNullish)
76
+ .join("; ");
77
+ const renderIntoxicantValues = (translate, translateMap, getInstanceById, intoxicant) => {
78
+ const translation = translateMap(intoxicant.translations);
79
+ return {
80
+ ingestion: translation?.ingestion ?? MISSING_VALUE,
81
+ sideEffect: translation?.side_effect,
82
+ overdose: translation?.overdose ?? MISSING_VALUE,
83
+ legality: intoxicant.legality.is_legal ? translate("legal") : translate("illegal"),
84
+ special: translation?.special,
85
+ addiction: intoxicant?.addiction === undefined
86
+ ? undefined
87
+ : renderAddiction(translate, translateMap, getInstanceById, intoxicant.addiction),
88
+ };
89
+ };
90
+ const renderSourceTypeBasedValues = (translate, translateMap, getInstanceById, sourceType) => {
91
+ switch (sourceType.kind) {
92
+ case "AnimalVenom":
93
+ return {
94
+ level: renderLevel(translate, translateMap, sourceType.AnimalVenom.level),
95
+ sourceType: translate("animal venom"),
96
+ };
97
+ case "AlchemicalPoison": {
98
+ const translation = translateMap(sourceType.AlchemicalPoison.translations);
99
+ return {
100
+ level: translate("QL"),
101
+ sourceType: [
102
+ sourceType.AlchemicalPoison.isDemonic === true ? translate("demonic poison") : undefined,
103
+ translate("alchemical poison"),
104
+ ]
105
+ .filter(isNotNullish)
106
+ .join(", "),
107
+ ...(sourceType.AlchemicalPoison.intoxicant === undefined
108
+ ? undefined
109
+ : renderIntoxicantValues(translate, translateMap, getInstanceById, sourceType.AlchemicalPoison.intoxicant)),
110
+ typicalIngredients: translation?.typical_ingredients.join(", "),
111
+ priceOfIngedientsPerLevel: translate("{$cost} per level", {
112
+ cost: translate(".input {$value :number} {{{$value} silverthalers}}", {
113
+ value: sourceType.AlchemicalPoison.cost_per_ingredient_level,
114
+ }),
115
+ }),
116
+ laboratory: renderLaboratoryLevel(translate, sourceType.AlchemicalPoison.laboratory),
117
+ brewingDifficulty: sign(sourceType.AlchemicalPoison.brewing_difficulty),
118
+ prerequisitesBrewingProcess: translation?.brewing_process_prerequisites ?? translate("none"),
119
+ tradeSecret: mapNullable(sourceType.AlchemicalPoison.trade_secret, tradeSecret => ({
120
+ apValue: tradeSecret.ap_value,
121
+ prerequisites: tradeSecret.prerequisites,
122
+ })),
123
+ };
124
+ }
125
+ case "AlchemicalPactGiftPoison":
126
+ return {
127
+ level: translate("QL"),
128
+ sourceType: translate("alchemical poison"),
129
+ };
130
+ case "MineralPoison":
131
+ return {
132
+ level: sourceType.MineralPoison.level,
133
+ sourceType: translate("mineral poison"),
134
+ };
135
+ case "PlantPoison":
136
+ return {
137
+ level: sourceType.PlantPoison.level,
138
+ sourceType: translate("plant poison"),
139
+ ...(sourceType.PlantPoison.intoxicant === undefined
140
+ ? undefined
141
+ : renderIntoxicantValues(translate, translateMap, getInstanceById, sourceType.PlantPoison.intoxicant)),
142
+ };
143
+ case "DemonicPoison": {
144
+ const translation = translateMap(sourceType.DemonicPoison.translations);
145
+ return {
146
+ level: renderLevel(translate, translateMap, sourceType.DemonicPoison.level),
147
+ sourceType: translate("demonic poison"),
148
+ note: translation?.note,
149
+ };
150
+ }
151
+ default:
152
+ return assertExhaustive(sourceType);
153
+ }
154
+ };
155
+ const renderStart = (translate, translateMap, start) => {
156
+ switch (start.kind) {
157
+ case "Immediate":
158
+ return translate("immediate");
159
+ case "Constant":
160
+ return formatTimeSpan(translate, ResponsiveTextSize.Full, start.Constant.unit, start.Constant.value);
161
+ case "DiceBased":
162
+ return formatTimeSpan(translate, ResponsiveTextSize.Full, start.DiceBased.unit, renderDiceAndFlat(translate, start.DiceBased.dice, start.DiceBased.flat));
163
+ case "Indefinite":
164
+ return translateMap(start.Indefinite.translations)?.description ?? MISSING_VALUE;
165
+ default:
166
+ return assertExhaustive(start);
167
+ }
168
+ };
169
+ const renderDuration = (translate, translateMap, duration) => {
170
+ switch (duration.kind) {
171
+ case "Instant":
172
+ return translate("instant");
173
+ case "Constant":
174
+ return formatTimeSpan(translate, ResponsiveTextSize.Full, duration.Constant.unit, duration.Constant.value);
175
+ case "DiceBased":
176
+ return formatTimeSpan(translate, ResponsiveTextSize.Full, duration.DiceBased.unit, renderDiceAndFlat(translate, duration.DiceBased.dice, duration.DiceBased.flat));
177
+ case "ExpressionBased":
178
+ return renderMathOperation(duration.ExpressionBased.value, value => {
179
+ switch (value.kind) {
180
+ case "Constant":
181
+ return value.Constant.toString();
182
+ case "Dice":
183
+ return renderDice(translate, value.Dice);
184
+ case "CircleOfDamnation":
185
+ return translate("CoD");
186
+ default:
187
+ return assertExhaustive(value);
188
+ }
189
+ });
190
+ case "Indefinite":
191
+ return translateMap(duration.Indefinite.translations)?.description ?? UNHANDLED_VALUE;
192
+ default:
193
+ return assertExhaustive(duration);
194
+ }
195
+ };
196
+ const renderCost = (translate, translateMap, cost) => {
197
+ switch (cost.kind) {
198
+ case "CannotBeExtracted":
199
+ return translate("cannot be extracted");
200
+ case "None":
201
+ return translate("none");
202
+ case "Constant":
203
+ return translate(".input {$value :number} {{{$value} silverthalers}}", {
204
+ value: cost.Constant,
205
+ });
206
+ case "DependingOnPurchaseOrSale":
207
+ return `${translate(".input {$value :number} {{{$value} silverthalers}}", {
208
+ value: cost.DependingOnPurchaseOrSale.purchase,
209
+ })} (${translate("purchase")}) / ${translate(".input {$value :number} {{{$value} silverthalers}}", {
210
+ value: cost.DependingOnPurchaseOrSale.sale,
211
+ })} (${translate("sale")})`;
212
+ case "Indefinite":
213
+ return translateMap(cost.Indefinite.translations)?.description ?? MISSING_VALUE;
214
+ default:
215
+ return assertExhaustive(cost);
216
+ }
217
+ };
218
+ const renderValueCost = (translate, translateMap, cost, value) => value === undefined
219
+ ? {
220
+ label: translate("Cost"),
221
+ value: renderCost(translate, translateMap, cost),
222
+ }
223
+ : {
224
+ label: translate("Value/Cost"),
225
+ value: `${translate(".input {$value :number} {{{$value} silverthalers}}", {
226
+ value,
227
+ })} / ${renderCost(translate, translateMap, cost)}`,
228
+ };
229
+ /**
230
+ * Get a JSON representation of the rules text for a poison.
231
+ */
232
+ export const getPoisonEntityDescription = createEntityDescriptionCreator(({ getInstanceById, getResolvedSelectOptionById, idMap }, locale, { content: entry }) => {
233
+ const { translate, translateMap, join: localeJoin, compare: localeCompare } = locale;
234
+ const translation = translateMap(entry.translations);
235
+ if (translation === undefined) {
236
+ return undefined;
237
+ }
238
+ const applicationType = renderApplicationType(translate, localeJoin, localeCompare, entry.application_type);
239
+ const { level, sourceType, ingestion, sideEffect, overdose, legality, special, addiction, typicalIngredients, priceOfIngedientsPerLevel, laboratory, brewingDifficulty, prerequisitesBrewingProcess, tradeSecret, note, } = renderSourceTypeBasedValues(translate, translateMap, getInstanceById, entry.source_type);
240
+ return {
241
+ title: translation.name,
242
+ className: "poison",
243
+ body: [
244
+ {
245
+ type: "definitionList",
246
+ items: [
247
+ renderAlternativeNames(translate, translation.alternative_names),
248
+ {
249
+ label: translate("Level"),
250
+ value: level.toString(),
251
+ },
252
+ {
253
+ label: translate("Type"),
254
+ value: `${applicationType}, ${sourceType}`,
255
+ },
256
+ {
257
+ label: translate("Resistance"),
258
+ value: renderResistance(translate, translateMap, getInstanceById, idMap, entry.resistance),
259
+ },
260
+ ingestion === undefined
261
+ ? undefined
262
+ : {
263
+ label: translate("Ingestion"),
264
+ value: ingestion,
265
+ },
266
+ {
267
+ label: translate("Effect"),
268
+ value: translation.effect.default +
269
+ (translation.effect.reduced === undefined ? "" : ` / ${translation.effect.reduced}`),
270
+ },
271
+ sideEffect === undefined
272
+ ? undefined
273
+ : {
274
+ label: translate("Side Effect"),
275
+ value: sideEffect,
276
+ },
277
+ overdose === undefined
278
+ ? undefined
279
+ : {
280
+ label: translate("Overdose"),
281
+ value: overdose,
282
+ },
283
+ {
284
+ label: translate("Start"),
285
+ value: renderStart(translate, translateMap, entry.start),
286
+ },
287
+ {
288
+ label: translate("Duration"),
289
+ value: renderDuration(translate, translateMap, entry.duration.default) +
290
+ (entry.duration.reduced === undefined
291
+ ? ""
292
+ : ` / ${renderDuration(translate, translateMap, entry.duration.reduced)}`),
293
+ },
294
+ legality === undefined
295
+ ? undefined
296
+ : {
297
+ label: translate("Legality"),
298
+ value: legality,
299
+ },
300
+ entry.cost === undefined
301
+ ? undefined
302
+ : renderValueCost(translate, translateMap, entry.cost, entry.value),
303
+ special === undefined
304
+ ? undefined
305
+ : {
306
+ label: translate("Special"),
307
+ value: special,
308
+ },
309
+ addiction === undefined
310
+ ? undefined
311
+ : {
312
+ label: translate("Addiction"),
313
+ value: addiction,
314
+ },
315
+ typicalIngredients === undefined
316
+ ? undefined
317
+ : {
318
+ label: translate("Typical Ingredients"),
319
+ value: typicalIngredients,
320
+ },
321
+ priceOfIngedientsPerLevel === undefined
322
+ ? undefined
323
+ : {
324
+ label: translate("Price of Ingredients/Level"),
325
+ value: priceOfIngedientsPerLevel,
326
+ },
327
+ laboratory === undefined
328
+ ? undefined
329
+ : {
330
+ label: translate("Laboratory"),
331
+ value: laboratory,
332
+ },
333
+ brewingDifficulty === undefined
334
+ ? undefined
335
+ : {
336
+ label: translate("Brewing Difficulty"),
337
+ value: brewingDifficulty,
338
+ },
339
+ prerequisitesBrewingProcess === undefined
340
+ ? undefined
341
+ : {
342
+ label: `${translate("Prerequisites")} (${translate("Brewing Process")})`,
343
+ value: prerequisitesBrewingProcess,
344
+ },
345
+ tradeSecret === undefined
346
+ ? undefined
347
+ : {
348
+ label: `${translate("AP Value")} (${translate("Trade Secret")})`,
349
+ value: translate("{$value} AP", { value: tradeSecret.apValue }) +
350
+ parensIf(mapNullable(tradeSecret.prerequisites, prerequisites => `${translate("Prerequisites")}: ${printPlainGeneralPrerequisites(getInstanceById, getResolvedSelectOptionById, locale, prerequisites)}`)),
351
+ },
352
+ {
353
+ label: translate("Quality Levels"),
354
+ value: translate("The poison levels equals the QL."),
355
+ },
356
+ note === undefined
357
+ ? undefined
358
+ : {
359
+ label: translate("Note"),
360
+ value: note,
361
+ },
362
+ ],
363
+ },
364
+ ],
365
+ errata: translation.errata,
366
+ references: entry.src,
367
+ };
368
+ });
@@ -0,0 +1,12 @@
1
+ import { type MagicalActionIdentifier, type RatedIdentifier, type SpecialAbilityIdentifier } from "optolith-database-schema/gen";
2
+ import type { GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "../helpers/getTypes.js";
3
+ import { type GetResolvedSelectOptionById } from "./partial/prerequisites/single/activatable.js";
4
+ /**
5
+ * Get a JSON representation of the rules text for a profession version.
6
+ */
7
+ export declare const getProfessionVersionEntityDescription: import("../creator.js").EntityDescriptionCreator<"ProfessionVersion", {
8
+ getInstanceById: GetInstanceById<"Publication" | "ExperienceLevel" | "Advantage" | "Disadvantage" | SpecialAbilityIdentifier["kind"] | "Aspect" | RatedIdentifier["kind"] | "Race" | "Culture" | MagicalActionIdentifier["kind"] | "SkillGroup" | "Cantrip" | "Blessing">;
9
+ getAllInstances: GetAllInstances<"SkillGroup">;
10
+ getChildInstancesForInstanceId: GetAllChildInstancesForParent<"ProfessionPackage" | "ProfessionVariant">;
11
+ getResolvedSelectOptionById: GetResolvedSelectOptionById;
12
+ }, import("../index.js").EntityDescription>;