@optolith/entity-descriptions 0.4.26 → 0.6.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 (31) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/entities/activatable.d.ts +3 -3
  3. package/lib/entities/activatable.js +60 -29
  4. package/lib/entities/equipment.d.ts +2 -2
  5. package/lib/entities/equipment.js +7 -7
  6. package/lib/entities/liturgicalChant.js +19 -12
  7. package/lib/entities/partial/enhancements.js +2 -2
  8. package/lib/entities/partial/map.d.ts +25 -36
  9. package/lib/entities/partial/map.js +16 -15
  10. package/lib/entities/partial/prerequisites/prerequisiteGroups.js +9 -2
  11. package/lib/entities/partial/prerequisites/single/enhancement.d.ts +7 -3
  12. package/lib/entities/partial/prerequisites/single/enhancement.js +19 -25
  13. package/lib/entities/partial/rated/activatable/castingTime.d.ts +5 -5
  14. package/lib/entities/partial/rated/activatable/castingTime.js +6 -3
  15. package/lib/entities/partial/rated/activatable/cost.d.ts +20 -14
  16. package/lib/entities/partial/rated/activatable/cost.js +62 -27
  17. package/lib/entities/partial/rated/activatable/duration.d.ts +3 -3
  18. package/lib/entities/partial/rated/activatable/index.d.ts +6 -6
  19. package/lib/entities/partial/rated/activatable/index.js +4 -4
  20. package/lib/entities/partial/reader.d.ts +10 -0
  21. package/lib/entities/partial/reader.js +5 -1
  22. package/lib/entities/partial/units/timeSpan.d.ts +23 -15
  23. package/lib/entities/partial/units/timeSpan.js +17 -3
  24. package/lib/entities/poison.js +9 -9
  25. package/lib/entities/profession.js +17 -15
  26. package/lib/entities/spell.js +34 -18
  27. package/lib/helpers/enums.d.ts +2 -1
  28. package/lib/helpers/enums.js +1 -3
  29. package/lib/index.d.ts +56 -56
  30. package/lib/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +11 -10
@@ -82,7 +82,10 @@ export const printGeneralPrerequisiteGroup = (getInstanceById, getResolvedSelect
82
82
  case "RatedSum":
83
83
  return printRatedSumPrerequisite(getInstanceById, locale, prerequisite.RatedSum);
84
84
  case "Enhancement":
85
- return printEnhancementPrerequisite(getInstanceById, locale, prerequisite.Enhancement);
85
+ return printEnhancementPrerequisite(prerequisite.Enhancement).run({
86
+ ...locale,
87
+ getInstanceById,
88
+ });
86
89
  case "Text":
87
90
  return printTextPrerequisite(locale, prerequisite.Text);
88
91
  case "SexualCharacteristic":
@@ -262,7 +265,11 @@ export const printEnhancementPrerequisiteGroup = (getInstanceById, locale, prere
262
265
  case "Rated":
263
266
  return printRatedPrerequisite(getInstanceById, locale, prerequisite.Rated);
264
267
  case "Enhancement":
265
- return printEnhancementPrerequisite(getInstanceById, locale, prerequisite.Enhancement);
268
+ return printEnhancementPrerequisite(prerequisite.Enhancement).run({
269
+ ...locale,
270
+ getInstanceById,
271
+ hideParent: true,
272
+ });
266
273
  default:
267
274
  return assertExhaustive(prerequisite);
268
275
  }
@@ -1,8 +1,12 @@
1
+ import { Reader } from "@elyukai/utils/reader";
1
2
  import type { EnhancementPrerequisite } from "@optolith/database-schema/gen";
2
- import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
- import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
+ import { type StdEnv } from "../../reader.js";
4
4
  import type { PrerequisitePart } from "../part.js";
5
+ type EnvExtra = {
6
+ hideParent?: true;
7
+ };
5
8
  /**
6
9
  * Get the translation of an external enhancement prerequisite.
7
10
  */
8
- export declare const printEnhancementPrerequisite: (getInstanceById: GetInstanceById<"Spell" | "Ritual" | "LiturgicalChant" | "Ceremony" | "Enhancement">, locale: Pick<LocaleEnvironment, "translate" | "translateMap">, prerequisite: EnhancementPrerequisite) => PrerequisitePart | undefined;
11
+ export declare const printEnhancementPrerequisite: (prerequisite: EnhancementPrerequisite) => Reader<StdEnv<"t" | "tm" | "ibi", "Enhancement" | "Spell" | "Ritual" | "LiturgicalChant" | "Ceremony"> & EnvExtra, PrerequisitePart | undefined>;
12
+ export {};
@@ -1,41 +1,35 @@
1
+ import { Reader } from "@elyukai/utils/reader";
1
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
+ import { fromUniformCase } from "tsondb/schema/gen";
4
+ import { attributedNameFromInstanceR, getInstanceByIdR, translateR, } from "../../reader.js";
2
5
  import { MISSING_VALUE } from "../../unknown.js";
3
- const printLabel = (locale, skillId) => {
6
+ const printLabel = (skillId) => {
4
7
  switch (skillId.kind) {
5
8
  case "Spell":
6
9
  case "Ritual":
7
- return locale.translate("spell enhancement");
10
+ return translateR("spell enhancement");
8
11
  case "LiturgicalChant":
9
12
  case "Ceremony":
10
- return locale.translate("liturgical enhancement");
13
+ return translateR("liturgical enhancement");
11
14
  default:
12
15
  return assertExhaustive(skillId);
13
16
  }
14
17
  };
15
- const getSkill = (getInstanceById, parentId) => {
16
- switch (parentId.kind) {
17
- case "Spell":
18
- return getInstanceById("Spell", parentId.Spell);
19
- case "Ritual":
20
- return getInstanceById("Ritual", parentId.Ritual);
21
- case "LiturgicalChant":
22
- return getInstanceById("LiturgicalChant", parentId.LiturgicalChant);
23
- case "Ceremony":
24
- return getInstanceById("Ceremony", parentId.Ceremony);
25
- default:
26
- return assertExhaustive(parentId);
27
- }
28
- };
29
18
  /**
30
19
  * Get the translation of an external enhancement prerequisite.
31
20
  */
32
- export const printEnhancementPrerequisite = (getInstanceById, locale, prerequisite) => {
33
- const enhancement = getInstanceById("Enhancement", prerequisite.id);
34
- const skill = enhancement && getSkill(getInstanceById, enhancement.parent);
35
- return {
36
- label: `${enhancement ? printLabel(locale, enhancement.parent) : MISSING_VALUE} `,
37
- value: `*${locale.translateMap(enhancement?.translations)?.name ?? MISSING_VALUE}* ${locale.translate("for")} ${locale.translateMap(skill?.translations)?.name ?? MISSING_VALUE}`,
21
+ export const printEnhancementPrerequisite = (prerequisite) => getInstanceByIdR("Enhancement", prerequisite.id).thenW(enhancement => enhancement === undefined
22
+ ? Reader.of(undefined)
23
+ : getInstanceByIdR(enhancement.parent).thenW(skill => printLabel(enhancement.parent).thenW(label => Reader.asks((env) => env.hideParent ?? false).thenW(hideParent => attributedNameFromInstanceR(enhancement, "prerequisite", "Enhancement", prerequisite.id)
24
+ .map(name => name ?? MISSING_VALUE)
25
+ .thenW(name => hideParent
26
+ ? Reader.of(name)
27
+ : attributedNameFromInstanceR(skill, "prerequisite", enhancement.parent.kind, fromUniformCase(enhancement.parent))
28
+ .map(skillName => skillName ?? MISSING_VALUE)
29
+ .thenW(skillName => translateR("for").map(forText => `${name} ${forText} ${skillName}`)))
30
+ .map((value) => ({
31
+ label: `${label} `,
32
+ value,
38
33
  sentenceType: undefined,
39
34
  isMeta: false,
40
- };
41
- };
35
+ }))))));
@@ -3,20 +3,20 @@ import { type StdReader } from "../../reader.js";
3
3
  /**
4
4
  * Renders the text for a non-modifiable casting time of a fast activatable skill.
5
5
  */
6
- export declare const renderFastSkillNonModifiableCastingTime: (value: FastSkillNonModifiableCastingTime) => StdReader<string, "t" | "rts">;
6
+ export declare const renderFastSkillNonModifiableCastingTime: (value: FastSkillNonModifiableCastingTime) => StdReader<string, "t" | "tm" | "f" | "rts">;
7
7
  /**
8
8
  * Get the text for a non-modifiable casting time of a slow activatable skill.
9
9
  */
10
- export declare const renderSlowSkillNonModifiableCastingTime: (value: SlowSkillNonModifiableCastingTime) => StdReader<string, "t" | "rts">;
10
+ export declare const renderSlowSkillNonModifiableCastingTime: (value: SlowSkillNonModifiableCastingTime) => StdReader<string, "t" | "tm" | "f" | "rts">;
11
11
  /**
12
12
  * Translate casting time.
13
13
  */
14
- export declare const renderCastingTime: <NonModifiable extends object>(renderNonModifiableCastingTime: (value: NonModifiable) => StdReader<string, "t" | "rts" | "s" | "nms">, value: CastingTime<NonModifiable>) => StdReader<string, "t" | "rts" | "s" | "nms" | "ibi", "SkillModificationLevel">;
14
+ export declare const renderCastingTime: <NonModifiable extends object>(renderNonModifiableCastingTime: (value: NonModifiable) => StdReader<string, "t" | "tm" | "f" | "rts" | "s" | "nms">, value: CastingTime<NonModifiable>) => StdReader<string, "t" | "tm" | "f" | "rts" | "s" | "nms" | "ibi", "SkillModificationLevel">;
15
15
  /**
16
16
  * Get the text for the casting time of a fast activatable skill.
17
17
  */
18
- export declare const renderFastCastingTime: (value: FastCastingTime) => StdReader<string, "t" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
18
+ export declare const renderFastCastingTime: (value: FastCastingTime) => StdReader<string, "t" | "tm" | "f" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
19
19
  /**
20
20
  * Get the text for the casting time of a slow activatable skill.
21
21
  */
22
- export declare const renderSlowCastingTime: (value: SlowCastingTime) => StdReader<string, "t" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
22
+ export declare const renderSlowCastingTime: (value: SlowCastingTime) => StdReader<string, "t" | "tm" | "f" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
@@ -3,6 +3,7 @@ import { isNotNullish, mapNullable } from "@optolith/helpers/nullable";
3
3
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
4
4
  import { Case } from "../../../../helpers/enums.js";
5
5
  import { getInstanceByIdFnR, modifiableBySpeedR } from "../../reader.js";
6
+ import { appendNoteIfNeeded } from "../../responsiveText.js";
6
7
  import { formatCombinedTimeSpanR, formatTimeSpanR } from "../../units/timeSpan.js";
7
8
  import { MISSING_VALUE } from "../../unknown.js";
8
9
  import { appendNonModifiableSuffix, ModifiableParameter } from "./nonModifiableSuffix.js";
@@ -10,16 +11,18 @@ import { Speed } from "./speed.js";
10
11
  const deriveModifiableCastingTime = (modificationLevelId) => getInstanceByIdFnR().thenW(getInstanceById => mapNullable(getInstanceById("SkillModificationLevel", modificationLevelId), modificationLevel => modifiableBySpeedR("casting_time", modificationLevel).map(castingTime => typeof castingTime === "number"
11
12
  ? { value: castingTime, unit: Case("Actions") }
12
13
  : castingTime)) ?? Reader.of(undefined));
13
- const renderModifiableCastingTime = (value) => deriveModifiableCastingTime(value.initial_modification_level).thenW(castingTime => castingTime === undefined ? Reader.of(MISSING_VALUE) : formatCombinedTimeSpanR(castingTime));
14
+ const renderModifiableCastingTime = (value) => deriveModifiableCastingTime(value.initial_modification_level)
15
+ .thenW(castingTime => castingTime === undefined ? Reader.of(MISSING_VALUE) : formatCombinedTimeSpanR(castingTime))
16
+ .thenW(text => appendNoteIfNeeded(value.translations, text));
14
17
  const renderCastingTimeDuringLovemaking = (value) => formatCombinedTimeSpanR(value);
15
18
  /**
16
19
  * Renders the text for a non-modifiable casting time of a fast activatable skill.
17
20
  */
18
- export const renderFastSkillNonModifiableCastingTime = (value) => formatTimeSpanR(Case("Actions"), value.actions);
21
+ export const renderFastSkillNonModifiableCastingTime = (value) => formatTimeSpanR(Case("Actions"), value.actions).thenW(text => appendNoteIfNeeded(value.translations, text));
19
22
  /**
20
23
  * Get the text for a non-modifiable casting time of a slow activatable skill.
21
24
  */
22
- export const renderSlowSkillNonModifiableCastingTime = (value) => formatCombinedTimeSpanR(value);
25
+ export const renderSlowSkillNonModifiableCastingTime = (value) => formatCombinedTimeSpanR(value).thenW(text => appendNoteIfNeeded(value.translations, text));
23
26
  /**
24
27
  * Translate casting time.
25
28
  */
@@ -1,8 +1,7 @@
1
1
  import { Reader } from "@elyukai/utils/reader";
2
- import type { CheckResultBasedModifier, DurationUnitValue, ElvenMagicalSongPermanentCost, FirstPersonMagicalMelodyCost, NonModifiableOneTimeCostPerCountable, NonModifiableSustainedCost, OneTimeCost, OneTimeCostMap, ResponsiveText, ResponsiveTextOptional, ResponsiveTextReplace, SkillModificationLevel_ID, SustainedCost } from "@optolith/database-schema/gen";
3
- import { type LocaleMap, type Translate } from "../../../../helpers/translate.js";
2
+ import type { CheckResultBasedModifier, DurationUnitValue, ElvenMagicalSongPermanentCost, FirstPersonMagicalMelodyCost, NonModifiableOneTimeCostPerCountable, NonModifiableSustainedCost, OneTimeCost, ResponsiveText, ResponsiveTextOptional, ResponsiveTextReplace, SkillModificationLevel_ID, StandaloneCostMap, SustainedCost } from "@optolith/database-schema/gen";
3
+ import { type LocaleMap } from "../../../../helpers/translate.js";
4
4
  import { type StdEnv, type StdReader } from "../../reader.js";
5
- import { type ResponsiveTextSize } from "../../responsiveText.js";
6
5
  /**
7
6
  * Returns the text for the modifiable one-time cost of an activatable skill.
8
7
  */
@@ -29,7 +28,7 @@ type NonModifiableOneTimeCost = {
29
28
  /**
30
29
  * Returns the text for a non-modifiable one-time cost of an activatable skill.
31
30
  */
32
- export declare const renderNonModifiableOneTimeCost: (value: NonModifiableOneTimeCost, shouldAppendNonModifiableSuffix: boolean) => StdReader<string, "t" | "tm" | "rts" | "eu" | "nms" | "lj">;
31
+ export declare const renderNonModifiableOneTimeCost: (value: NonModifiableOneTimeCost, shouldAppendNonModifiableSuffix: boolean) => StdReader<string, "t" | "tm" | "f" | "rts" | "eu" | "nms" | "lj">;
33
32
  type IndefiniteCost = {
34
33
  modifier?: CheckResultBasedModifier;
35
34
  translations: LocaleMap<{
@@ -41,27 +40,34 @@ type IndefiniteCost = {
41
40
  */
42
41
  export declare const renderIndefiniteCost: (value: IndefiniteCost, shouldAppendNonModifiableSuffix: boolean) => StdReader<string, "t" | "tm" | "rts" | "eu" | "nms">;
43
42
  /**
44
- * Returns the text for a one-time cost map of an activatable skill.
43
+ * Returns the text for a standalone one-time cost map of an activatable skill.
45
44
  */
46
- export declare const renderOneTimeCostMap: (value: OneTimeCostMap) => StdReader<string, "t" | "tm" | "rts" | "nms" | "eu">;
45
+ export declare const renderStandaloneCostMap: (value: StandaloneCostMap) => Reader<StdEnv<"tm" | "t" | "rts"> & {
46
+ translate: import("../../../../helpers/translate.js").Translate;
47
+ energyUnit: import("../../units/energy.js").EnergyUnit;
48
+ }, string>;
47
49
  /**
48
50
  * Returns the text for the cost of a one-time activatable skill.
49
51
  */
50
- export declare const renderOneTimeCost: (value: OneTimeCost) => StdReader<string, "t" | "tm" | "lj" | "rts" | "eu" | "s" | "nms" | "ibi", "SkillModificationLevel">;
52
+ export declare const renderOneTimeCost: (value: OneTimeCost) => StdReader<string, "t" | "tm" | "f" | "lj" | "rts" | "eu" | "s" | "nms" | "ibi", "SkillModificationLevel">;
51
53
  /**
52
54
  * Returns the text for the non-modifiable cost of a sustained activatable skill.
53
55
  */
54
56
  export declare const renderNonModifiableSustainedCost: (value: NonModifiableSustainedCost) => Reader<{
55
- translate: Translate;
57
+ translate: import("../../../../helpers/translate.js").Translate;
56
58
  energyUnit: import("../../units/energy.js").EnergyUnit;
57
59
  } & {
58
- translate: Translate;
59
- responsiveTextSize: ResponsiveTextSize;
60
- } & StdEnv<"tm" | "t" | "rts" | "eu", never, never, never>, string>;
60
+ translate: import("../../../../helpers/translate.js").Translate;
61
+ responsiveTextSize: import("../../responsiveText.js").ResponsiveTextSize;
62
+ } & {
63
+ responsiveTextSize: import("../../responsiveText.js").ResponsiveTextSize;
64
+ } & {
65
+ translate: import("../../../../helpers/translate.js").Translate;
66
+ } & StdEnv<"f" | "tm" | "t" | "rts"> & StdEnv<"tm" | "t" | "rts" | "eu", never, never, never>, string>;
61
67
  /**
62
68
  * Returns the text for the cost of a sustained activatable skill.
63
69
  */
64
- export declare const renderSustainedCost: (value: SustainedCost) => StdReader<string, "t" | "tm" | "rts" | "eu" | "s" | "nms" | "ibi", "SkillModificationLevel">;
70
+ export declare const renderSustainedCost: (value: SustainedCost) => StdReader<string, "t" | "tm" | "f" | "rts" | "eu" | "s" | "nms" | "ibi", "SkillModificationLevel">;
65
71
  type MagicalActionCost = {
66
72
  kind: "Fixed";
67
73
  Fixed: NonModifiableOneTimeCost;
@@ -86,10 +92,10 @@ type MagicalActionCost = {
86
92
  };
87
93
  } | {
88
94
  kind: "Map";
89
- Map: OneTimeCostMap;
95
+ Map: StandaloneCostMap;
90
96
  };
91
97
  /**
92
98
  * Generates the text for the cost specific to a magical action.
93
99
  */
94
- export declare const renderMagicalActionCost: (cost: MagicalActionCost) => StdReader<string, "t" | "tm" | "rts" | "eu" | "nms" | "lj">;
100
+ export declare const renderMagicalActionCost: (cost: MagicalActionCost) => StdReader<string, "t" | "tm" | "f" | "rts" | "eu" | "nms" | "lj">;
95
101
  export {};
@@ -2,11 +2,10 @@ import { identity } from "@elyukai/utils/function";
2
2
  import { Reader } from "@elyukai/utils/reader";
3
3
  import { mapNullable } from "@optolith/helpers/nullable";
4
4
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
5
- import { responsiveTranslate, } from "../../../../helpers/translate.js";
6
5
  import { renderResponsiveMap } from "../../map.js";
7
6
  import { formatEnergyFnR, formatEnergyR, getInstanceByIdFnR, modifiableBySpeedR, responsiveLocaleJoinR, responsiveR, responsiveTextR, responsiveTranslateR, translateMapR, translateR, } from "../../reader.js";
8
- import { appendNoteIfNeeded, replaceTextIfNeeded, } from "../../responsiveText.js";
9
- import { formatCombinedTimeSpan, formatCombinedTimeSpanR } from "../../units/timeSpan.js";
7
+ import { appendNoteIfNeeded, replaceTextIfNeeded } from "../../responsiveText.js";
8
+ import { formatCombinedTimeSpanR } from "../../units/timeSpan.js";
10
9
  import { MISSING_VALUE } from "../../unknown.js";
11
10
  import { appendCheckResultModifier } from "./checkResultBased.js";
12
11
  import { wrapIfMinimum } from "./isMinimumMaximum.js";
@@ -64,12 +63,6 @@ const appendIntervalToCostR = (interval, baseCost) => interval === undefined
64
63
  cost: baseCost,
65
64
  interval: formattedInterval,
66
65
  }));
67
- const appendIntervalToCost = (translate, responsiveTextSize, interval, baseCost) => interval === undefined
68
- ? baseCost
69
- : responsiveTranslate(translate, responsiveTextSize, "{$cost} per {$interval}", "{$cost}/{$interval}", {
70
- cost: baseCost,
71
- interval: formatCombinedTimeSpan(translate, responsiveTextSize, interval, true),
72
- });
73
66
  /**
74
67
  * Returns the text for a non-modifiable one-time cost of an activatable skill.
75
68
  */
@@ -77,7 +70,7 @@ export const renderNonModifiableOneTimeCost = (value, shouldAppendNonModifiableS
77
70
  .thenW(base => appendFamiliarsTrickLPCostIfNeeded(value.lp_value, base))
78
71
  .thenW(base => appendPerCountableToCostIfNeeded(value.per, base))
79
72
  .then(base => appendPermanentCostIfNeeded(value.permanent_value, base))
80
- .then(base => appendIntervalToCostR(value.interval, base))
73
+ .thenW(base => appendIntervalToCostR(value.interval, base))
81
74
  .then(base => appendElvenPermanentCostIfNeeded(value.permanent, base))
82
75
  .then(base => wrapIfMinimum(value.is_minimum, base))
83
76
  .then(base => appendNoteIfNeeded(value.translations, base))
@@ -119,22 +112,56 @@ const renderMultipleOneTimeCosts = (type, value) => {
119
112
  .then(text => appendNonModifiableIfRequested(text));
120
113
  };
121
114
  /**
122
- * Returns the text for a one-time cost map of an activatable skill.
115
+ * Returns the text for a standalone one-time cost map of an activatable skill.
123
116
  */
124
- export const renderOneTimeCostMap = (value) => Reader.asks(({ translate }) => translate).thenW(translate => formatEnergyFnR
125
- .thenW(formatEnergy => renderResponsiveMap(value, option => option.value, formatEnergy, value.options.every(option => option.permanent_value !== undefined)
117
+ export const renderStandaloneCostMap = (value) => renderResponsiveMap(value, option => Reader.of(option.value), formatEnergyR, value.options.every(option => option.value.permanentValue !== undefined)
126
118
  ? {
127
- surround: values => translate(", {$value} of which are permanent", {
119
+ surround: values => translateR(", {$value} of which are permanent", {
128
120
  value: values,
129
121
  }),
130
122
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- is checked beforehand
131
- getAdditionalValue: option => option.permanent_value,
123
+ getAdditionalValue: option => option.permanentValue,
124
+ }
125
+ : undefined);
126
+ /**
127
+ * Returns the text for a one-time cost map of an activatable skill.
128
+ */
129
+ const renderOneTimeCostMap = (value) => {
130
+ switch (value.kind) {
131
+ case "Modifiable":
132
+ return renderResponsiveMap(value.Modifiable.map, option => deriveModifiableCost(option.initialModificationLevel).map(cost => cost ?? MISSING_VALUE), formatEnergyR, value.Modifiable.map.options.every(option => option.value.permanentValue !== undefined)
133
+ ? {
134
+ surround: values => translateR(", {$value} of which are permanent", {
135
+ value: values,
136
+ }),
137
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- is checked beforehand
138
+ getAdditionalValue: option => option.permanentValue,
139
+ }
140
+ : undefined);
141
+ case "NonModifiable":
142
+ return renderResponsiveMap(value.NonModifiable.map, option => Reader.of(option.value), formatEnergyR, value.NonModifiable.map.options.every(option => option.value.permanentValue !== undefined)
143
+ ? {
144
+ surround: values => translateR(", {$value} of which are permanent", {
145
+ value: values,
146
+ }),
147
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- is checked beforehand
148
+ getAdditionalValue: option => option.permanentValue,
149
+ }
150
+ : undefined).then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text));
151
+ default:
152
+ return assertExhaustive(value);
153
+ }
154
+ };
155
+ const renderSustainedCostMap = (value) => {
156
+ switch (value.kind) {
157
+ case "Modifiable":
158
+ return renderResponsiveMap(value.Modifiable.map, option => deriveModifiableCost(option.initialModificationLevel).map(cost => cost ?? MISSING_VALUE), singleValue => formatEnergyR(singleValue).thenW(energy => appendIntervalToCostR(value.Modifiable.interval, energy)));
159
+ case "NonModifiable":
160
+ return renderResponsiveMap(value.NonModifiable.map, option => Reader.of(option.value), singleValue => formatEnergyR(singleValue).thenW(energy => appendIntervalToCostR(value.NonModifiable.interval, energy))).then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text));
161
+ default:
162
+ return assertExhaustive(value);
132
163
  }
133
- : undefined))
134
- .then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text)));
135
- const renderSustainedCostMap = (value) => formatEnergyFnR
136
- .thenW(formatEnergy => Reader.ask().thenW(({ translate, responsiveTextSize }) => renderResponsiveMap(value, option => option.value, singleValue => appendIntervalToCost(translate, responsiveTextSize, value.interval, formatEnergy(singleValue)))))
137
- .then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text));
164
+ };
138
165
  /**
139
166
  * Returns the text for the cost of a one-time activatable skill.
140
167
  */
@@ -155,7 +182,7 @@ export const renderOneTimeCost = (value) => {
155
182
  const buildSustainedCost = (activationCost, intervalCost, interval) => {
156
183
  const activationCostWithLabel = responsiveR(() => translateR("activation").map(label => `${activationCost} (${label})`), () => Reader.of(activationCost)).thenW(identity);
157
184
  const intervalCostWithLabel = appendIntervalToCostR(interval, intervalCost);
158
- return activationCostWithLabel.map2(intervalCostWithLabel, (activationStr, intervalStr) => `${activationStr} + ${intervalStr}`);
185
+ return activationCostWithLabel.thenW(activationStr => intervalCostWithLabel.map(intervalStr => `${activationStr} + ${intervalStr}`));
159
186
  };
160
187
  const renderModifiableSustainedCost = (value) => deriveModifiableCost(value.initial_modification_level).thenW(cost => cost === undefined
161
188
  ? Reader.of(MISSING_VALUE)
@@ -173,20 +200,28 @@ export const renderNonModifiableSustainedCost = (value) => formatEnergyFnR
173
200
  const getIntervalCost = value.is_minimum === true
174
201
  ? responsiveTranslateR("half of the activation cost", "50%")
175
202
  : Reader.of(formatEnergy(value.value / 2));
176
- return getIntervalCost.then(intervalCost => buildSustainedCost(activationCost, intervalCost, value.interval));
203
+ return getIntervalCost.thenW(intervalCost => buildSustainedCost(activationCost, intervalCost, value.interval));
177
204
  })
178
205
  .thenW(base => appendPerCountableToCostIfNeeded(value.per, base))
179
206
  .then(base => wrapIfMinimum(value.is_minimum, base))
180
207
  .then(base => appendNonModifiableSuffix(ModifiableParameter.Cost, base));
181
- /**
182
- * Returns the text for the cost of a sustained activatable skill.
183
- */
184
- export const renderSustainedCost = (value) => {
208
+ const renderSingleSustainedCost = (value) => {
185
209
  switch (value.kind) {
186
210
  case "Modifiable":
187
211
  return renderModifiableSustainedCost(value.Modifiable);
188
212
  case "NonModifiable":
189
213
  return renderNonModifiableSustainedCost(value.NonModifiable);
214
+ default:
215
+ return assertExhaustive(value);
216
+ }
217
+ };
218
+ /**
219
+ * Returns the text for the cost of a sustained activatable skill.
220
+ */
221
+ export const renderSustainedCost = (value) => {
222
+ switch (value.kind) {
223
+ case "Single":
224
+ return renderSingleSustainedCost(value.Single);
190
225
  case "Map":
191
226
  return renderSustainedCostMap(value.Map);
192
227
  default:
@@ -220,7 +255,7 @@ export const renderMagicalActionCost = (cost) => {
220
255
  value: cost.All.minimum,
221
256
  }));
222
257
  case "Map":
223
- return renderOneTimeCostMap(cost.Map);
258
+ return renderStandaloneCostMap(cost.Map);
224
259
  default:
225
260
  return assertExhaustive(cost);
226
261
  }
@@ -4,7 +4,7 @@ import { type StdReader } from "../../reader.js";
4
4
  /**
5
5
  * Returns the text for a duration that is based on an expression.
6
6
  */
7
- export declare const renderExpressionBasedDuration: (value: ExpressionBasedDuration) => StdReader<string, "t" | "tm" | "rts">;
7
+ export declare const renderExpressionBasedDuration: (value: ExpressionBasedDuration) => StdReader<string, "t" | "tm" | "f" | "rts">;
8
8
  type OneTimeDuration = {
9
9
  kind: "Immediate";
10
10
  Immediate?: Immediate;
@@ -34,11 +34,11 @@ type OneTimeDuration = {
34
34
  /**
35
35
  * Returns the text for the duration of a one-time activatable skill.
36
36
  */
37
- export declare const renderOneTimeDuration: (value: OneTimeDuration) => StdReader<string, "t" | "tm" | "rts">;
37
+ export declare const renderOneTimeDuration: (value: OneTimeDuration) => StdReader<string, "t" | "tm" | "f" | "rts">;
38
38
  /**
39
39
  * Returns the text for the duration of a sustained activatable skill.
40
40
  */
41
- export declare const renderSustainedDuration: (value: DurationForSustained | undefined) => StdReader<string, "t" | "rts">;
41
+ export declare const renderSustainedDuration: (value: DurationForSustained | undefined) => StdReader<string, "t" | "tm" | "f" | "rts">;
42
42
  /**
43
43
  * Returns the text for the duration of a musical activatable skill.
44
44
  */
@@ -10,11 +10,11 @@ type RenderedPerformanceParameters = {
10
10
  /**
11
11
  * Get the texts for all fast one-time performance parameters.
12
12
  */
13
- export declare const renderFastOneTimePerformanceParameters: (value: FastOneTimePerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
13
+ export declare const renderFastOneTimePerformanceParameters: (value: FastOneTimePerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
14
14
  /**
15
15
  * Get the texts for all fast sustained performance parameters.
16
16
  */
17
- export declare const renderFastSustainedPerformanceParameters: (value: FastSustainedPerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
17
+ export declare const renderFastSustainedPerformanceParameters: (value: FastSustainedPerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
18
18
  /**
19
19
  * Renders the performance parameters for a fast activatable skill.
20
20
  */
@@ -24,15 +24,15 @@ export declare const renderFastPerformanceParameters: (value: {
24
24
  } | {
25
25
  kind: "Sustained";
26
26
  Sustained: FastSustainedPerformanceParameters;
27
- }) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
27
+ }) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
28
28
  /**
29
29
  * Get the texts for all slow one-time performance parameters.
30
30
  */
31
- export declare const renderSlowOneTimePerformanceParameters: <CastingTime>(renderCastingTime: (value: CastingTime) => StdReader<string, "t" | "rts" | "nms" | "ibi", "SkillModificationLevel">, value: OneTimePerformanceParameters<CastingTime>) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
31
+ export declare const renderSlowOneTimePerformanceParameters: <CastingTime>(renderCastingTime: (value: CastingTime) => StdReader<string, "t" | "tm" | "f" | "rts" | "nms" | "ibi", "SkillModificationLevel">, value: OneTimePerformanceParameters<CastingTime>) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
32
32
  /**
33
33
  * Get the texts for all slow sustained performance parameters.
34
34
  */
35
- export declare const renderSlowSustainedPerformanceParameters: (value: SlowSustainedPerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
35
+ export declare const renderSlowSustainedPerformanceParameters: (value: SlowSustainedPerformanceParameters) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
36
36
  /**
37
37
  * Renders the performance parameters for a slow activatable skill.
38
38
  */
@@ -42,7 +42,7 @@ export declare const renderSlowPerformanceParameters: (value: {
42
42
  } | {
43
43
  kind: "Sustained";
44
44
  Sustained: SlowSustainedPerformanceParameters;
45
- }) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
45
+ }) => StdReader<RenderedPerformanceParameters, "t" | "tm" | "f" | "lj" | "eu" | "rts" | "nms" | "ibi", "SkillModificationLevel">;
46
46
  /**
47
47
  * Diff the generated text with the static translation and combine them into a single text, highlighting the differences.
48
48
  */
@@ -9,7 +9,7 @@ import { Speed } from "./speed.js";
9
9
  * Get the texts for all fast one-time performance parameters.
10
10
  */
11
11
  export const renderFastOneTimePerformanceParameters = (value) => renderFastCastingTime(value.casting_time)
12
- .thenW(castingTime => renderOneTimeCost(value.cost).then(cost => renderRange(value.range).then(range => renderOneTimeDuration(value.duration).map(duration => ({
12
+ .thenW(castingTime => renderOneTimeCost(value.cost).then(cost => renderRange(value.range).thenW(range => renderOneTimeDuration(value.duration).map(duration => ({
13
13
  castingTime,
14
14
  cost,
15
15
  range,
@@ -20,7 +20,7 @@ export const renderFastOneTimePerformanceParameters = (value) => renderFastCasti
20
20
  * Get the texts for all fast sustained performance parameters.
21
21
  */
22
22
  export const renderFastSustainedPerformanceParameters = (value) => renderFastCastingTime(value.casting_time)
23
- .thenW(castingTime => renderSustainedCost(value.cost).then(cost => renderRange(value.range).then(range => renderSustainedDuration(value.duration).map(duration => ({
23
+ .thenW(castingTime => renderSustainedCost(value.cost).then(cost => renderRange(value.range).thenW(range => renderSustainedDuration(value.duration).map(duration => ({
24
24
  castingTime,
25
25
  cost,
26
26
  range,
@@ -44,7 +44,7 @@ export const renderFastPerformanceParameters = (value) => {
44
44
  * Get the texts for all slow one-time performance parameters.
45
45
  */
46
46
  export const renderSlowOneTimePerformanceParameters = (renderCastingTime, value) => renderCastingTime(value.casting_time)
47
- .thenW(castingTime => renderOneTimeCost(value.cost).then(cost => renderRange(value.range).then(range => renderOneTimeDuration(value.duration).map(duration => ({
47
+ .thenW(castingTime => renderOneTimeCost(value.cost).then(cost => renderRange(value.range).thenW(range => renderOneTimeDuration(value.duration).map(duration => ({
48
48
  castingTime,
49
49
  cost,
50
50
  range,
@@ -55,7 +55,7 @@ export const renderSlowOneTimePerformanceParameters = (renderCastingTime, value)
55
55
  * Get the texts for all slow sustained performance parameters.
56
56
  */
57
57
  export const renderSlowSustainedPerformanceParameters = (value) => renderSlowCastingTime(value.casting_time)
58
- .thenW(castingTime => renderSustainedCost(value.cost).then(cost => renderRange(value.range).then(range => renderSustainedDuration(value.duration).map(duration => ({
58
+ .thenW(castingTime => renderSustainedCost(value.cost).then(cost => renderRange(value.range).thenW(range => renderSustainedDuration(value.duration).map(duration => ({
59
59
  castingTime,
60
60
  cost,
61
61
  range,
@@ -147,6 +147,16 @@ export declare const attributedNameR: <E extends { [K in keyof EntityMap]: Entit
147
147
  translateMap: TranslateMap;
148
148
  getInstanceById: GetInstanceById<E>;
149
149
  }, string | undefined>;
150
+ /**
151
+ * Retrieves the `name` property of the specified entry in an attributed string.
152
+ */
153
+ export declare const attributedNameFromInstanceR: (instance: {
154
+ translations: LocaleMap<{
155
+ name: string;
156
+ }>;
157
+ } | undefined, context: string, ...args: IdArgsVariant) => Reader<{
158
+ translateMap: TranslateMap;
159
+ }, string | undefined>;
150
160
  /**
151
161
  * Applies a function to the translation of the specified entry and renders it in an attributed string.
152
162
  */
@@ -1,7 +1,7 @@
1
1
  import { isNotNullish } from "@elyukai/utils/nullable";
2
2
  import { Reader } from "@elyukai/utils/reader";
3
3
  import { assertExhaustive } from "@elyukai/utils/typeSafety";
4
- import { attributedCustomName, attributedName, customName } from "./markdown.js";
4
+ import { attributedCustomName, attributedName, attributedNameFromInstance, customName, } from "./markdown.js";
5
5
  import { Speed } from "./rated/activatable/speed.js";
6
6
  import { responsive, ResponsiveTextSize } from "./responsiveText.js";
7
7
  import { formatEnergy } from "./units/energy.js";
@@ -55,6 +55,10 @@ export const strictNameR = (...args) => nameR(...args).map(name => name ?? MISSI
55
55
  * Retrieves the `name` property of the specified entry in an attributed string.
56
56
  */
57
57
  export const attributedNameR = (context, ...args) => Reader.asks(env => attributedName(env.translateMap, env.getInstanceById, context, ...args));
58
+ /**
59
+ * Retrieves the `name` property of the specified entry in an attributed string.
60
+ */
61
+ export const attributedNameFromInstanceR = (instance, context, ...args) => Reader.asks(env => attributedNameFromInstance(env.translateMap, instance, context, ...args));
58
62
  /**
59
63
  * Applies a function to the translation of the specified entry and renders it in an attributed string.
60
64
  */
@@ -1,5 +1,6 @@
1
1
  import { Reader } from "@elyukai/utils/reader";
2
- import type { Translate } from "../../../helpers/translate.js";
2
+ import type { Case } from "tsondb/schema/gen";
3
+ import type { Format, LocaleMap, Translate, TranslateMap } from "../../../helpers/translate.js";
3
4
  import type { StdEnv } from "../reader.js";
4
5
  import { type ResponsiveTextSize } from "../responsiveText.js";
5
6
  /**
@@ -7,32 +8,39 @@ import { type ResponsiveTextSize } from "../responsiveText.js";
7
8
  */
8
9
  export type TimeSpanUnit = "Seconds" | "Minutes" | "Hours" | "Days" | "Weeks" | "Months" | "Years" | "Decades" | "Centuries" | "Actions" | "CombatRounds" | "SeductionActions" | "Rounds";
9
10
  /**
10
- * Returns the text for a time span unit.
11
+ * Possible units to use for time spans, including the possibility of creating your own.
11
12
  */
12
- export declare const formatTimeSpan: (translate: Translate, responsiveTextSize: ResponsiveTextSize, unit: {
13
+ export type TimeSpanUnitObject = {
13
14
  kind: TimeSpanUnit;
14
- } | TimeSpanUnit, value: number | string, interval?: boolean) => string;
15
+ } | Case<"Custom", {
16
+ translations: LocaleMap<{
17
+ name: string;
18
+ symbol: string;
19
+ fullNumber: string;
20
+ full: string;
21
+ compressedNumber: string;
22
+ compressed: string;
23
+ }>;
24
+ }>;
15
25
  /**
16
26
  * Returns the text for a time span unit.
17
27
  */
18
- export declare const formatCombinedTimeSpan: (translate: Translate, responsiveTextSize: ResponsiveTextSize, object: {
19
- unit: {
20
- kind: TimeSpanUnit;
21
- };
28
+ export declare const formatTimeSpan: (translate: Translate, translateMap: TranslateMap, format: Format, responsiveTextSize: ResponsiveTextSize, unit: TimeSpanUnitObject | TimeSpanUnit, value: number | string, interval?: boolean) => string;
29
+ /**
30
+ * Returns the text for a time span unit.
31
+ */
32
+ export declare const formatCombinedTimeSpan: (translate: Translate, translateMap: TranslateMap, format: Format, responsiveTextSize: ResponsiveTextSize, object: {
33
+ unit: TimeSpanUnitObject;
22
34
  value: number | string;
23
35
  }, interval?: boolean) => string;
24
36
  /**
25
37
  * Returns the text for a time span unit.
26
38
  */
27
- export declare const formatTimeSpanR: (unit: {
28
- kind: TimeSpanUnit;
29
- } | TimeSpanUnit, value: number | string, interval?: boolean) => Reader<StdEnv<"t" | "rts">, string>;
39
+ export declare const formatTimeSpanR: (unit: TimeSpanUnitObject | TimeSpanUnit, value: number | string, interval?: boolean) => Reader<StdEnv<"t" | "tm" | "f" | "rts">, string>;
30
40
  /**
31
41
  * Returns the text for a time span unit.
32
42
  */
33
43
  export declare const formatCombinedTimeSpanR: (object: {
34
- unit: {
35
- kind: TimeSpanUnit;
36
- };
44
+ unit: TimeSpanUnitObject;
37
45
  value: number | string;
38
- }, interval?: boolean) => Reader<StdEnv<"t" | "rts">, string>;
46
+ }, interval?: boolean) => Reader<StdEnv<"t" | "tm" | "f" | "rts">, string>;