@optolith/entity-descriptions 0.2.1 → 0.3.1

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 (187) hide show
  1. package/CHANGELOG.md +58 -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 +613 -0
  26. package/lib/entities/equipmentPackage.d.ts +8 -0
  27. package/lib/entities/equipmentPackage.js +301 -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 +7 -0
  33. package/lib/entities/influence.js +35 -0
  34. package/lib/entities/liturgicalChant.d.ts +10 -23
  35. package/lib/entities/liturgicalChant.js +169 -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/herbary.d.ts +28 -0
  49. package/lib/entities/partial/herbary.js +65 -0
  50. package/lib/entities/partial/map.d.ts +49 -0
  51. package/lib/entities/partial/map.js +43 -0
  52. package/lib/entities/partial/mathOperation.d.ts +36 -0
  53. package/lib/entities/partial/mathOperation.js +107 -0
  54. package/lib/entities/partial/prerequisites/displayOption.d.ts +7 -0
  55. package/lib/entities/partial/prerequisites/displayOption.js +19 -0
  56. package/lib/entities/partial/prerequisites/index.d.ts +67 -0
  57. package/lib/entities/partial/prerequisites/index.js +189 -0
  58. package/lib/entities/partial/prerequisites/part.d.ts +26 -0
  59. package/lib/entities/partial/prerequisites/part.js +88 -0
  60. package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +65 -0
  61. package/lib/entities/partial/prerequisites/prerequisiteGroups.js +269 -0
  62. package/lib/entities/partial/prerequisites/single/activatable.d.ts +18 -0
  63. package/lib/entities/partial/prerequisites/single/activatable.js +40 -0
  64. package/lib/entities/partial/prerequisites/single/animistPower.d.ts +8 -0
  65. package/lib/entities/partial/prerequisites/single/animistPower.js +23 -0
  66. package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +7 -0
  67. package/lib/entities/partial/prerequisites/single/blessedTradition.js +32 -0
  68. package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +6 -0
  69. package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.js +19 -0
  70. package/lib/entities/partial/prerequisites/single/culture.d.ts +8 -0
  71. package/lib/entities/partial/prerequisites/single/culture.js +20 -0
  72. package/lib/entities/partial/prerequisites/single/enhancement.d.ts +8 -0
  73. package/lib/entities/partial/prerequisites/single/enhancement.js +41 -0
  74. package/lib/entities/partial/prerequisites/single/influence.d.ts +8 -0
  75. package/lib/entities/partial/prerequisites/single/influence.js +17 -0
  76. package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +7 -0
  77. package/lib/entities/partial/prerequisites/single/magicalTradition.js +27 -0
  78. package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +6 -0
  79. package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.js +8 -0
  80. package/lib/entities/partial/prerequisites/single/pact.d.ts +8 -0
  81. package/lib/entities/partial/prerequisites/single/pact.js +30 -0
  82. package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +8 -0
  83. package/lib/entities/partial/prerequisites/single/personalityTrait.js +28 -0
  84. package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +7 -0
  85. package/lib/entities/partial/prerequisites/single/primaryAttribute.js +15 -0
  86. package/lib/entities/partial/prerequisites/single/publication.d.ts +8 -0
  87. package/lib/entities/partial/prerequisites/single/publication.js +19 -0
  88. package/lib/entities/partial/prerequisites/single/race.d.ts +8 -0
  89. package/lib/entities/partial/prerequisites/single/race.js +20 -0
  90. package/lib/entities/partial/prerequisites/single/rated.d.ts +8 -0
  91. package/lib/entities/partial/prerequisites/single/rated.js +41 -0
  92. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +8 -0
  93. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +89 -0
  94. package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +8 -0
  95. package/lib/entities/partial/prerequisites/single/ratedSum.js +21 -0
  96. package/lib/entities/partial/prerequisites/single/rule.d.ts +7 -0
  97. package/lib/entities/partial/prerequisites/single/rule.js +4 -0
  98. package/lib/entities/partial/prerequisites/single/sex.d.ts +7 -0
  99. package/lib/entities/partial/prerequisites/single/sex.js +19 -0
  100. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +7 -0
  101. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.js +21 -0
  102. package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +8 -0
  103. package/lib/entities/partial/prerequisites/single/socialStatus.js +21 -0
  104. package/lib/entities/partial/prerequisites/single/state.d.ts +8 -0
  105. package/lib/entities/partial/prerequisites/single/state.js +20 -0
  106. package/lib/entities/partial/prerequisites/single/text.d.ts +7 -0
  107. package/lib/entities/partial/prerequisites/single/text.js +9 -0
  108. package/lib/entities/partial/professions.d.ts +15 -0
  109. package/lib/entities/partial/professions.js +19 -0
  110. package/lib/entities/partial/rated/activatable/castingTime.d.ts +16 -7
  111. package/lib/entities/partial/rated/activatable/castingTime.js +35 -20
  112. package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +18 -3
  113. package/lib/entities/partial/rated/activatable/checkResultBased.js +18 -10
  114. package/lib/entities/partial/rated/activatable/cost.d.ts +88 -8
  115. package/lib/entities/partial/rated/activatable/cost.js +183 -115
  116. package/lib/entities/partial/rated/activatable/duration.d.ts +36 -13
  117. package/lib/entities/partial/rated/activatable/duration.js +72 -61
  118. package/lib/entities/partial/rated/activatable/effect.d.ts +4 -4
  119. package/lib/entities/partial/rated/activatable/effect.js +32 -25
  120. package/lib/entities/partial/rated/activatable/index.d.ts +31 -27
  121. package/lib/entities/partial/rated/activatable/index.js +63 -28
  122. package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +5 -6
  123. package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +8 -5
  124. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +2 -4
  125. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +7 -42
  126. package/lib/entities/partial/rated/activatable/range.d.ts +22 -14
  127. package/lib/entities/partial/rated/activatable/range.js +54 -54
  128. package/lib/entities/partial/rated/activatable/speed.d.ts +11 -2
  129. package/lib/entities/partial/rated/activatable/speed.js +14 -1
  130. package/lib/entities/partial/rated/activatable/targetCategory.d.ts +4 -5
  131. package/lib/entities/partial/rated/activatable/targetCategory.js +19 -24
  132. package/lib/entities/partial/rated/improvementCost.d.ts +16 -4
  133. package/lib/entities/partial/rated/improvementCost.js +63 -4
  134. package/lib/entities/partial/rated/skillCheck.d.ts +20 -17
  135. package/lib/entities/partial/rated/skillCheck.js +56 -54
  136. package/lib/entities/partial/reader.d.ts +266 -0
  137. package/lib/entities/partial/reader.js +175 -0
  138. package/lib/entities/partial/responsiveText.d.ts +10 -5
  139. package/lib/entities/partial/responsiveText.js +19 -3
  140. package/lib/entities/partial/units/energy.d.ts +5 -8
  141. package/lib/entities/partial/units/energy.js +5 -23
  142. package/lib/entities/partial/units/length.d.ts +20 -2
  143. package/lib/entities/partial/units/length.js +24 -5
  144. package/lib/entities/partial/units/timeSpan.d.ts +25 -4
  145. package/lib/entities/partial/units/timeSpan.js +27 -15
  146. package/lib/entities/partial/unknown.d.ts +5 -1
  147. package/lib/entities/partial/unknown.js +5 -1
  148. package/lib/entities/personalityTrait.d.ts +7 -0
  149. package/lib/entities/personalityTrait.js +56 -0
  150. package/lib/entities/poison.d.ts +12 -0
  151. package/lib/entities/poison.js +356 -0
  152. package/lib/entities/profession.d.ts +12 -0
  153. package/lib/entities/profession.js +585 -0
  154. package/lib/entities/race.d.ts +9 -0
  155. package/lib/entities/race.js +146 -0
  156. package/lib/entities/sexPractice.d.ts +6 -0
  157. package/lib/entities/sexPractice.js +33 -0
  158. package/lib/entities/skill.d.ts +9 -9
  159. package/lib/entities/skill.js +124 -91
  160. package/lib/entities/spell.d.ts +83 -26
  161. package/lib/entities/spell.js +835 -147
  162. package/lib/entities/state.d.ts +6 -0
  163. package/lib/entities/state.js +17 -0
  164. package/lib/helpers/enums.d.ts +11 -0
  165. package/lib/helpers/enums.js +6 -0
  166. package/lib/helpers/getTypes.d.ts +12 -482
  167. package/lib/helpers/getTypes.js +1 -0
  168. package/lib/helpers/identifiers.d.ts +314 -0
  169. package/lib/helpers/identifiers.js +333 -0
  170. package/lib/helpers/locale.d.ts +21 -2
  171. package/lib/helpers/translate.d.ts +47 -5
  172. package/lib/helpers/translate.js +13 -6
  173. package/lib/index.d.ts +848 -21
  174. package/lib/index.js +182 -17
  175. package/lib/references/index.d.ts +6 -3
  176. package/lib/references/index.js +25 -33
  177. package/lib/references/page.d.ts +1 -1
  178. package/lib/references/page.js +14 -14
  179. package/lib/references/pageRange.d.ts +1 -5
  180. package/lib/references/pageRange.js +7 -16
  181. package/lib/tsconfig.tsbuildinfo +1 -0
  182. package/package.json +30 -10
  183. package/.prettierrc.yml +0 -1
  184. package/lib/entities/partial/rated/activatable/entity.d.ts +0 -11
  185. package/lib/entities/partial/rated/activatable/entity.js +0 -12
  186. package/lib/references/occurrence.d.ts +0 -4
  187. package/lib/references/occurrence.js +0 -3
@@ -0,0 +1,146 @@
1
+ import { anySameIndices } from "@elyukai/utils/array/filters";
2
+ import { isNotEmpty } from "@elyukai/utils/array/nonEmpty";
3
+ import { deepEqual } from "@elyukai/utils/equality";
4
+ import { on } from "@elyukai/utils/function";
5
+ import { isNotNullish } from "@elyukai/utils/nullable";
6
+ import { Reader } from "@elyukai/utils/reader";
7
+ import { sign } from "@elyukai/utils/string/number";
8
+ import { createEntityDescriptionCreator } from "../creator.js";
9
+ import { renderCommonnessRatedAdvantagesAndDisadvantages, renderCommonnessRatedAdvantagesOrDisadvantages, renderValueWithPossibleTranslation, } from "./partial/commonnessRatedAdvantagesAndDisadvantages.js";
10
+ import { MISSING_VALUE } from "./partial/unknown.js";
11
+ const renderBaseValueItem = (label, value) => Reader.asks(({ translate }) => ({
12
+ label: translate(label),
13
+ value: value < 0 ? sign(value) : value.toString(),
14
+ }));
15
+ const renderAttributeAdjustmentsItem = (totalAttributesCount, adjustments) => Reader.asks(({ translate, translateMap, localeJoin, getInstanceById, }) => {
16
+ const getAttributeAbbreviation = (id) => translateMap(getInstanceById("Attribute", id)?.translations)
17
+ ?.abbreviation ?? MISSING_VALUE;
18
+ return {
19
+ label: translate("Attribute Adjustments"),
20
+ value: [
21
+ ...(adjustments.fixed?.map(adj => `${getAttributeAbbreviation(adj.id)} ${sign(adj.value)}`) ?? []),
22
+ ...(adjustments.selectable?.map(adj => `${adj.list.length === totalAttributesCount ? translate("one attribute of your choice") : localeJoin(adj.list.map(getAttributeAbbreviation), "disjunction")} ${sign(adj.value)}`) ?? []),
23
+ ].join("; "),
24
+ };
25
+ });
26
+ const renderVariantValues = (label, variants, selector, renderValue, translationSelector) => Reader.asks(({ translate, translateMap, localeCompare, localeJoin, }) => {
27
+ const values = variants.map(variant => {
28
+ const translation = translateMap(variant.translations);
29
+ return {
30
+ name: translation?.name ?? MISSING_VALUE,
31
+ value: selector(variant),
32
+ valueTranslation: translationSelector && translation !== undefined
33
+ ? translationSelector(translation)
34
+ : undefined,
35
+ };
36
+ });
37
+ const sameValues = anySameIndices(values, on(value => [value.value, value.valueTranslation], deepEqual));
38
+ if (sameValues.length === 1 && sameValues[0].length === values.length) {
39
+ return {
40
+ label: translate(label),
41
+ value: values[0] === undefined
42
+ ? MISSING_VALUE
43
+ : (values[0].valueTranslation ?? renderValue(values[0].value)),
44
+ };
45
+ }
46
+ else {
47
+ return {
48
+ label: translate(label),
49
+ value: [
50
+ {
51
+ type: "definitionList",
52
+ style: "nested",
53
+ items: Map.groupBy(values
54
+ .toSorted(on(item => item.name, localeCompare))
55
+ .map(value => ({
56
+ label: value.name,
57
+ value: value.valueTranslation ?? renderValue(value.value),
58
+ })), item => item.value)
59
+ .entries()
60
+ .map(([value, items]) => ({
61
+ label: localeJoin(items.map(item => item.label), "conjunction"),
62
+ value,
63
+ }))
64
+ .toArray(),
65
+ },
66
+ ],
67
+ };
68
+ }
69
+ });
70
+ const renderAutomaticAdvantagesOrDisadvantages = (entity, items) => Reader.asks(({ translate, translateMap, getInstanceById, localeCompare }) => items === undefined || !isNotEmpty(items)
71
+ ? translate("none")
72
+ : items
73
+ .map(item => {
74
+ const instanceTranslation = translateMap(getInstanceById(entity, item.id)?.translations);
75
+ return (instanceTranslation?.name_in_library ??
76
+ instanceTranslation?.name ??
77
+ MISSING_VALUE);
78
+ })
79
+ .toSorted(localeCompare)
80
+ .join(", "));
81
+ const renderCommonCultures = (items) => Reader.asks(({ translate, translateMap, getInstanceById, localeCompare }) => items === undefined || !isNotEmpty(items)
82
+ ? translate("none")
83
+ : items
84
+ .map(itemId => translateMap(getInstanceById("Culture", itemId)?.translations)
85
+ ?.name)
86
+ .filter(isNotNullish)
87
+ .toSorted(localeCompare)
88
+ .join(", "));
89
+ /**
90
+ * Get a JSON representation of the rules text for a race.
91
+ */
92
+ export const getRaceEntityDescription = createEntityDescriptionCreator(({ getInstanceById, countInstances, getChildInstancesForInstanceId }, { translate, translateMap, join: localeJoin, compare: localeCompare }, { id, content: entry }) => {
93
+ const translation = translateMap(entry.translations);
94
+ if (translation === undefined) {
95
+ return undefined;
96
+ }
97
+ const totalAttributesCount = countInstances("Attribute");
98
+ const raceVariants = getChildInstancesForInstanceId("RaceVariant", id).map(variant => variant.content);
99
+ const env = {
100
+ translate,
101
+ translateMap,
102
+ localeJoin,
103
+ localeCompare,
104
+ getInstanceById,
105
+ };
106
+ return {
107
+ title: translation.name,
108
+ className: "race",
109
+ body: [
110
+ {
111
+ type: "definitionList",
112
+ items: [
113
+ {
114
+ label: translate("AP Value"),
115
+ value: translate(".input {$value :number} {{{$value} Adventure Points}}", { value: entry.ap_value }),
116
+ },
117
+ renderBaseValueItem("Life Point Base Value", entry.base_values.life_points).run(env),
118
+ renderBaseValueItem("Spirit Base Value", entry.base_values.spirit).run(env),
119
+ renderBaseValueItem("Toughness Base Value", entry.base_values.toughness).run(env),
120
+ renderBaseValueItem("Movement Base Value", entry.base_values.movement).run(env),
121
+ renderAttributeAdjustmentsItem(totalAttributesCount, entry.attribute_adjustments).run(env),
122
+ renderVariantValues("Common Cultures", raceVariants, v => v.common_cultures, cultures => renderCommonCultures(cultures).run(env)).run(env),
123
+ entry.automatic_advantages === undefined
124
+ ? undefined
125
+ : renderValueWithPossibleTranslation("Automatic Advantages", entry.automatic_advantages, v => renderAutomaticAdvantagesOrDisadvantages("Advantage", v).run(env), translation.automatic_advantages).run(env),
126
+ entry.automatic_disadvantages === undefined
127
+ ? undefined
128
+ : renderValueWithPossibleTranslation("Automatic Disadvantages", entry.automatic_disadvantages, v => renderAutomaticAdvantagesOrDisadvantages("Disadvantage", v).run(env), translation.automatic_disadvantages).run(env),
129
+ entry.strongly_recommended_advantages === undefined &&
130
+ entry.strongly_recommended_disadvantages === undefined
131
+ ? undefined
132
+ : {
133
+ label: translate("Strongly recommended Advantages and Disadvantages"),
134
+ value: `${translate("The following advantages and disadvantages distinguish Aventurian {$race}. You should choose these advantages and disadvantages. If you don’t want to take them, talk to your GM.", { race: translation.name })} ${renderCommonnessRatedAdvantagesAndDisadvantages(entry.strongly_recommended_advantages, entry.strongly_recommended_disadvantages).run(env)}`,
135
+ },
136
+ renderVariantValues("Common Advantages", raceVariants, v => v.common_advantages, advs => renderCommonnessRatedAdvantagesOrDisadvantages("Advantage", advs).run(env), vt => vt.common_advantages).run(env),
137
+ renderVariantValues("Common Disadvantages", raceVariants, v => v.common_disadvantages, advs => renderCommonnessRatedAdvantagesOrDisadvantages("Disadvantage", advs).run(env), vt => vt.common_disadvantages).run(env),
138
+ renderVariantValues("Uncommon Advantages", raceVariants, v => v.uncommon_advantages, advs => renderCommonnessRatedAdvantagesOrDisadvantages("Advantage", advs).run(env), vt => vt.uncommon_advantages).run(env),
139
+ renderVariantValues("Uncommon Disadvantages", raceVariants, v => v.uncommon_disadvantages, advs => renderCommonnessRatedAdvantagesOrDisadvantages("Disadvantage", advs).run(env), vt => vt.uncommon_disadvantages).run(env),
140
+ ],
141
+ },
142
+ ],
143
+ errata: translation.errata,
144
+ references: entry.src,
145
+ };
146
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get a JSON representation of the rules text for a sex practice.
3
+ */
4
+ export declare const getSexPracticeEntityDescription: import("../creator.js").EntityDescriptionCreator<"SexPractice", {
5
+ getInstanceById: import("../helpers/getTypes.js").GetInstanceById<"Publication">;
6
+ }, import("../index.js").EntityDescription>;
@@ -0,0 +1,33 @@
1
+ import { createEntityDescriptionCreator } from "../creator.js";
2
+ /**
3
+ * Get a JSON representation of the rules text for a sex practice.
4
+ */
5
+ export const getSexPracticeEntityDescription = createEntityDescriptionCreator((_, { translate, translateMap }, { content: entry }) => {
6
+ const translation = translateMap(entry.translations);
7
+ if (translation === undefined) {
8
+ return undefined;
9
+ }
10
+ return {
11
+ title: translation.name,
12
+ className: "sex-practice",
13
+ body: [
14
+ {
15
+ type: "definitionList",
16
+ items: [
17
+ { label: translate("Rules"), value: translation.rules },
18
+ { label: translate("Duration"), value: translation.duration },
19
+ translation.prerequisites === undefined
20
+ ? undefined
21
+ : {
22
+ label: translate("Prerequisites"),
23
+ value: translation.prerequisites,
24
+ },
25
+ translation.failed === undefined
26
+ ? undefined
27
+ : { label: translate("Failed"), value: translation.failed },
28
+ ],
29
+ },
30
+ ],
31
+ references: entry.src,
32
+ };
33
+ });
@@ -1,13 +1,13 @@
1
- import { NewApplicationsAndUsesCache } from "optolith-database-schema/cache/newApplicationsAndUses";
2
- import { Skill } from "optolith-database-schema/types/Skill";
3
- import { All, GetById } from "../helpers/getTypes.js";
1
+ import type { ActivatableIdentifier } from "optolith-database-schema/gen";
2
+ import type { GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "../helpers/getTypes.js";
3
+ import type { GetAllResolvedNewSkillApplications, GetAllResolvedSkillUses } from "../index.js";
4
4
  /**
5
5
  * Get a JSON representation of the rules text for a skill.
6
6
  */
7
- export declare const getSkillEntityDescription: import("../index.js").EntityDescriptionCreator<Skill | undefined, {
8
- getAttributeById: GetById.Static.Attribute;
9
- blessedTraditions: All.Static.BlessedTraditions;
10
- diseases: All.Static.Diseases;
11
- regions: All.Static.Regions;
12
- cache: NewApplicationsAndUsesCache;
7
+ export declare const getSkillEntityDescription: import("../creator.js").EntityDescriptionCreator<"Skill", {
8
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | ActivatableIdentifier["kind"] | "Aspect">;
9
+ getAllInstances: GetAllInstances<"BlessedTradition" | "Disease" | "Region" | "SkillUse" | "NewSkillApplication">;
10
+ getChildInstancesForInstanceId: GetAllChildInstancesForParent<"SkillApplication">;
11
+ getAllResolvedNewSkillApplications: GetAllResolvedNewSkillApplications;
12
+ getAllResolvedSkillUses: GetAllResolvedSkillUses;
13
13
  }, import("../index.js").EntityDescription>;
@@ -1,109 +1,142 @@
1
1
  import { isNotNullish } from "@optolith/helpers/nullable";
2
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
- import { createEntityDescriptionCreator } from "../index.js";
4
- import { createImprovementCost } from "./partial/rated/improvementCost.js";
5
- import { getTextForCheck } from "./partial/rated/skillCheck.js";
3
+ import { fromUniformCase } from "tsondb/schema/gen";
4
+ import { createEntityDescriptionCreator } from "../creator.js";
5
+ import { renderImprovementCost } from "./partial/rated/improvementCost.js";
6
+ import { renderSkillCheck } from "./partial/rated/skillCheck.js";
7
+ const getUsesOrNewApplications = (getInstanceById, locale, items) => items
8
+ .map(x => {
9
+ const name = locale.translateMap(x.content.translations)?.name;
10
+ if (name !== undefined) {
11
+ return name;
12
+ }
13
+ const { parent: parentId } = x.content;
14
+ if (parentId.kind === "GeneralSelectOption") {
15
+ return undefined;
16
+ }
17
+ return locale.translateMap(getInstanceById(parentId.kind, fromUniformCase(parentId))?.translations)?.name;
18
+ // if (parentTranslations === undefined) {
19
+ // return undefined
20
+ // }
21
+ // return printActivatableNameChunk(
22
+ // locale,
23
+ // getNameComponents<BaseSpecialAbilityTranslation>(
24
+ // getInstanceById,
25
+ // locale,
26
+ // parentId,
27
+ // undefined,
28
+ // undefined,
29
+ // parentTranslations,
30
+ // translation => translation.name,
31
+ // id => getResolvedSelectOptionById(parentId, id),
32
+ // false,
33
+ // ).full,
34
+ // )
35
+ })
36
+ .filter(isNotNullish)
37
+ .sort(locale.compare);
6
38
  /**
7
39
  * Get a JSON representation of the rules text for a skill.
8
40
  */
9
- export const getSkillEntityDescription = createEntityDescriptionCreator(({ getAttributeById, blessedTraditions, diseases, regions, cache }, { translate, translateMap, compare: localeCompare }, entry) => {
41
+ export const getSkillEntityDescription = createEntityDescriptionCreator(({ getInstanceById, getAllInstances, getChildInstancesForInstanceId, getAllResolvedNewSkillApplications, getAllResolvedSkillUses, }, locale, { content: entry, id }) => {
42
+ const { translate, translateMap, compare: localeCompare } = locale;
10
43
  const translation = translateMap(entry.translations);
11
44
  if (translation === undefined) {
12
45
  return undefined;
13
46
  }
14
- const newApplications = (entry === undefined ? [] : cache.newApplications[entry.id] ?? [])
15
- .map((x) => translateMap(x.data.translations)?.name)
16
- .filter(isNotNullish)
17
- .sort(localeCompare);
18
- const uses = (entry === undefined ? [] : cache.uses[entry.id] ?? [])
19
- .map((x) => translateMap(x.data.translations)?.name)
20
- .filter(isNotNullish)
21
- .sort(localeCompare);
22
- const applications = (() => {
23
- switch (entry.applications.tag) {
24
- case "Derived":
25
- return (() => {
26
- switch (entry.applications.derived) {
27
- case "BlessedTraditions":
28
- return Object.values(blessedTraditions)
29
- .map((x) => translateMap(x.translations)?.name)
30
- .filter(isNotNullish)
31
- .sort(localeCompare);
32
- case "Diseases":
33
- return Object.values(diseases)
34
- .map((x) => translateMap(x.translations)?.name)
35
- .filter(isNotNullish)
36
- .sort(localeCompare);
37
- case "Regions":
38
- return Object.values(regions)
39
- .map((x) => translateMap(x.translations)?.name)
40
- .filter(isNotNullish)
41
- .sort(localeCompare);
42
- default:
43
- return assertExhaustive(entry.applications.derived);
44
- }
45
- })();
46
- case "Explicit":
47
- return entry.applications.explicit
48
- .map((x) => translateMap(x.translations)?.name)
49
- .filter(isNotNullish)
50
- .sort(localeCompare);
51
- default:
52
- return assertExhaustive(entry.applications);
53
- }
54
- })();
47
+ const newApplications = getUsesOrNewApplications(getInstanceById, locale, getAllResolvedNewSkillApplications(id));
48
+ const uses = getUsesOrNewApplications(getInstanceById, locale, getAllResolvedSkillUses(id));
49
+ const applications = [
50
+ ...getChildInstancesForInstanceId("SkillApplication", id)
51
+ .map(x => translateMap(x.content.translations)?.name)
52
+ .filter(isNotNullish)
53
+ .sort(localeCompare),
54
+ ...(() => {
55
+ switch (entry.applications.derived?.kind) {
56
+ case "BlessedTraditions":
57
+ return getAllInstances("BlessedTradition")
58
+ .map(x => translateMap(x.content.translations)?.name)
59
+ .filter(isNotNullish)
60
+ .sort(localeCompare);
61
+ case "Diseases":
62
+ return getAllInstances("Disease")
63
+ .map(x => translateMap(x.content.translations)?.name)
64
+ .filter(isNotNullish)
65
+ .sort(localeCompare);
66
+ case "Regions":
67
+ return getAllInstances("Region")
68
+ .map(x => translateMap(x.content.translations)?.name)
69
+ .filter(isNotNullish)
70
+ .sort(localeCompare);
71
+ case undefined:
72
+ return [];
73
+ default:
74
+ return assertExhaustive(entry.applications.derived);
75
+ }
76
+ })(),
77
+ ];
55
78
  return {
56
79
  title: translation.name,
57
80
  className: "skill",
58
81
  body: [
59
- newApplications.length === 0
60
- ? undefined
61
- : {
62
- label: translate("New Applications"),
63
- value: newApplications.join(", "),
64
- },
65
- uses.length === 0
66
- ? undefined
67
- : {
68
- label: translate("Uses"),
69
- value: uses.join(", "),
70
- },
71
- getTextForCheck({ translate, translateMap, getAttributeById }, entry.check),
72
- {
73
- label: translate("Applications"),
74
- value: applications.join(", "),
75
- },
76
- {
77
- label: translate("Encumbrance"),
78
- value: entry.encumbrance === "True"
79
- ? translate("Yes")
80
- : entry.encumbrance === "False"
81
- ? translate("No")
82
- : translation.encumbrance_description ?? translate("Maybe"),
83
- },
84
- translation?.tools === undefined
85
- ? undefined
86
- : {
87
- label: translate("Tools"),
88
- value: translation.tools,
89
- },
90
- {
91
- label: translate("Quality"),
92
- value: translation.quality,
93
- },
94
- {
95
- label: translate("Failed Check"),
96
- value: translation.failed,
97
- },
98
- {
99
- label: translate("Critical Success"),
100
- value: translation.critical,
101
- },
102
82
  {
103
- label: translate("Botch"),
104
- value: translation.botch,
83
+ type: "definitionList",
84
+ items: [
85
+ newApplications.length === 0
86
+ ? undefined
87
+ : {
88
+ label: translate("New Applications"),
89
+ value: newApplications.join(", "),
90
+ },
91
+ uses.length === 0
92
+ ? undefined
93
+ : {
94
+ label: translate("Uses"),
95
+ value: uses.join(", "),
96
+ },
97
+ renderSkillCheck(entry.check).run({
98
+ translate,
99
+ translateMap,
100
+ getInstanceById,
101
+ }),
102
+ {
103
+ label: translate("Applications"),
104
+ value: applications.join(", "),
105
+ },
106
+ {
107
+ label: translate("Encumbrance"),
108
+ value: entry.encumbrance.kind === "Yes"
109
+ ? translate("Yes")
110
+ : entry.encumbrance.kind === "No"
111
+ ? translate("No")
112
+ : (translation.encumbrance_description ??
113
+ translate("Maybe")),
114
+ },
115
+ translation?.tools === undefined
116
+ ? undefined
117
+ : {
118
+ label: translate("Tools"),
119
+ value: translation.tools,
120
+ },
121
+ {
122
+ label: translate("Quality"),
123
+ value: translation.quality,
124
+ },
125
+ {
126
+ label: translate("Failed Check"),
127
+ value: translation.failed,
128
+ },
129
+ {
130
+ label: translate("Critical Success"),
131
+ value: translation.critical,
132
+ },
133
+ {
134
+ label: translate("Botch"),
135
+ value: translation.botch,
136
+ },
137
+ renderImprovementCost(entry.improvement_cost).run({ translate }),
138
+ ],
105
139
  },
106
- createImprovementCost(translate, entry.improvement_cost),
107
140
  ],
108
141
  };
109
142
  });
@@ -1,38 +1,95 @@
1
- import { Cantrip } from "optolith-database-schema/types/Cantrip";
2
- import { DerivedCharacteristic } from "optolith-database-schema/types/DerivedCharacteristic";
3
- import { Ritual } from "optolith-database-schema/types/Ritual";
4
- import { Spell } from "optolith-database-schema/types/Spell";
5
- import { GetById } from "../helpers/getTypes.js";
1
+ import type { GetAllChildInstancesForParent, GetInstanceById } from "../helpers/getTypes.js";
2
+ import { type IdMap } from "../index.js";
6
3
  /**
7
4
  * Get a JSON representation of the rules text for a cantrip.
8
5
  */
9
- export declare const getCantripEntityDescription: import("../index.js").EntityDescriptionCreator<Cantrip | undefined, {
10
- getTargetCategoryById: GetById.Static.TargetCategory;
11
- getPropertyById: GetById.Static.Property;
12
- getMagicalTraditionById: GetById.Static.MagicalTradition;
13
- getCurriculumById: GetById.Static.Curriculum;
6
+ export declare const getCantripEntityDescription: import("../creator.js").EntityDescriptionCreator<"Cantrip", {
7
+ getInstanceById: GetInstanceById<"Publication" | "TargetCategory" | "Property" | "MagicalTradition" | "Curriculum">;
14
8
  }, import("../index.js").EntityDescription>;
15
9
  /**
16
10
  * Get a JSON representation of the rules text for a skill.
17
11
  */
18
- export declare const getSpellEntityDescription: import("../index.js").EntityDescriptionCreator<Spell | undefined, {
19
- getAttributeById: GetById.Static.Attribute;
20
- getSpirit: () => DerivedCharacteristic | undefined;
21
- getToughness: () => DerivedCharacteristic | undefined;
22
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
23
- getTargetCategoryById: GetById.Static.TargetCategory;
24
- getPropertyById: GetById.Static.Property;
25
- getMagicalTraditionById: GetById.Static.MagicalTradition;
12
+ export declare const getSpellEntityDescription: import("../creator.js").EntityDescriptionCreator<"Spell", {
13
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
14
+ idMap: IdMap;
26
15
  }, import("../index.js").EntityDescription>;
27
16
  /**
28
17
  * Get a JSON representation of the rules text for a ritual.
29
18
  */
30
- export declare const getRitualEntityDescription: import("../index.js").EntityDescriptionCreator<Ritual | undefined, {
31
- getAttributeById: GetById.Static.Attribute;
32
- getSpirit: () => DerivedCharacteristic | undefined;
33
- getToughness: () => DerivedCharacteristic | undefined;
34
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
35
- getTargetCategoryById: GetById.Static.TargetCategory;
36
- getPropertyById: GetById.Static.Property;
37
- getMagicalTraditionById: GetById.Static.MagicalTradition;
19
+ export declare const getRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"Ritual", {
20
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
21
+ idMap: IdMap;
22
+ }, import("../index.js").EntityDescription>;
23
+ /**
24
+ * Get a JSON representation of the rules text for a curse.
25
+ */
26
+ export declare const getCurseEntityDescription: import("../creator.js").EntityDescriptionCreator<"Curse", {
27
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic">;
28
+ idMap: IdMap;
29
+ }, import("../index.js").EntityDescription>;
30
+ /**
31
+ * Get a JSON representation of the rules text for an Elven magical song.
32
+ */
33
+ export declare const getElvenMagicalSongEntityDescription: import("../creator.js").EntityDescriptionCreator<"ElvenMagicalSong", {
34
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill">;
35
+ idMap: IdMap;
36
+ }, import("../index.js").EntityDescription>;
37
+ /**
38
+ * Get a JSON representation of the rules text for a domination ritual.
39
+ */
40
+ export declare const getDominationRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"DominationRitual", {
41
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "SkillModificationLevel">;
42
+ idMap: IdMap;
43
+ }, import("../index.js").EntityDescription>;
44
+ /**
45
+ * Get a JSON representation of the rules text for a magical dance.
46
+ */
47
+ export declare const getMagicalDanceEntityDescription: import("../creator.js").EntityDescriptionCreator<"MagicalDance", {
48
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "ArcaneBardTradition" | "ArcaneDancerTradition">;
49
+ }, import("../index.js").EntityDescription>;
50
+ /**
51
+ * Get a JSON representation of the rules text for a magical melody.
52
+ */
53
+ export declare const getMagicalMelodyEntityDescription: import("../creator.js").EntityDescriptionCreator<"MagicalMelody", {
54
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill" | "ArcaneBardTradition" | "ArcaneDancerTradition">;
55
+ }, import("../index.js").EntityDescription>;
56
+ /**
57
+ * Get a JSON representation of the rules text for a familiar’s trick.
58
+ */
59
+ export declare const getFamiliarsTrickEntityDescription: import("../creator.js").EntityDescriptionCreator<"FamiliarsTrick", {
60
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "AnimalType">;
61
+ }, import("../index.js").EntityDescription>;
62
+ /**
63
+ * Get a JSON representation of the rules text for a animist power.
64
+ */
65
+ export declare const getAnimistPowerEntityDescription: import("../creator.js").EntityDescriptionCreator<"AnimistPower", {
66
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | "AnimistPower" | "Tribe">;
67
+ }, import("../index.js").EntityDescription>;
68
+ /**
69
+ * Get a JSON representation of the rules text for a Goede ritual.
70
+ */
71
+ export declare const getGeodeRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"GeodeRitual", {
72
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | "Influence">;
73
+ }, import("../index.js").EntityDescription>;
74
+ /**
75
+ * Get a JSON representation of the rules text for a jester trick.
76
+ */
77
+ export declare const getJesterTrickEntityDescription: import("../creator.js").EntityDescriptionCreator<"JesterTrick", {
78
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
79
+ idMap: IdMap;
80
+ }, import("../index.js").EntityDescription>;
81
+ /**
82
+ * Get a JSON representation of the rules text for a Zibilja ritual.
83
+ */
84
+ export declare const getZibiljaRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"ZibiljaRitual", {
85
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
86
+ idMap: IdMap;
87
+ }, import("../index.js").EntityDescription>;
88
+ /**
89
+ * Get a JSON representation of the rules text for a magical rune.
90
+ */
91
+ export declare const getMagicalRuneEntityDescription: import("../creator.js").EntityDescriptionCreator<"MagicalRune", {
92
+ getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill">;
93
+ getChildInstancesForInstanceId: GetAllChildInstancesForParent<"MagicalRuneOption">;
94
+ idMap: IdMap;
38
95
  }, import("../index.js").EntityDescription>;