@optolith/entity-descriptions 0.1.1 → 0.2.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.
- package/CHANGELOG.md +32 -0
- package/lib/entities/combatTechnique.d.ts +4 -4
- package/lib/entities/combatTechnique.js +7 -7
- package/lib/entities/experienceLevel.d.ts +1 -1
- package/lib/entities/experienceLevel.js +3 -3
- package/lib/entities/focusRule.d.ts +8 -0
- package/lib/entities/focusRule.js +18 -0
- package/lib/entities/liturgicalChant.d.ts +6 -6
- package/lib/entities/liturgicalChant.js +27 -56
- package/lib/entities/optionalRule.d.ts +5 -0
- package/lib/entities/optionalRule.js +16 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +3 -15
- package/lib/entities/partial/rated/activatable/castingTime.js +19 -34
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/checkResultBased.js +2 -2
- package/lib/entities/partial/rated/activatable/cost.d.ts +3 -19
- package/lib/entities/partial/rated/activatable/cost.js +82 -99
- package/lib/entities/partial/rated/activatable/duration.d.ts +5 -24
- package/lib/entities/partial/rated/activatable/duration.js +40 -57
- package/lib/entities/partial/rated/activatable/effect.d.ts +3 -3
- package/lib/entities/partial/rated/activatable/effect.js +7 -7
- package/lib/entities/partial/rated/activatable/index.d.ts +5 -33
- package/lib/entities/partial/rated/activatable/index.js +23 -41
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +20 -0
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +19 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +16 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +55 -0
- package/lib/entities/partial/rated/activatable/parensIf.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/parensIf.js +3 -1
- package/lib/entities/partial/rated/activatable/range.d.ts +4 -20
- package/lib/entities/partial/rated/activatable/range.js +59 -100
- package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/speed.js +1 -1
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +3 -7
- package/lib/entities/partial/rated/activatable/targetCategory.js +30 -26
- package/lib/entities/partial/rated/improvementCost.d.ts +2 -2
- package/lib/entities/partial/rated/skillCheck.d.ts +2 -2
- package/lib/entities/partial/responsiveText.d.ts +7 -4
- package/lib/entities/partial/responsiveText.js +8 -2
- package/lib/entities/partial/units/energy.d.ts +12 -0
- package/lib/entities/partial/units/energy.js +30 -0
- package/lib/entities/partial/units/length.d.ts +8 -0
- package/lib/entities/partial/units/length.js +12 -0
- package/lib/entities/partial/units/timeSpan.d.ts +8 -0
- package/lib/entities/partial/units/timeSpan.js +22 -0
- package/lib/entities/skill.d.ts +2 -2
- package/lib/entities/skill.js +3 -3
- package/lib/entities/spell.d.ts +6 -6
- package/lib/entities/spell.js +27 -56
- package/lib/helpers/locale.d.ts +8 -0
- package/lib/helpers/locale.js +1 -0
- package/lib/index.d.ts +45 -1
- package/lib/index.js +22 -1
- package/lib/references/index.d.ts +4 -0
- package/lib/references/index.js +46 -0
- package/lib/references/occurrence.d.ts +4 -0
- package/lib/references/occurrence.js +3 -0
- package/lib/references/page.d.ts +23 -0
- package/lib/references/page.js +61 -0
- package/lib/references/pageRange.d.ts +30 -0
- package/lib/references/pageRange.js +58 -0
- package/package.json +7 -3
- package/lib/entities/partial/rated/activatable/isMaximum.d.ts +0 -6
- package/lib/entities/partial/rated/activatable/isMaximum.js +0 -10
- package/lib/entities/partial/rated/activatable/modifiableParameter.d.ts +0 -8
- package/lib/entities/partial/rated/activatable/modifiableParameter.js +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.d.ts +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.js +0 -75
- package/lib/entities/partial/rated/activatable/units.d.ts +0 -13
- package/lib/entities/partial/rated/activatable/units.js +0 -53
- package/lib/libraryEntry.d.ts +0 -52
- package/lib/libraryEntry.js +0 -17
|
@@ -1,165 +1,148 @@
|
|
|
1
1
|
import { mapNullable, mapNullableDefault } from "@optolith/helpers/nullable";
|
|
2
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
-
import {
|
|
3
|
+
import { appendNoteIfRequested, getResponsiveText, replaceTextIfRequested, responsive, } from "../../responsiveText.js";
|
|
4
|
+
import { formatEnergyByEntity } from "../../units/energy.js";
|
|
5
|
+
import { formatTimeSpan } from "../../units/timeSpan.js";
|
|
4
6
|
import { MISSING_VALUE } from "../../unknown.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getModifiableBySpeed
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return replaceTextIfRequested(value.translations, formatCost(deps.translate, env.entity, cost), deps.translateMap, env.responsiveText);
|
|
7
|
+
import { wrapIfMinimum } from "./isMinimumMaximum.js";
|
|
8
|
+
import { getNonModifiableSuffixTranslation, ModifiableParameter, } from "./nonModifiableSuffix.js";
|
|
9
|
+
import { getModifiableBySpeed } from "./speed.js";
|
|
10
|
+
const getModifiableOneTimeCostTranslation = (getSkillModificationLevelById, locale, responsiveTextSize, entity, speed, value) => mapNullable(getSkillModificationLevelById(value.initial_modification_level), (modificationLevel) => {
|
|
11
|
+
const cost = getModifiableBySpeed((config) => config.cost, (config) => config.cost, speed, modificationLevel);
|
|
12
|
+
return replaceTextIfRequested("replacement", value.translations, locale.translateMap, responsiveTextSize, formatEnergyByEntity(locale, entity, cost));
|
|
12
13
|
}) ?? MISSING_VALUE;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const countableText = responsive(env.responsiveText, (entity) => deps.translate(" per {0}", entity), (entity) => deps.translate("/{0}", entity), getResponsiveText(deps.translateMap(perCountable.translations)?.countable, env.responsiveText));
|
|
18
|
-
const minimumTotalText = mapNullable(perCountable.minimum_total, (minimumTotal) => deps.translate(", minimum of {0}", deps.formatCost(minimumTotal))) ?? "";
|
|
14
|
+
const getNonModifiableOneTimeCostPerCountableTranslation = (formatCost, locale, responsiveTextSize, value) => mapNullable(value, (perCountable) => {
|
|
15
|
+
const entity = getResponsiveText(locale.translateMap(perCountable.translations)?.countable, responsiveTextSize);
|
|
16
|
+
const countableText = responsive(responsiveTextSize, () => locale.translate(" per {0}", entity), () => locale.translate("/{0}", entity));
|
|
17
|
+
const minimumTotalText = mapNullable(perCountable.minimum_total, (minimumTotal) => locale.translate(", minimum of {0}", formatCost(minimumTotal))) ?? "";
|
|
19
18
|
return countableText + minimumTotalText;
|
|
20
19
|
}) ?? "";
|
|
21
|
-
const
|
|
20
|
+
const getPermanentValueTranslation = (locale, responsiveTextSize, permanentValue) => permanentValue === undefined
|
|
22
21
|
? ""
|
|
23
|
-
: responsive(
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
: getResponsiveTextOptional(translation.note, env.responsiveText), (noteIfPresent) => ` (${noteIfPresent})`, "");
|
|
33
|
-
const cannotModify = getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Cost, env.responsiveText);
|
|
34
|
-
return (isMinimum + formatCostP(value.value) + per + permanent + note + cannotModify);
|
|
22
|
+
: responsive(responsiveTextSize, () => locale.translate(", {0} of which are permanent", permanentValue), () => locale.translate(" ({0} perm.)", permanentValue));
|
|
23
|
+
const getNonModifiableOneTimeCostTranslation = (locale, entity, responsiveTextSize, value) => {
|
|
24
|
+
const formatCostP = formatEnergyByEntity.bind(this, locale, entity);
|
|
25
|
+
const perCountable = getNonModifiableOneTimeCostPerCountableTranslation(formatCostP, locale, responsiveTextSize, value.per);
|
|
26
|
+
const permanentValue = getPermanentValueTranslation(locale, responsiveTextSize, value.permanent_value);
|
|
27
|
+
const costWrappedIfMinimum = wrapIfMinimum(locale, responsiveTextSize, value.is_minimum, formatCostP(value.value) + perCountable + permanentValue);
|
|
28
|
+
const withNote = appendNoteIfRequested("note", value.translations, locale.translateMap, responsiveTextSize, costWrappedIfMinimum);
|
|
29
|
+
const cannotModify = getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize);
|
|
30
|
+
return withNote + cannotModify;
|
|
35
31
|
};
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
32
|
+
const getIndefiniteOneTimeCostTranslation = (locale, entity, responsiveTextSize, value) => getResponsiveText(locale.translateMap(value.translations)?.description, responsiveTextSize) +
|
|
33
|
+
getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize);
|
|
34
|
+
const getSingleOneTimeCostTranslation = (getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => {
|
|
39
35
|
switch (value.tag) {
|
|
40
36
|
case "Modifiable":
|
|
41
|
-
return
|
|
37
|
+
return getModifiableOneTimeCostTranslation(getSkillModificationLevelById, locale, responsiveTextSize, entity, speed, value.modifiable);
|
|
42
38
|
case "NonModifiable":
|
|
43
|
-
return
|
|
39
|
+
return getNonModifiableOneTimeCostTranslation(locale, entity, responsiveTextSize, value.non_modifiable);
|
|
44
40
|
case "Indefinite":
|
|
45
|
-
return
|
|
41
|
+
return getIndefiniteOneTimeCostTranslation(locale, entity, responsiveTextSize, value.indefinite);
|
|
46
42
|
default:
|
|
47
43
|
return assertExhaustive(value);
|
|
48
44
|
}
|
|
49
45
|
};
|
|
50
|
-
const
|
|
46
|
+
const getMultipleOneTimeCostsTranslation = (type, getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => {
|
|
51
47
|
const modifiable = !value.every((part) => part.tag === "Modifiable")
|
|
52
|
-
?
|
|
48
|
+
? getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize)
|
|
53
49
|
: "";
|
|
54
50
|
return (value
|
|
55
|
-
.map((part) =>
|
|
51
|
+
.map((part) => getSingleOneTimeCostTranslation(getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, part))
|
|
56
52
|
.join((() => {
|
|
57
53
|
switch (type) {
|
|
58
54
|
case "conjunction":
|
|
59
|
-
return responsive(
|
|
55
|
+
return responsive(responsiveTextSize, () => locale.translate(" and "), () => locale.translate(" + "));
|
|
60
56
|
case "disjunction":
|
|
61
|
-
return responsive(
|
|
57
|
+
return responsive(responsiveTextSize, () => locale.translate(" or "), () => locale.translate(" / "));
|
|
62
58
|
default:
|
|
63
59
|
return assertExhaustive(type);
|
|
64
60
|
}
|
|
65
61
|
})()) + modifiable);
|
|
66
62
|
};
|
|
67
|
-
const
|
|
68
|
-
const translation =
|
|
63
|
+
const getCostMapTranslation = (locale, entity, responsiveTextSize, value) => {
|
|
64
|
+
const translation = locale.translateMap(value.translations);
|
|
69
65
|
if (value.translations !== undefined && translation === undefined) {
|
|
70
66
|
return MISSING_VALUE;
|
|
71
67
|
}
|
|
72
68
|
if (translation?.replacement !== undefined) {
|
|
73
69
|
return translation.replacement;
|
|
74
70
|
}
|
|
75
|
-
const costs = value.options.map((option) => option.value).join("/");
|
|
76
71
|
const labels = value.options
|
|
77
|
-
.map((option) =>
|
|
72
|
+
.map((option) => locale.translateMap(option.translations)?.label ?? MISSING_VALUE)
|
|
78
73
|
.join("/");
|
|
74
|
+
const costs = value.options.map((option) => option.value).join("/");
|
|
79
75
|
const permanentCosts = value.options.every((option) => option.permanent_value !== undefined)
|
|
80
76
|
? value.options.map((option) => option.permanent_value).join("/")
|
|
81
77
|
: undefined;
|
|
82
|
-
const formatCostP =
|
|
83
|
-
const notModifiable =
|
|
78
|
+
const formatCostP = formatEnergyByEntity.bind(this, locale, entity);
|
|
79
|
+
const notModifiable = getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize);
|
|
84
80
|
return (formatCostP(costs) +
|
|
85
|
-
|
|
81
|
+
locale.translate(" for ") +
|
|
86
82
|
mapNullableDefault(translation?.list_prepend, (listPrepend) => `${listPrepend} `, "") +
|
|
87
83
|
labels +
|
|
88
84
|
(translation?.list_append ?? "") +
|
|
89
85
|
(permanentCosts !== undefined
|
|
90
|
-
?
|
|
86
|
+
? locale.translate(", {0} of which are permanent", formatCostP(permanentCosts))
|
|
91
87
|
: "") +
|
|
92
88
|
notModifiable);
|
|
93
89
|
};
|
|
94
90
|
/**
|
|
95
91
|
* Returns the text for the cost of a one-time activatable skill.
|
|
96
92
|
*/
|
|
97
|
-
export const
|
|
93
|
+
export const getOneTimeCostTranslation = (getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => {
|
|
98
94
|
switch (value.tag) {
|
|
99
95
|
case "Single":
|
|
100
|
-
return
|
|
96
|
+
return getSingleOneTimeCostTranslation(getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value.single);
|
|
101
97
|
case "Conjunction":
|
|
102
|
-
return
|
|
98
|
+
return getMultipleOneTimeCostsTranslation("conjunction", getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value.conjunction);
|
|
103
99
|
case "Disjunction":
|
|
104
|
-
return
|
|
100
|
+
return getMultipleOneTimeCostsTranslation("disjunction", getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value.disjunction);
|
|
105
101
|
case "Map":
|
|
106
|
-
return
|
|
102
|
+
return getCostMapTranslation(locale, entity, responsiveTextSize, value.map);
|
|
107
103
|
default:
|
|
108
104
|
return assertExhaustive(value);
|
|
109
105
|
}
|
|
110
106
|
};
|
|
107
|
+
const getModifiableSustainedCostTranslation = (getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => mapNullable(getSkillModificationLevelById(value.initial_modification_level), (modificationLevel) => {
|
|
108
|
+
const cost = getModifiableBySpeed((config) => config.cost, (config) => config.cost, speed, modificationLevel);
|
|
109
|
+
const formatCostP = formatEnergyByEntity.bind(this, locale, entity);
|
|
110
|
+
const interval = formatTimeSpan(locale, responsiveTextSize, value.interval.unit, value.interval.value);
|
|
111
|
+
return responsive(responsiveTextSize, () => `${formatCostP(cost) + locale.translate(" (casting)")} + ${formatCostP(cost / 2) + locale.translate(" per {0}", interval)}`, () => `${formatCostP(cost)} + ${formatCostP(cost / 2) + locale.translate("/{0}", interval)}`);
|
|
112
|
+
}) ?? MISSING_VALUE;
|
|
113
|
+
const getNonModifiableSustainedCostTranslation = (locale, entity, responsiveTextSize, value) => {
|
|
114
|
+
const formatCostP = formatEnergyByEntity.bind(this, locale, entity);
|
|
115
|
+
const per = (() => {
|
|
116
|
+
if (value.per === undefined) {
|
|
117
|
+
return { countable: "", minimumTotal: "" };
|
|
118
|
+
}
|
|
119
|
+
const countable = responsive(responsiveTextSize, (entity) => locale.translate(" per {0}", entity), (entity) => locale.translate("/{0}", entity), getResponsiveText(locale.translateMap(value.per.translations)?.countable, responsiveTextSize));
|
|
120
|
+
const minimumTotal = value.per.minimum_total !== undefined
|
|
121
|
+
? locale.translate(", minimum of {0}", formatCostP(value.per.minimum_total))
|
|
122
|
+
: "";
|
|
123
|
+
return { countable, minimumTotal };
|
|
124
|
+
})();
|
|
125
|
+
const interval = formatTimeSpan(locale, responsiveTextSize, value.interval.unit, value.interval.value);
|
|
126
|
+
const cost = responsive(responsiveTextSize, () => `${formatCostP(value.value) + locale.translate(" (casting)")} + ${(value.is_minimum === true
|
|
127
|
+
? locale.translate("half of the activation cost")
|
|
128
|
+
: formatCostP(value.value / 2)) +
|
|
129
|
+
per.countable +
|
|
130
|
+
locale.translate(" per {0}", interval)}`, () => `${formatCostP(value.value)} + ${(value.is_minimum === true ? "50%" : formatCostP(value.value / 2)) +
|
|
131
|
+
per.countable +
|
|
132
|
+
locale.translate("/{0}", interval)}`) + per.minimumTotal;
|
|
133
|
+
const costWrappedIfMinimum = wrapIfMinimum(locale, responsiveTextSize, value.is_minimum, cost);
|
|
134
|
+
return (costWrappedIfMinimum +
|
|
135
|
+
getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize));
|
|
136
|
+
};
|
|
111
137
|
/**
|
|
112
138
|
* Returns the text for the cost of a sustained activatable skill.
|
|
113
139
|
*/
|
|
114
|
-
export const
|
|
140
|
+
export const getSustainedCostTranslation = (getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value) => {
|
|
115
141
|
switch (value.tag) {
|
|
116
|
-
case "Modifiable":
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
const cost = (() => {
|
|
122
|
-
switch (env.speed) {
|
|
123
|
-
case Speed.Fast:
|
|
124
|
-
return modificationLevel.fast.cost;
|
|
125
|
-
case Speed.Slow:
|
|
126
|
-
return modificationLevel.slow.cost;
|
|
127
|
-
default:
|
|
128
|
-
return assertExhaustive(env.speed);
|
|
129
|
-
}
|
|
130
|
-
})();
|
|
131
|
-
const formatCostP = formatCost.bind(this, deps.translate, env.entity);
|
|
132
|
-
const interval = formatTimeSpan(deps.translate, env.responsiveText, value.modifiable.interval.unit, value.modifiable.interval.value);
|
|
133
|
-
return responsive(env.responsiveText, () => `${formatCostP(cost) + deps.translate(" (casting)")} + ${formatCostP(cost / 2) + deps.translate(" per {0}", interval)}`, () => `${formatCostP(cost)} + ${formatCostP(cost / 2) + deps.translate("/{0}", interval)}`);
|
|
134
|
-
}
|
|
135
|
-
case "NonModifiable": {
|
|
136
|
-
const isMinimum = getMinimumText(value.non_modifiable.is_minimum, deps.translate, env.responsiveText);
|
|
137
|
-
const cost = value.non_modifiable.value;
|
|
138
|
-
const formatCostP = formatCost.bind(this, deps.translate, env.entity);
|
|
139
|
-
const per = (() => {
|
|
140
|
-
if (value.non_modifiable.per === undefined) {
|
|
141
|
-
return { countable: "", minimumTotal: "" };
|
|
142
|
-
}
|
|
143
|
-
const countable = responsive(env.responsiveText, (entity) => deps.translate(" per {0}", entity), (entity) => deps.translate("/{0}", entity), getResponsiveText(deps.translateMap(value.non_modifiable.per.translations)?.countable, env.responsiveText));
|
|
144
|
-
const minimumTotal = value.non_modifiable.per.minimum_total !== undefined
|
|
145
|
-
? deps.translate(", minimum of {0}", formatCostP(value.non_modifiable.per.minimum_total))
|
|
146
|
-
: "";
|
|
147
|
-
return { countable, minimumTotal };
|
|
148
|
-
})();
|
|
149
|
-
const interval = formatTimeSpan(deps.translate, env.responsiveText, value.non_modifiable.interval.unit, value.non_modifiable.interval.value);
|
|
150
|
-
return (isMinimum +
|
|
151
|
-
responsive(env.responsiveText, () => `${formatCostP(cost) + deps.translate(" (casting)")} + ${(value.non_modifiable.is_minimum === true
|
|
152
|
-
? deps.translate("half of the activation cost")
|
|
153
|
-
: formatCostP(cost / 2)) +
|
|
154
|
-
per.countable +
|
|
155
|
-
deps.translate(" per {0}", interval)}`, () => `${formatCostP(cost)} + ${(value.non_modifiable.is_minimum === true
|
|
156
|
-
? "50%"
|
|
157
|
-
: formatCostP(cost / 2)) +
|
|
158
|
-
per.countable +
|
|
159
|
-
deps.translate("/{0}", interval)}`) +
|
|
160
|
-
per.minimumTotal +
|
|
161
|
-
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Cost, env.responsiveText));
|
|
162
|
-
}
|
|
142
|
+
case "Modifiable":
|
|
143
|
+
return getModifiableSustainedCostTranslation(getSkillModificationLevelById, locale, speed, entity, responsiveTextSize, value.modifiable);
|
|
144
|
+
case "NonModifiable":
|
|
145
|
+
return getNonModifiableSustainedCostTranslation(locale, entity, responsiveTextSize, value.non_modifiable);
|
|
163
146
|
default:
|
|
164
147
|
return assertExhaustive(value);
|
|
165
148
|
}
|
|
@@ -1,40 +1,21 @@
|
|
|
1
1
|
import { DurationForOneTime, DurationForSustained } from "optolith-database-schema/types/_ActivatableSkillDuration";
|
|
2
2
|
import { BlessingDuration } from "optolith-database-schema/types/Blessing";
|
|
3
3
|
import { CantripDuration } from "optolith-database-schema/types/Cantrip";
|
|
4
|
-
import {
|
|
4
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
5
5
|
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
6
6
|
/**
|
|
7
7
|
* Returns the text for the duration of a one-time activatable skill.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
translate: Translate;
|
|
11
|
-
translateMap: TranslateMap;
|
|
12
|
-
}, value: DurationForOneTime, env: {
|
|
13
|
-
responsiveText: ResponsiveTextSize;
|
|
14
|
-
}) => string;
|
|
9
|
+
export declare const getDurationForOneTimeTranslation: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: DurationForOneTime) => string;
|
|
15
10
|
/**
|
|
16
11
|
* Returns the text for the duration of a sustained activatable skill.
|
|
17
12
|
*/
|
|
18
|
-
export declare const
|
|
19
|
-
translate: Translate;
|
|
20
|
-
}, value: DurationForSustained | undefined, env: {
|
|
21
|
-
responsiveText: ResponsiveTextSize;
|
|
22
|
-
}) => string;
|
|
13
|
+
export declare const getDurationForSustainedTranslation: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: DurationForSustained | undefined) => string;
|
|
23
14
|
/**
|
|
24
15
|
* Returns the text for the duration of a cantrip.
|
|
25
16
|
*/
|
|
26
|
-
export declare const
|
|
27
|
-
translate: Translate;
|
|
28
|
-
translateMap: TranslateMap;
|
|
29
|
-
}, value: CantripDuration, env: {
|
|
30
|
-
responsiveText: ResponsiveTextSize;
|
|
31
|
-
}) => string;
|
|
17
|
+
export declare const getDurationTranslationForCantrip: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: CantripDuration) => string;
|
|
32
18
|
/**
|
|
33
19
|
* Returns the text for the duration of a blessing.
|
|
34
20
|
*/
|
|
35
|
-
export declare const
|
|
36
|
-
translate: Translate;
|
|
37
|
-
translateMap: TranslateMap;
|
|
38
|
-
}, value: BlessingDuration, env: {
|
|
39
|
-
responsiveText: ResponsiveTextSize;
|
|
40
|
-
}) => string;
|
|
21
|
+
export declare const getDurationTranslationForBlessing: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: BlessingDuration) => string;
|
|
@@ -1,58 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
3
|
import { getResponsiveText, replaceTextIfRequested, responsive, } from "../../responsiveText.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return replaceTextIfRequested(value.translations,
|
|
4
|
+
import { formatTimeSpan } from "../../units/timeSpan.js";
|
|
5
|
+
import { getCheckResultBasedValueTranslation } from "./checkResultBased.js";
|
|
6
|
+
import { wrapAsMaximum, wrapIfMaximum } from "./isMinimumMaximum.js";
|
|
7
|
+
import { appendInParensIfNotEmpty } from "./parensIf.js";
|
|
8
|
+
const getImmediateDurationTranslation = (locale, responsiveTextSize, value) => {
|
|
9
|
+
const text = appendInParensIfNotEmpty(mapNullable(value.maximum, (max) => {
|
|
10
|
+
const maxText = formatTimeSpan(locale, responsiveTextSize, max.unit, max.value);
|
|
11
|
+
return responsive(responsiveTextSize, () => locale.translate("no more than {0}", maxText), () => locale.translate("max. {0}", maxText));
|
|
12
|
+
}), locale.translate("Immediate"));
|
|
13
|
+
return replaceTextIfRequested("replacement", value.translations, locale.translateMap, responsiveTextSize, text);
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return text;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const getTextForFixedDuration = (deps, value, env) => {
|
|
26
|
-
const isMaximum = getTextForIsMaximum(value.is_maximum, deps.translate, env.responsiveText);
|
|
27
|
-
const unitValue = formatTimeSpan(deps.translate, env.responsiveText, value.unit, value.value);
|
|
28
|
-
const text = isMaximum + unitValue;
|
|
29
|
-
const translation = deps.translateMap(value.translations);
|
|
30
|
-
if (translation?.replacement !== undefined) {
|
|
31
|
-
return getResponsiveText(translation.replacement, env.responsiveText).replace("$1", text);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return text;
|
|
35
|
-
}
|
|
15
|
+
const getPermanentDurationTranslation = (locale, responsiveTextSize, value) => replaceTextIfRequested("replacement", value.translations, locale.translateMap, responsiveTextSize, locale.translate("Permanent"));
|
|
16
|
+
const getFixedDurationTranslation = (locale, responsiveTextSize, value) => {
|
|
17
|
+
const duration = formatTimeSpan(locale, responsiveTextSize, value.unit, value.value);
|
|
18
|
+
const durationWrappedIfMaximum = wrapIfMaximum(locale, responsiveTextSize, value.is_maximum, duration);
|
|
19
|
+
return replaceTextIfRequested("replacement", value.translations, locale.translateMap, responsiveTextSize, durationWrappedIfMaximum);
|
|
36
20
|
};
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
return
|
|
21
|
+
const getCheckResultBasedDurationTranslation = (locale, responsiveTextSize, value) => {
|
|
22
|
+
const duration = formatTimeSpan(locale, responsiveTextSize, value.unit, getCheckResultBasedValueTranslation(locale.translate, value));
|
|
23
|
+
return wrapIfMaximum(locale, responsiveTextSize, value.is_maximum, duration);
|
|
40
24
|
};
|
|
25
|
+
const getIndefiniteDurationTranslation = (locale, responsiveTextSize, value) => getResponsiveText(locale.translateMap(value.translations)?.description, responsiveTextSize);
|
|
41
26
|
/**
|
|
42
27
|
* Returns the text for the duration of a one-time activatable skill.
|
|
43
28
|
*/
|
|
44
|
-
export const
|
|
29
|
+
export const getDurationForOneTimeTranslation = (locale, responsiveTextSize, value) => {
|
|
45
30
|
switch (value.tag) {
|
|
46
31
|
case "Immediate":
|
|
47
|
-
return
|
|
32
|
+
return getImmediateDurationTranslation(locale, responsiveTextSize, value.immediate);
|
|
48
33
|
case "Permanent":
|
|
49
|
-
return
|
|
34
|
+
return getPermanentDurationTranslation(locale, responsiveTextSize, value.permanent);
|
|
50
35
|
case "Fixed":
|
|
51
|
-
return
|
|
36
|
+
return getFixedDurationTranslation(locale, responsiveTextSize, value.fixed);
|
|
52
37
|
case "CheckResultBased":
|
|
53
|
-
return
|
|
38
|
+
return getCheckResultBasedDurationTranslation(locale, responsiveTextSize, value.check_result_based);
|
|
54
39
|
case "Indefinite":
|
|
55
|
-
return
|
|
40
|
+
return getIndefiniteDurationTranslation(locale, responsiveTextSize, value.indefinite);
|
|
56
41
|
default:
|
|
57
42
|
return assertExhaustive(value);
|
|
58
43
|
}
|
|
@@ -60,25 +45,23 @@ export const getTextForDurationForOneTime = (deps, value, env) => {
|
|
|
60
45
|
/**
|
|
61
46
|
* Returns the text for the duration of a sustained activatable skill.
|
|
62
47
|
*/
|
|
63
|
-
export const
|
|
64
|
-
? responsive(
|
|
65
|
-
:
|
|
66
|
-
|
|
48
|
+
export const getDurationForSustainedTranslation = (locale, responsiveTextSize, value) => value === undefined
|
|
49
|
+
? responsive(responsiveTextSize, () => locale.translate("Sustained"), () => locale.translate("(S)"))
|
|
50
|
+
: wrapAsMaximum(locale, responsiveTextSize, formatTimeSpan(locale, responsiveTextSize, value.maximum.unit, value.maximum.value));
|
|
51
|
+
const getDurationDuringLovemakingTranslation = (locale, responsiveTextSize, value) => formatTimeSpan(locale, responsiveTextSize, value.unit, value.value);
|
|
67
52
|
/**
|
|
68
53
|
* Returns the text for the duration of a cantrip.
|
|
69
54
|
*/
|
|
70
|
-
export const
|
|
55
|
+
export const getDurationTranslationForCantrip = (locale, responsiveTextSize, value) => {
|
|
71
56
|
switch (value.tag) {
|
|
72
57
|
case "Immediate":
|
|
73
|
-
return
|
|
58
|
+
return getImmediateDurationTranslation(locale, responsiveTextSize, value.immediate);
|
|
74
59
|
case "Fixed":
|
|
75
|
-
return
|
|
60
|
+
return getFixedDurationTranslation(locale, responsiveTextSize, value.fixed);
|
|
76
61
|
case "Indefinite":
|
|
77
|
-
return
|
|
78
|
-
case "DuringLovemaking":
|
|
79
|
-
|
|
80
|
-
return formatTimeSpan(deps.translate, env.responsiveText, lovemakingUnit, lovemakingValue);
|
|
81
|
-
}
|
|
62
|
+
return getIndefiniteDurationTranslation(locale, responsiveTextSize, value.indefinite);
|
|
63
|
+
case "DuringLovemaking":
|
|
64
|
+
return getDurationDuringLovemakingTranslation(locale, responsiveTextSize, value.during_lovemaking);
|
|
82
65
|
default:
|
|
83
66
|
return assertExhaustive(value);
|
|
84
67
|
}
|
|
@@ -86,14 +69,14 @@ export const getTextForCantripDuration = (deps, value, env) => {
|
|
|
86
69
|
/**
|
|
87
70
|
* Returns the text for the duration of a blessing.
|
|
88
71
|
*/
|
|
89
|
-
export const
|
|
72
|
+
export const getDurationTranslationForBlessing = (locale, responsiveTextSize, value) => {
|
|
90
73
|
switch (value.tag) {
|
|
91
74
|
case "Immediate":
|
|
92
|
-
return
|
|
75
|
+
return getImmediateDurationTranslation(locale, responsiveTextSize, value.immediate);
|
|
93
76
|
case "Fixed":
|
|
94
|
-
return
|
|
77
|
+
return getFixedDurationTranslation(locale, responsiveTextSize, value.fixed);
|
|
95
78
|
case "Indefinite":
|
|
96
|
-
return
|
|
79
|
+
return getIndefiniteDurationTranslation(locale, responsiveTextSize, value.indefinite);
|
|
97
80
|
default:
|
|
98
81
|
return assertExhaustive(value);
|
|
99
82
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "optolith-database-schema/types/_ActivatableSkillEffect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
3
|
+
import { EntityDescriptionSection } from "../../../../index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Gets the text for the effect of an activatable skill.
|
|
6
6
|
*/
|
|
7
|
-
export declare const getTextForEffect: (
|
|
7
|
+
export declare const getTextForEffect: (locale: LocaleEnvironment, effect: Effect) => EntityDescriptionSection[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { filterNonNullable } from "@optolith/helpers/array";
|
|
2
2
|
import { mapNullable } from "@optolith/helpers/nullable";
|
|
3
3
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
4
|
-
const getContentPartsForQualityLevels = (
|
|
4
|
+
const getContentPartsForQualityLevels = (getQualityLevelString, locale, source) => filterNonNullable([
|
|
5
5
|
{
|
|
6
|
-
label: translate("Effect"),
|
|
6
|
+
label: locale.translate("Effect"),
|
|
7
7
|
value: source.text_before,
|
|
8
8
|
},
|
|
9
9
|
...source.quality_levels.map((text, index) => ({
|
|
10
10
|
value: text,
|
|
11
|
-
label: translate("QL {0}", getQualityLevelString(index)),
|
|
11
|
+
label: locale.translate("QL {0}", getQualityLevelString(index)),
|
|
12
12
|
})),
|
|
13
13
|
mapNullable(source.text_after, (textAfter) => ({
|
|
14
14
|
value: textAfter,
|
|
@@ -18,19 +18,19 @@ const getContentPartsForQualityLevels = (source, getQualityLevelString, translat
|
|
|
18
18
|
/**
|
|
19
19
|
* Gets the text for the effect of an activatable skill.
|
|
20
20
|
*/
|
|
21
|
-
export const getTextForEffect = (
|
|
21
|
+
export const getTextForEffect = (locale, effect) => {
|
|
22
22
|
switch (effect.tag) {
|
|
23
23
|
case "Plain":
|
|
24
24
|
return [
|
|
25
25
|
{
|
|
26
|
-
label: translate("Effect"),
|
|
26
|
+
label: locale.translate("Effect"),
|
|
27
27
|
value: effect.plain.text,
|
|
28
28
|
},
|
|
29
29
|
];
|
|
30
30
|
case "ForEachQualityLevel":
|
|
31
|
-
return getContentPartsForQualityLevels(
|
|
31
|
+
return getContentPartsForQualityLevels((index) => index + 1, locale, effect.for_each_quality_level);
|
|
32
32
|
case "ForEachTwoQualityLevels":
|
|
33
|
-
return getContentPartsForQualityLevels(
|
|
33
|
+
return getContentPartsForQualityLevels((index) => `${index * 2 + 1}–${index * 2 + 2}`, locale, effect.for_each_two_quality_levels);
|
|
34
34
|
default:
|
|
35
35
|
return assertExhaustive(effect);
|
|
36
36
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { FastOneTimePerformanceParameters, FastSustainedPerformanceParameters, SlowOneTimePerformanceParameters, SlowSustainedPerformanceParameters } from "optolith-database-schema/types/_ActivatableSkill";
|
|
2
2
|
import { GetById } from "../../../../helpers/getTypes.js";
|
|
3
|
-
import {
|
|
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 texts for all fast one-time performance parameters.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
11
|
-
translate: Translate;
|
|
12
|
-
translateMap: TranslateMap;
|
|
13
|
-
}, value: FastOneTimePerformanceParameters, env: {
|
|
14
|
-
entity: Entity;
|
|
15
|
-
responsiveText: ResponsiveTextSize;
|
|
16
|
-
}) => {
|
|
9
|
+
export declare const getFastOneTimePerformanceParametersTranslations: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: FastOneTimePerformanceParameters) => {
|
|
17
10
|
castingTime: string;
|
|
18
11
|
cost: string;
|
|
19
12
|
range: string;
|
|
@@ -22,14 +15,7 @@ export declare const getTextForFastOneTimePerformanceParameters: (deps: {
|
|
|
22
15
|
/**
|
|
23
16
|
* Get the texts for all fast sustained performance parameters.
|
|
24
17
|
*/
|
|
25
|
-
export declare const
|
|
26
|
-
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
27
|
-
translate: Translate;
|
|
28
|
-
translateMap: TranslateMap;
|
|
29
|
-
}, value: FastSustainedPerformanceParameters, env: {
|
|
30
|
-
entity: Entity;
|
|
31
|
-
responsiveText: ResponsiveTextSize;
|
|
32
|
-
}) => {
|
|
18
|
+
export declare const getFastSustainedPerformanceParametersTranslations: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: FastSustainedPerformanceParameters) => {
|
|
33
19
|
castingTime: string;
|
|
34
20
|
cost: string;
|
|
35
21
|
range: string;
|
|
@@ -38,14 +24,7 @@ export declare const getTextForFastSustainedPerformanceParameters: (deps: {
|
|
|
38
24
|
/**
|
|
39
25
|
* Get the texts for all slow one-time performance parameters.
|
|
40
26
|
*/
|
|
41
|
-
export declare const
|
|
42
|
-
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
43
|
-
translate: Translate;
|
|
44
|
-
translateMap: TranslateMap;
|
|
45
|
-
}, value: SlowOneTimePerformanceParameters, env: {
|
|
46
|
-
entity: Entity;
|
|
47
|
-
responsiveText: ResponsiveTextSize;
|
|
48
|
-
}) => {
|
|
27
|
+
export declare const getSlowOneTimePerformanceParametersTranslations: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: SlowOneTimePerformanceParameters) => {
|
|
49
28
|
castingTime: string;
|
|
50
29
|
cost: string;
|
|
51
30
|
range: string;
|
|
@@ -54,14 +33,7 @@ export declare const getTextForSlowOneTimePerformanceParameters: (deps: {
|
|
|
54
33
|
/**
|
|
55
34
|
* Get the texts for all slow sustained performance parameters.
|
|
56
35
|
*/
|
|
57
|
-
export declare const
|
|
58
|
-
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
59
|
-
translate: Translate;
|
|
60
|
-
translateMap: TranslateMap;
|
|
61
|
-
}, value: SlowSustainedPerformanceParameters, env: {
|
|
62
|
-
entity: Entity;
|
|
63
|
-
responsiveText: ResponsiveTextSize;
|
|
64
|
-
}) => {
|
|
36
|
+
export declare const getSlowSustainedPerformanceParametersTranslations: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, entity: Entity, responsiveTextSize: ResponsiveTextSize, value: SlowSustainedPerformanceParameters) => {
|
|
65
37
|
castingTime: string;
|
|
66
38
|
cost: string;
|
|
67
39
|
range: string;
|