@optolith/entity-descriptions 0.1.1 → 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 (72) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/lib/entities/combatTechnique.d.ts +4 -4
  3. package/lib/entities/combatTechnique.js +7 -7
  4. package/lib/entities/experienceLevel.d.ts +1 -1
  5. package/lib/entities/experienceLevel.js +3 -3
  6. package/lib/entities/focusRule.d.ts +8 -0
  7. package/lib/entities/focusRule.js +18 -0
  8. package/lib/entities/liturgicalChant.d.ts +6 -6
  9. package/lib/entities/liturgicalChant.js +27 -56
  10. package/lib/entities/optionalRule.d.ts +5 -0
  11. package/lib/entities/optionalRule.js +16 -0
  12. package/lib/entities/partial/rated/activatable/castingTime.d.ts +3 -15
  13. package/lib/entities/partial/rated/activatable/castingTime.js +19 -34
  14. package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +1 -1
  15. package/lib/entities/partial/rated/activatable/checkResultBased.js +2 -2
  16. package/lib/entities/partial/rated/activatable/cost.d.ts +3 -19
  17. package/lib/entities/partial/rated/activatable/cost.js +82 -99
  18. package/lib/entities/partial/rated/activatable/duration.d.ts +5 -24
  19. package/lib/entities/partial/rated/activatable/duration.js +40 -57
  20. package/lib/entities/partial/rated/activatable/effect.d.ts +3 -3
  21. package/lib/entities/partial/rated/activatable/effect.js +7 -7
  22. package/lib/entities/partial/rated/activatable/index.d.ts +5 -33
  23. package/lib/entities/partial/rated/activatable/index.js +23 -41
  24. package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +20 -0
  25. package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +19 -0
  26. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +16 -0
  27. package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +55 -0
  28. package/lib/entities/partial/rated/activatable/parensIf.d.ts +1 -1
  29. package/lib/entities/partial/rated/activatable/parensIf.js +3 -1
  30. package/lib/entities/partial/rated/activatable/range.d.ts +4 -20
  31. package/lib/entities/partial/rated/activatable/range.js +59 -100
  32. package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
  33. package/lib/entities/partial/rated/activatable/speed.js +1 -1
  34. package/lib/entities/partial/rated/activatable/targetCategory.d.ts +3 -7
  35. package/lib/entities/partial/rated/activatable/targetCategory.js +30 -26
  36. package/lib/entities/partial/rated/improvementCost.d.ts +2 -2
  37. package/lib/entities/partial/rated/skillCheck.d.ts +2 -2
  38. package/lib/entities/partial/responsiveText.d.ts +7 -4
  39. package/lib/entities/partial/responsiveText.js +8 -2
  40. package/lib/entities/partial/units/energy.d.ts +12 -0
  41. package/lib/entities/partial/units/energy.js +30 -0
  42. package/lib/entities/partial/units/length.d.ts +8 -0
  43. package/lib/entities/partial/units/length.js +12 -0
  44. package/lib/entities/partial/units/timeSpan.d.ts +8 -0
  45. package/lib/entities/partial/units/timeSpan.js +22 -0
  46. package/lib/entities/skill.d.ts +2 -2
  47. package/lib/entities/skill.js +3 -3
  48. package/lib/entities/spell.d.ts +6 -6
  49. package/lib/entities/spell.js +27 -56
  50. package/lib/helpers/locale.d.ts +8 -0
  51. package/lib/helpers/locale.js +1 -0
  52. package/lib/index.d.ts +45 -1
  53. package/lib/index.js +22 -1
  54. package/lib/references/index.d.ts +4 -0
  55. package/lib/references/index.js +46 -0
  56. package/lib/references/occurrence.d.ts +4 -0
  57. package/lib/references/occurrence.js +3 -0
  58. package/lib/references/page.d.ts +23 -0
  59. package/lib/references/page.js +61 -0
  60. package/lib/references/pageRange.d.ts +30 -0
  61. package/lib/references/pageRange.js +58 -0
  62. package/package.json +7 -3
  63. package/lib/entities/partial/rated/activatable/isMaximum.d.ts +0 -6
  64. package/lib/entities/partial/rated/activatable/isMaximum.js +0 -10
  65. package/lib/entities/partial/rated/activatable/modifiableParameter.d.ts +0 -8
  66. package/lib/entities/partial/rated/activatable/modifiableParameter.js +0 -9
  67. package/lib/entities/partial/rated/activatable/nonModifiable.d.ts +0 -9
  68. package/lib/entities/partial/rated/activatable/nonModifiable.js +0 -75
  69. package/lib/entities/partial/rated/activatable/units.d.ts +0 -13
  70. package/lib/entities/partial/rated/activatable/units.js +0 -53
  71. package/lib/libraryEntry.d.ts +0 -52
  72. package/lib/libraryEntry.js +0 -17
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.2.0](https://github.com/Optolith/entity-descriptions/compare/v0.1.1...v0.2.0) (2024-10-07)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **npm:** define exports
11
+ * rename entity description creator exports to match previous renames
12
+ * remove partial application functionality from createEntityDescriptionCreator
13
+ * rename library entry to entity description to match repository
14
+
15
+ ### build
16
+
17
+ * **npm:** define exports ([52291cf](https://github.com/Optolith/entity-descriptions/commit/52291cf55342d700da972df8b67346f8304f7e13))
18
+
19
+
20
+ * remove partial application functionality from createEntityDescriptionCreator ([840510b](https://github.com/Optolith/entity-descriptions/commit/840510bad64c696f089fd025ebce05e68722b8ea))
21
+ * rename entity description creator exports to match previous renames ([e09c884](https://github.com/Optolith/entity-descriptions/commit/e09c884bddfebd68faf6263a1ce552b4d4e82965))
22
+ * rename library entry to entity description to match repository ([82878f8](https://github.com/Optolith/entity-descriptions/commit/82878f8ddce5f7c7db01c8b32af6435cb4e154c5))
23
+
24
+
25
+ ### Features
26
+
27
+ * add focus rule and optional rule description generators ([512c894](https://github.com/Optolith/entity-descriptions/commit/512c8940cfcae2ee19e51989de5aa5884c75e5ba))
28
+ * print references ([381394f](https://github.com/Optolith/entity-descriptions/commit/381394fd4efebd8fe4f6f3f8181557df83ffbefa))
29
+
5
30
  ## [0.1.1](https://github.com/Optolith/entity-descriptions/compare/v0.1.0...v0.1.1) (2024-10-04)
6
31
 
7
32
  ## 0.1.0 (2024-10-04)
@@ -4,12 +4,12 @@ import { GetById } from "../helpers/getTypes.js";
4
4
  /**
5
5
  * Get a JSON representation of the rules text for a close combat technique.
6
6
  */
7
- export declare const getCloseCombatTechniqueLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<CloseCombatTechnique | undefined, {
7
+ export declare const getCloseCombatTechniqueEntityDescription: import("../index.js").EntityDescriptionCreator<CloseCombatTechnique | undefined, {
8
8
  getAttributeById: GetById.Static.Attribute;
9
- }, import("../libraryEntry.js").LibraryEntry>;
9
+ }, import("../index.js").EntityDescription>;
10
10
  /**
11
11
  * Get a JSON representation of the rules text for a ranged combat technique.
12
12
  */
13
- export declare const getRangedCombatTechniqueLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<RangedCombatTechnique | undefined, {
13
+ export declare const getRangedCombatTechniqueEntityDescription: import("../index.js").EntityDescriptionCreator<RangedCombatTechnique | undefined, {
14
14
  getAttributeById: GetById.Static.Attribute;
15
- }, import("../libraryEntry.js").LibraryEntry>;
15
+ }, import("../index.js").EntityDescription>;
@@ -1,10 +1,10 @@
1
1
  import { mapNullable } from "@optolith/helpers/nullable";
2
- import { createLibraryEntryCreator } from "../libraryEntry.js";
2
+ import { createEntityDescriptionCreator } from "../index.js";
3
3
  import { createImprovementCost } from "./partial/rated/improvementCost.js";
4
4
  /**
5
5
  * Get a JSON representation of the rules text for a close combat technique.
6
6
  */
7
- export const getCloseCombatTechniqueLibraryEntry = createLibraryEntryCreator((entry, { getAttributeById }) => ({ translate, translateMap }) => {
7
+ export const getCloseCombatTechniqueEntityDescription = createEntityDescriptionCreator(({ getAttributeById }, { translate, translateMap }, entry) => {
8
8
  const translation = translateMap(entry.translations);
9
9
  if (translation === undefined) {
10
10
  return undefined;
@@ -12,7 +12,7 @@ export const getCloseCombatTechniqueLibraryEntry = createLibraryEntryCreator((en
12
12
  return {
13
13
  title: translation.name,
14
14
  className: "combat-technique close-combat-technique",
15
- content: [
15
+ body: [
16
16
  mapNullable(translation.special, (value) => ({
17
17
  label: translate("Special"),
18
18
  value,
@@ -26,13 +26,13 @@ export const getCloseCombatTechniqueLibraryEntry = createLibraryEntryCreator((en
26
26
  },
27
27
  createImprovementCost(translate, entry.improvement_cost),
28
28
  ],
29
- src: entry.src,
29
+ references: entry.src,
30
30
  };
31
31
  });
32
32
  /**
33
33
  * Get a JSON representation of the rules text for a ranged combat technique.
34
34
  */
35
- export const getRangedCombatTechniqueLibraryEntry = createLibraryEntryCreator((entry, { getAttributeById }) => ({ translate, translateMap }) => {
35
+ export const getRangedCombatTechniqueEntityDescription = createEntityDescriptionCreator(({ getAttributeById }, { translate, translateMap }, entry) => {
36
36
  const translation = translateMap(entry.translations);
37
37
  if (translation === undefined) {
38
38
  return undefined;
@@ -40,7 +40,7 @@ export const getRangedCombatTechniqueLibraryEntry = createLibraryEntryCreator((e
40
40
  return {
41
41
  title: translation.name,
42
42
  className: "combat-technique ranged-combat-technique",
43
- content: [
43
+ body: [
44
44
  mapNullable(translation.special, (value) => ({
45
45
  label: translate("Special"),
46
46
  value,
@@ -54,6 +54,6 @@ export const getRangedCombatTechniqueLibraryEntry = createLibraryEntryCreator((e
54
54
  },
55
55
  createImprovementCost(translate, entry.improvement_cost),
56
56
  ],
57
- src: entry.src,
57
+ references: entry.src,
58
58
  };
59
59
  });
@@ -2,4 +2,4 @@ import { ExperienceLevel } from "optolith-database-schema/types/ExperienceLevel"
2
2
  /**
3
3
  * Get a JSON representation of the rules text for an experience level.
4
4
  */
5
- export declare const getExperienceLevelLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<ExperienceLevel | undefined, undefined, import("../libraryEntry.js").LibraryEntry>;
5
+ export declare const getExperienceLevelEntityDescription: import("../index.js").EntityDescriptionCreator<ExperienceLevel | undefined, Record<string, never>, import("../index.js").EntityDescription>;
@@ -1,8 +1,8 @@
1
- import { createLibraryEntryCreator } from "../libraryEntry.js";
1
+ import { createEntityDescriptionCreator } from "../index.js";
2
2
  /**
3
3
  * Get a JSON representation of the rules text for an experience level.
4
4
  */
5
- export const getExperienceLevelLibraryEntry = createLibraryEntryCreator((entry) => ({ translate, translateMap }) => {
5
+ export const getExperienceLevelEntityDescription = createEntityDescriptionCreator((_, { translate, translateMap }, entry) => {
6
6
  const translation = translateMap(entry.translations);
7
7
  if (translation === undefined) {
8
8
  return undefined;
@@ -10,7 +10,7 @@ export const getExperienceLevelLibraryEntry = createLibraryEntryCreator((entry)
10
10
  return {
11
11
  title: translation.name,
12
12
  className: "experience-level",
13
- content: [
13
+ body: [
14
14
  {
15
15
  label: translate("Adventure Points"),
16
16
  value: entry.adventure_points,
@@ -0,0 +1,8 @@
1
+ import { FocusRule } from "optolith-database-schema/types/rule/FocusRule";
2
+ import { GetById } from "../helpers/getTypes.js";
3
+ /**
4
+ * Get a JSON representation of the rules text for a focus rule.
5
+ */
6
+ export declare const getFocusRuleEntityDescription: import("../index.js").EntityDescriptionCreator<FocusRule | undefined, {
7
+ getSubjectById: GetById.Static.Subject;
8
+ }, import("../index.js").EntityDescription>;
@@ -0,0 +1,18 @@
1
+ import { romanize } from "@optolith/helpers/roman";
2
+ import { createEntityDescriptionCreator } from "../index.js";
3
+ /**
4
+ * Get a JSON representation of the rules text for a focus rule.
5
+ */
6
+ export const getFocusRuleEntityDescription = createEntityDescriptionCreator(({ getSubjectById }, { translateMap }, entry) => {
7
+ const translation = translateMap(entry.translations);
8
+ if (translation === undefined) {
9
+ return undefined;
10
+ }
11
+ return {
12
+ title: `${translation.name} (${romanize(entry.level)})`,
13
+ subtitle: translateMap(getSubjectById(entry.subject.id.subject)?.translations)?.name,
14
+ className: "focus-rule",
15
+ body: [{ value: translation.description }],
16
+ references: entry.src,
17
+ };
18
+ });
@@ -6,13 +6,13 @@ import { GetById } from "../helpers/getTypes.js";
6
6
  /**
7
7
  * Get a JSON representation of the rules text for a blessing.
8
8
  */
9
- export declare const getBlessingLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<Blessing | undefined, {
9
+ export declare const getBlessingEntityDescription: import("../index.js").EntityDescriptionCreator<Blessing | undefined, {
10
10
  getTargetCategoryById: GetById.Static.TargetCategory;
11
- }, import("../libraryEntry.js").LibraryEntry>;
11
+ }, import("../index.js").EntityDescription>;
12
12
  /**
13
13
  * Get a JSON representation of the rules text for a liturgical chant.
14
14
  */
15
- export declare const getLiturgicalChantLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<LiturgicalChant | undefined, {
15
+ export declare const getLiturgicalChantEntityDescription: import("../index.js").EntityDescriptionCreator<LiturgicalChant | undefined, {
16
16
  getAttributeById: GetById.Static.Attribute;
17
17
  getSpirit: () => DerivedCharacteristic | undefined;
18
18
  getToughness: () => DerivedCharacteristic | undefined;
@@ -20,11 +20,11 @@ export declare const getLiturgicalChantLibraryEntry: import("../libraryEntry.js"
20
20
  getTargetCategoryById: GetById.Static.TargetCategory;
21
21
  getBlessedTraditionById: GetById.Static.BlessedTradition;
22
22
  getAspectById: GetById.Static.Aspect;
23
- }, import("../libraryEntry.js").LibraryEntry>;
23
+ }, import("../index.js").EntityDescription>;
24
24
  /**
25
25
  * Get a JSON representation of the rules text for a ceremony.
26
26
  */
27
- export declare const getCeremonyLibraryEntry: import("../libraryEntry.js").LibraryEntryCreator<Ceremony | undefined, {
27
+ export declare const getCeremonyEntityDescription: import("../index.js").EntityDescriptionCreator<Ceremony | undefined, {
28
28
  getAttributeById: GetById.Static.Attribute;
29
29
  getSpirit: () => DerivedCharacteristic | undefined;
30
30
  getToughness: () => DerivedCharacteristic | undefined;
@@ -32,4 +32,4 @@ export declare const getCeremonyLibraryEntry: import("../libraryEntry.js").Libra
32
32
  getTargetCategoryById: GetById.Static.TargetCategory;
33
33
  getBlessedTraditionById: GetById.Static.BlessedTradition;
34
34
  getAspectById: GetById.Static.Aspect;
35
- }, import("../libraryEntry.js").LibraryEntry>;
35
+ }, import("../index.js").EntityDescription>;
@@ -1,12 +1,12 @@
1
1
  import { isNotNullish } from "@optolith/helpers/nullable";
2
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
- import { createLibraryEntryCreator, } from "../libraryEntry.js";
4
- import { getTextForBlessingDuration } from "./partial/rated/activatable/duration.js";
3
+ import { createEntityDescriptionCreator, } from "../index.js";
4
+ import { getDurationTranslationForBlessing } from "./partial/rated/activatable/duration.js";
5
5
  import { getTextForEffect } from "./partial/rated/activatable/effect.js";
6
6
  import { Entity } from "./partial/rated/activatable/entity.js";
7
- import { getTextForFastOneTimePerformanceParameters, getTextForFastSustainedPerformanceParameters, getTextForSlowOneTimePerformanceParameters, getTextForSlowSustainedPerformanceParameters, } from "./partial/rated/activatable/index.js";
7
+ import { getFastOneTimePerformanceParametersTranslations, getFastSustainedPerformanceParametersTranslations, getSlowOneTimePerformanceParametersTranslations, getSlowSustainedPerformanceParametersTranslations, } from "./partial/rated/activatable/index.js";
8
8
  import { getTextForBlessingRange } from "./partial/rated/activatable/range.js";
9
- import { getTextForTargetCategory } from "./partial/rated/activatable/targetCategory.js";
9
+ import { getTargetCategoryTranslation } from "./partial/rated/activatable/targetCategory.js";
10
10
  import { createImprovementCost } from "./partial/rated/improvementCost.js";
11
11
  import { getTextForCheck } from "./partial/rated/skillCheck.js";
12
12
  import { ResponsiveTextSize } from "./partial/responsiveText.js";
@@ -46,21 +46,18 @@ const getTextForTraditions = (deps, values) => {
46
46
  /**
47
47
  * Get a JSON representation of the rules text for a blessing.
48
48
  */
49
- export const getBlessingLibraryEntry = createLibraryEntryCreator((entry, { getTargetCategoryById }) => ({ translate, translateMap }) => {
49
+ export const getBlessingEntityDescription = createEntityDescriptionCreator(({ getTargetCategoryById }, locale, entry) => {
50
+ const { translate, translateMap } = locale;
50
51
  const translation = translateMap(entry.translations);
51
52
  if (translation === undefined) {
52
53
  return undefined;
53
54
  }
54
- const range = getTextForBlessingRange({ translate }, entry.parameters.range, {
55
- responsiveText: ResponsiveTextSize.Full,
56
- });
57
- const duration = getTextForBlessingDuration({ translate, translateMap }, entry.parameters.duration, {
58
- responsiveText: ResponsiveTextSize.Full,
59
- });
55
+ const range = getTextForBlessingRange(locale, ResponsiveTextSize.Full, entry.parameters.range);
56
+ const duration = getDurationTranslationForBlessing(locale, ResponsiveTextSize.Full, entry.parameters.duration);
60
57
  return {
61
58
  title: translation.name,
62
59
  className: "blessing",
63
- content: [
60
+ body: [
64
61
  {
65
62
  label: translate("Effect"),
66
63
  value: translation.effect,
@@ -77,15 +74,16 @@ export const getBlessingLibraryEntry = createLibraryEntryCreator((entry, { getTa
77
74
  ? `***${duration}*** (${translation.duration})`
78
75
  : duration,
79
76
  },
80
- getTextForTargetCategory({ translate, translateMap, getTargetCategoryById }, entry.target),
77
+ getTargetCategoryTranslation(getTargetCategoryById, locale, entry.target),
81
78
  ],
82
- src: entry.src,
79
+ references: entry.src,
83
80
  };
84
81
  });
85
82
  /**
86
83
  * Get a JSON representation of the rules text for a liturgical chant.
87
84
  */
88
- export const getLiturgicalChantLibraryEntry = createLibraryEntryCreator((entry, { getAttributeById, getSpirit, getToughness, getSkillModificationLevelById, getTargetCategoryById, getBlessedTraditionById, getAspectById, }) => ({ translate, translateMap, localeCompare }) => {
85
+ export const getLiturgicalChantEntityDescription = createEntityDescriptionCreator(({ getAttributeById, getSpirit, getToughness, getSkillModificationLevelById, getTargetCategoryById, getBlessedTraditionById, getAspectById, }, locale, entry) => {
86
+ const { translate, translateMap, compare: localeCompare } = locale;
89
87
  const translation = translateMap(entry.translations);
90
88
  if (translation === undefined) {
91
89
  return undefined;
@@ -93,23 +91,9 @@ export const getLiturgicalChantLibraryEntry = createLibraryEntryCreator((entry,
93
91
  const { castingTime, cost, range, duration } = (() => {
94
92
  switch (entry.parameters.tag) {
95
93
  case "OneTime":
96
- return getTextForFastOneTimePerformanceParameters({
97
- getSkillModificationLevelById,
98
- translate,
99
- translateMap,
100
- }, entry.parameters.one_time, {
101
- entity: Entity.LiturgicalChant,
102
- responsiveText: ResponsiveTextSize.Full,
103
- });
94
+ return getFastOneTimePerformanceParametersTranslations(getSkillModificationLevelById, locale, Entity.LiturgicalChant, ResponsiveTextSize.Full, entry.parameters.one_time);
104
95
  case "Sustained":
105
- return getTextForFastSustainedPerformanceParameters({
106
- getSkillModificationLevelById,
107
- translate,
108
- translateMap,
109
- }, entry.parameters.sustained, {
110
- entity: Entity.LiturgicalChant,
111
- responsiveText: ResponsiveTextSize.Full,
112
- });
96
+ return getFastSustainedPerformanceParametersTranslations(getSkillModificationLevelById, locale, Entity.LiturgicalChant, ResponsiveTextSize.Full, entry.parameters.sustained);
113
97
  default:
114
98
  return assertExhaustive(entry.parameters);
115
99
  }
@@ -117,14 +101,14 @@ export const getLiturgicalChantLibraryEntry = createLibraryEntryCreator((entry,
117
101
  return {
118
102
  title: translation.name,
119
103
  className: "liturgical-chant",
120
- content: [
104
+ body: [
121
105
  getTextForCheck({ translate, translateMap, getAttributeById }, entry.check, {
122
106
  value: entry.check_penalty,
123
107
  responsiveText: ResponsiveTextSize.Full,
124
108
  getSpirit,
125
109
  getToughness,
126
110
  }),
127
- ...getTextForEffect(translation.effect, translate),
111
+ ...getTextForEffect(locale, translation.effect),
128
112
  {
129
113
  label: translate("Liturgical Time"),
130
114
  value: castingTime !== translation.casting_time.full
@@ -149,7 +133,7 @@ export const getLiturgicalChantLibraryEntry = createLibraryEntryCreator((entry,
149
133
  ? `***${duration}*** (${translation.duration.full})`
150
134
  : duration,
151
135
  },
152
- getTextForTargetCategory({ translate, translateMap, getTargetCategoryById }, entry.target),
136
+ getTargetCategoryTranslation(getTargetCategoryById, locale, entry.target),
153
137
  getTextForTraditions({
154
138
  translate,
155
139
  translateMap,
@@ -159,13 +143,14 @@ export const getLiturgicalChantLibraryEntry = createLibraryEntryCreator((entry,
159
143
  }, entry.traditions),
160
144
  createImprovementCost(translate, entry.improvement_cost),
161
145
  ],
162
- src: entry.src,
146
+ references: entry.src,
163
147
  };
164
148
  });
165
149
  /**
166
150
  * Get a JSON representation of the rules text for a ceremony.
167
151
  */
168
- export const getCeremonyLibraryEntry = createLibraryEntryCreator((entry, { getAttributeById, getSpirit, getToughness, getSkillModificationLevelById, getTargetCategoryById, getBlessedTraditionById, getAspectById, }) => ({ translate, translateMap, localeCompare }) => {
152
+ export const getCeremonyEntityDescription = createEntityDescriptionCreator(({ getAttributeById, getSpirit, getToughness, getSkillModificationLevelById, getTargetCategoryById, getBlessedTraditionById, getAspectById, }, locale, entry) => {
153
+ const { translate, translateMap, compare: localeCompare } = locale;
169
154
  const translation = translateMap(entry.translations);
170
155
  if (translation === undefined) {
171
156
  return undefined;
@@ -173,23 +158,9 @@ export const getCeremonyLibraryEntry = createLibraryEntryCreator((entry, { getAt
173
158
  const { castingTime, cost, range, duration } = (() => {
174
159
  switch (entry.parameters.tag) {
175
160
  case "OneTime":
176
- return getTextForSlowOneTimePerformanceParameters({
177
- getSkillModificationLevelById,
178
- translate,
179
- translateMap,
180
- }, entry.parameters.one_time, {
181
- entity: Entity.Ceremony,
182
- responsiveText: ResponsiveTextSize.Full,
183
- });
161
+ return getSlowOneTimePerformanceParametersTranslations(getSkillModificationLevelById, locale, Entity.Ritual, ResponsiveTextSize.Full, entry.parameters.one_time);
184
162
  case "Sustained":
185
- return getTextForSlowSustainedPerformanceParameters({
186
- getSkillModificationLevelById,
187
- translate,
188
- translateMap,
189
- }, entry.parameters.sustained, {
190
- entity: Entity.Ceremony,
191
- responsiveText: ResponsiveTextSize.Full,
192
- });
163
+ return getSlowSustainedPerformanceParametersTranslations(getSkillModificationLevelById, locale, Entity.Ceremony, ResponsiveTextSize.Full, entry.parameters.sustained);
193
164
  default:
194
165
  return assertExhaustive(entry.parameters);
195
166
  }
@@ -197,14 +168,14 @@ export const getCeremonyLibraryEntry = createLibraryEntryCreator((entry, { getAt
197
168
  return {
198
169
  title: translation.name,
199
170
  className: "ceremony",
200
- content: [
171
+ body: [
201
172
  getTextForCheck({ translate, translateMap, getAttributeById }, entry.check, {
202
173
  value: entry.check_penalty,
203
174
  responsiveText: ResponsiveTextSize.Full,
204
175
  getSpirit,
205
176
  getToughness,
206
177
  }),
207
- ...getTextForEffect(translation.effect, translate),
178
+ ...getTextForEffect(locale, translation.effect),
208
179
  {
209
180
  label: translate("Ceremonial Time"),
210
181
  value: castingTime !== translation.casting_time.full
@@ -229,7 +200,7 @@ export const getCeremonyLibraryEntry = createLibraryEntryCreator((entry, { getAt
229
200
  ? `***${duration}*** (${translation.duration.full})`
230
201
  : duration,
231
202
  },
232
- getTextForTargetCategory({ translate, translateMap, getTargetCategoryById }, entry.target),
203
+ getTargetCategoryTranslation(getTargetCategoryById, locale, entry.target),
233
204
  getTextForTraditions({
234
205
  translate,
235
206
  translateMap,
@@ -239,6 +210,6 @@ export const getCeremonyLibraryEntry = createLibraryEntryCreator((entry, { getAt
239
210
  }, entry.traditions),
240
211
  createImprovementCost(translate, entry.improvement_cost),
241
212
  ],
242
- src: entry.src,
213
+ references: entry.src,
243
214
  };
244
215
  });
@@ -0,0 +1,5 @@
1
+ import { OptionalRule } from "optolith-database-schema/types/rule/OptionalRule";
2
+ /**
3
+ * Get a JSON representation of the rules text for an optional rule.
4
+ */
5
+ export declare const getOptionalRuleEntityDescription: import("../index.js").EntityDescriptionCreator<OptionalRule | undefined, Record<string, never>, import("../index.js").EntityDescription>;
@@ -0,0 +1,16 @@
1
+ import { createEntityDescriptionCreator } from "../index.js";
2
+ /**
3
+ * Get a JSON representation of the rules text for an optional rule.
4
+ */
5
+ export const getOptionalRuleEntityDescription = createEntityDescriptionCreator((_, { translateMap }, entry) => {
6
+ const translation = translateMap(entry.translations);
7
+ if (translation === undefined) {
8
+ return undefined;
9
+ }
10
+ return {
11
+ title: translation.name,
12
+ className: "optional-rule",
13
+ body: [{ value: translation.description }],
14
+ references: entry.src,
15
+ };
16
+ });
@@ -1,25 +1,13 @@
1
1
  import { FastCastingTime, SlowCastingTime } from "optolith-database-schema/types/_ActivatableSkillCastingTime";
2
2
  import { GetById } from "../../../../helpers/getTypes.js";
3
- import { Translate } from "../../../../helpers/translate.js";
3
+ import { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import { ResponsiveTextSize } from "../../responsiveText.js";
5
5
  import { Entity } from "./entity.js";
6
6
  /**
7
7
  * Get the text for the casting time of a fast activatable skill.
8
8
  */
9
- export declare const getTextForFastCastingTime: (deps: {
10
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
11
- translate: Translate;
12
- }, value: FastCastingTime, env: {
13
- entity: Entity;
14
- responsiveText: ResponsiveTextSize;
15
- }) => string;
9
+ export declare const getFastCastingTimeTranslation: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: FastCastingTime) => string;
16
10
  /**
17
11
  * Get the text for the casting time of a slow activatable skill.
18
12
  */
19
- export declare const getTextForSlowCastingTime: (deps: {
20
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
21
- translate: Translate;
22
- }, value: SlowCastingTime, env: {
23
- entity: Entity;
24
- responsiveText: ResponsiveTextSize;
25
- }) => string;
13
+ export declare const getSlowCastingTimeTranslation: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: SlowCastingTime) => string;
@@ -1,50 +1,35 @@
1
1
  import { isNotNullish, mapNullable } from "@optolith/helpers/nullable";
2
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
+ import { formatTimeSpan } from "../../units/timeSpan.js";
3
4
  import { MISSING_VALUE } from "../../unknown.js";
4
- import { ModifiableParameter } from "./modifiableParameter.js";
5
- import { getTextForNonModifiableSuffix } from "./nonModifiable.js";
6
- import { Speed } from "./speed.js";
7
- import { formatTimeSpan } from "./units.js";
8
- const getTextForModifiableCastingTime = (deps, value, env) => mapNullable(deps.getSkillModificationLevelById(value.initial_modification_level), ({ fast: { casting_time: fastTime }, slow: { casting_time: slowTime }, }) => {
9
- switch (env.speed) {
10
- case Speed.Fast:
11
- return formatTimeSpan(deps.translate, env.responsiveText, "Actions", fastTime);
12
- case Speed.Slow:
13
- return formatTimeSpan(deps.translate, env.responsiveText, slowTime.unit, slowTime.value);
14
- default:
15
- return assertExhaustive(env.speed);
16
- }
17
- }) ?? MISSING_VALUE;
18
- const getTextForFastSkillNonModifiableCastingTime = (deps, value, env) => formatTimeSpan(deps.translate, env.responsiveText, "Actions", value.actions) +
19
- getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.CastingTime, env.responsiveText);
20
- const getTextForSlowSkillNonModifiableCastingTime = (deps, value, env) => formatTimeSpan(deps.translate, env.responsiveText, value.unit, value.value) +
21
- getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.CastingTime, env.responsiveText);
22
- const getTextForCastingTime = (deps, value, env, getTextForNonModifiableCastingTime) => {
5
+ import { getNonModifiableSuffixTranslation, ModifiableParameter, } from "./nonModifiableSuffix.js";
6
+ import { getModifiableBySpeed, Speed } from "./speed.js";
7
+ const getModifiableCastingTimeTranslation = (getSkillModificationLevelById, locale, speed, responsiveTextSize, value) => mapNullable(getSkillModificationLevelById(value.initial_modification_level), (modificationLevel) => getModifiableBySpeed((config) => formatTimeSpan(locale, responsiveTextSize, "Actions", config.casting_time), (config) => formatTimeSpan(locale, responsiveTextSize, config.casting_time.unit, config.casting_time.value), speed, modificationLevel)) ?? MISSING_VALUE;
8
+ const getFastSkillNonModifiableCastingTimeTranslation = (locale, responsiveTextSize, value) => formatTimeSpan(locale, responsiveTextSize, "Actions", value.actions);
9
+ const getSlowSkillNonModifiableCastingTimeTranslation = (locale, responsiveTextSize, value) => formatTimeSpan(locale, responsiveTextSize, value.unit, value.value);
10
+ const getCastingTimeTranslation = (getNonModifiableCastingTimeTranslation, getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => {
23
11
  switch (value.tag) {
24
12
  case "Modifiable":
25
- return getTextForModifiableCastingTime(deps, value.modifiable, env);
13
+ return getModifiableCastingTimeTranslation(getSkillModificationLevelById, locale, speed, responsiveTextSize, value.modifiable);
26
14
  case "NonModifiable":
27
- return getTextForNonModifiableCastingTime(value.non_modifiable);
15
+ return (getNonModifiableCastingTimeTranslation(value.non_modifiable) +
16
+ getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.CastingTime, responsiveTextSize));
28
17
  default:
29
18
  return assertExhaustive(value);
30
19
  }
31
20
  };
32
- const getTextForCastingTimeDuringLovemaking = (deps, value, env) => formatTimeSpan(deps.translate, env.responsiveText, value.unit, value.value);
33
- /**
34
- * Get the text for the casting time of a fast activatable skill.
35
- */
36
- export const getTextForFastCastingTime = (deps, value, env) => [
37
- mapNullable(value.default, (def) => getTextForCastingTime(deps, def, { ...env, speed: Speed.Fast }, (nonModifiableValue) => getTextForFastSkillNonModifiableCastingTime(deps, nonModifiableValue, env))),
38
- mapNullable(value.during_lovemaking, (duringLovemaking) => getTextForCastingTimeDuringLovemaking(deps, duringLovemaking, env)),
21
+ const getCastingTimeDuringLovemakingTranslation = (locale, responsiveTextSize, value) => formatTimeSpan(locale, responsiveTextSize, value.unit, value.value);
22
+ const getCastingTimeIncludingLovemakingTranslation = (getNonModifiableCastingTimeTranslation, getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => [
23
+ mapNullable(value.default, (def) => getCastingTimeTranslation(getNonModifiableCastingTimeTranslation, getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, def)),
24
+ mapNullable(value.during_lovemaking, (duringLovemaking) => getCastingTimeDuringLovemakingTranslation(locale, responsiveTextSize, duringLovemaking)),
39
25
  ]
40
26
  .filter(isNotNullish)
41
27
  .join(" / ");
28
+ /**
29
+ * Get the text for the casting time of a fast activatable skill.
30
+ */
31
+ export const getFastCastingTimeTranslation = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => getCastingTimeIncludingLovemakingTranslation((nonModifiableValue) => getFastSkillNonModifiableCastingTimeTranslation(locale, responsiveTextSize, nonModifiableValue), getSkillModificationLevelById, locale, Speed.Fast, entity, responsiveTextSize, value);
42
32
  /**
43
33
  * Get the text for the casting time of a slow activatable skill.
44
34
  */
45
- export const getTextForSlowCastingTime = (deps, value, env) => [
46
- mapNullable(value.default, (def) => getTextForCastingTime(deps, def, { ...env, speed: Speed.Slow }, (nonModifiableValue) => getTextForSlowSkillNonModifiableCastingTime(deps, nonModifiableValue, env))),
47
- mapNullable(value.during_lovemaking, (duringLovemaking) => getTextForCastingTimeDuringLovemaking(deps, duringLovemaking, env)),
48
- ]
49
- .filter(isNotNullish)
50
- .join(" / ");
35
+ export const getSlowCastingTimeTranslation = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => getCastingTimeIncludingLovemakingTranslation((nonModifiableValue) => getSlowSkillNonModifiableCastingTimeTranslation(locale, responsiveTextSize, nonModifiableValue), getSkillModificationLevelById, locale, Speed.Slow, entity, responsiveTextSize, value);
@@ -4,4 +4,4 @@ import { Translate } from "../../../../helpers/translate.js";
4
4
  * Returns the value text for a check-result-based parameter of an activatable
5
5
  * skill.
6
6
  */
7
- export declare const getTextForCheckResultBased: (value: CheckResultBased, translate: Translate) => string;
7
+ export declare const getCheckResultBasedValueTranslation: (translate: Translate, value: CheckResultBased) => string;
@@ -1,6 +1,6 @@
1
1
  import { mapNullableDefault } from "@optolith/helpers/nullable";
2
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
- const getCheckResultBaseValue = (baseValue, translate) => {
3
+ const getCheckResultBaseValueTranslation = (translate, baseValue) => {
4
4
  switch (baseValue) {
5
5
  case "QualityLevels":
6
6
  return translate("QL");
@@ -24,5 +24,5 @@ const getArithmeticSymbol = (arithmetic) => {
24
24
  * Returns the value text for a check-result-based parameter of an activatable
25
25
  * skill.
26
26
  */
27
- export const getTextForCheckResultBased = (value, translate) => getCheckResultBaseValue(value.base, translate) +
27
+ export const getCheckResultBasedValueTranslation = (translate, value) => getCheckResultBaseValueTranslation(translate, value.base) +
28
28
  mapNullableDefault(value.modifier, (modifier) => getArithmeticSymbol(modifier.arithmetic) + modifier.value, "");
@@ -1,30 +1,14 @@
1
1
  import { OneTimeCost, SustainedCost } from "optolith-database-schema/types/_ActivatableSkillCost";
2
2
  import { GetById } from "../../../../helpers/getTypes.js";
3
- import { Translate, TranslateMap } from "../../../../helpers/translate.js";
3
+ import { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import { ResponsiveTextSize } from "../../responsiveText.js";
5
5
  import { Entity } from "./entity.js";
6
6
  import { Speed } from "./speed.js";
7
7
  /**
8
8
  * Returns the text for the cost of a one-time activatable skill.
9
9
  */
10
- export declare const getTextForOneTimeCost: (deps: {
11
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
12
- translate: Translate;
13
- translateMap: TranslateMap;
14
- }, value: OneTimeCost, env: {
15
- speed: Speed;
16
- responsiveText: ResponsiveTextSize;
17
- entity: Entity;
18
- }) => string;
10
+ export declare const getOneTimeCostTranslation: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, speed: Speed, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: OneTimeCost) => string;
19
11
  /**
20
12
  * Returns the text for the cost of a sustained activatable skill.
21
13
  */
22
- export declare const getTextForSustainedCost: (deps: {
23
- getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
24
- translate: Translate;
25
- translateMap: TranslateMap;
26
- }, value: SustainedCost, env: {
27
- speed: Speed;
28
- responsiveText: ResponsiveTextSize;
29
- entity: Entity;
30
- }) => string;
14
+ export declare const getSustainedCostTranslation: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, speed: Speed, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: SustainedCost) => string;