@optolith/entity-descriptions 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/lib/creator.d.ts +2 -2
- package/lib/entities/activatable.js +35 -64
- package/lib/entities/condition.js +19 -24
- package/lib/entities/culture.js +18 -26
- package/lib/entities/curriculum.js +30 -33
- package/lib/entities/derivedCharacteristic.js +2 -1
- package/lib/entities/disease.js +3 -6
- package/lib/entities/elixir.js +6 -4
- package/lib/entities/equipment.js +17 -17
- package/lib/entities/equipmentPackage.js +4 -3
- package/lib/entities/experienceLevel.js +7 -7
- package/lib/entities/focusRule.js +2 -2
- package/lib/entities/influence.js +2 -2
- package/lib/entities/liturgicalChant.d.ts +1 -1
- package/lib/entities/liturgicalChant.js +11 -59
- package/lib/entities/partial/adventurePointsValue.js +14 -19
- package/lib/entities/partial/enhancements.d.ts +1 -1
- package/lib/entities/partial/enhancements.js +1 -1
- package/lib/entities/partial/herbary.js +13 -9
- package/lib/entities/partial/map.d.ts +3 -1
- package/lib/entities/partial/map.js +21 -8
- package/lib/entities/partial/mathOperation.js +12 -17
- package/lib/entities/partial/prerequisites/displayOption.d.ts +2 -2
- package/lib/entities/partial/prerequisites/index.d.ts +3 -3
- package/lib/entities/partial/prerequisites/index.js +10 -4
- package/lib/entities/partial/prerequisites/part.d.ts +1 -1
- package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +4 -4
- package/lib/entities/partial/prerequisites/prerequisiteGroups.js +1 -1
- package/lib/entities/partial/prerequisites/single/activatable.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/animistPower.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/animistPower.js +1 -1
- package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/culture.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/enhancement.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/influence.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/pact.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/primaryAttribute.js +1 -1
- package/lib/entities/partial/prerequisites/single/profession.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/publication.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/race.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/rated.d.ts +2 -2
- package/lib/entities/partial/prerequisites/single/rated.js +2 -2
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +1 -1
- package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/rule.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/sex.d.ts +1 -1
- package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +3 -3
- package/lib/entities/partial/prerequisites/single/state.d.ts +4 -4
- package/lib/entities/partial/prerequisites/single/text.d.ts +3 -3
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/castingTime.js +6 -8
- package/lib/entities/partial/rated/activatable/cost.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/cost.js +17 -14
- package/lib/entities/partial/rated/activatable/duration.js +4 -4
- package/lib/entities/partial/rated/activatable/effect.js +1 -1
- package/lib/entities/partial/rated/activatable/index.d.ts +6 -1
- package/lib/entities/partial/rated/activatable/index.js +25 -0
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +2 -2
- package/lib/entities/partial/rated/activatable/range.js +6 -6
- package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/targetCategory.js +2 -2
- package/lib/entities/partial/reader.d.ts +4 -2
- package/lib/entities/partial/responsiveText.d.ts +5 -1
- package/lib/entities/partial/responsiveText.js +3 -5
- package/lib/entities/partial/units/length.d.ts +1 -1
- package/lib/entities/partial/units/length.js +2 -10
- package/lib/entities/partial/units/timeSpan.d.ts +4 -4
- package/lib/entities/partial/units/timeSpan.js +21 -17
- package/lib/entities/personalityTrait.js +3 -4
- package/lib/entities/poison.js +4 -4
- package/lib/entities/profession.d.ts +1 -1
- package/lib/entities/profession.js +19 -14
- package/lib/entities/race.js +11 -13
- package/lib/entities/sexPractice.js +1 -3
- package/lib/entities/skill.js +2 -3
- package/lib/entities/spell.js +2 -14
- package/lib/helpers/getTypes.d.ts +2 -2
- package/lib/helpers/locale.d.ts +7 -2
- package/lib/helpers/translate.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -0
- package/lib/references/index.d.ts +1 -1
- package/lib/references/index.js +1 -1
- package/lib/references/page.d.ts +3 -3
- package/lib/references/page.js +1 -1
- package/lib/references/pageRange.d.ts +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MagicalActionIdentifier, RatedIdentifier, SpecialAbilityIdentifier } from "optolith-database-schema/gen";
|
|
2
2
|
import type { GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "../helpers/getTypes.js";
|
|
3
3
|
import { type GetResolvedSelectOptionById } from "./partial/prerequisites/single/activatable.js";
|
|
4
4
|
/**
|
|
@@ -24,6 +24,7 @@ const renderNumericListAcrossPackages = (packages, selector, equalityFn, renderT
|
|
|
24
24
|
.reduce((accR, pkg, pkgIndex) => accR.map2(selector(pkg), (acc, selected) => selected.reduce((filledAcc, [values, number]) => {
|
|
25
25
|
const existing = filledAcc.findIndex(([value]) => equalityFn(value, values));
|
|
26
26
|
if (existing >= 0) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- existing is checked to be >= 0
|
|
27
28
|
filledAcc[existing][1][pkgIndex] = number + defaultValue;
|
|
28
29
|
return filledAcc;
|
|
29
30
|
}
|
|
@@ -32,9 +33,7 @@ const renderNumericListAcrossPackages = (packages, selector, equalityFn, renderT
|
|
|
32
33
|
...filledAcc,
|
|
33
34
|
[
|
|
34
35
|
values,
|
|
35
|
-
Array(pkgIndex)
|
|
36
|
-
.fill(defaultValue)
|
|
37
|
-
.concat(number + defaultValue),
|
|
36
|
+
Array.from({ length: pkgIndex }, () => defaultValue).concat(number + defaultValue),
|
|
38
37
|
],
|
|
39
38
|
];
|
|
40
39
|
}
|
|
@@ -117,12 +116,11 @@ const getTotalingAPValues = (professionPackages, selector) => {
|
|
|
117
116
|
return undefined;
|
|
118
117
|
}
|
|
119
118
|
return allSame(options, deepEqual)
|
|
120
|
-
?
|
|
119
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- not all are nullish and because all are the same, none is nullish
|
|
120
|
+
options[0].ap_value
|
|
121
121
|
: options.map(option => option?.ap_value ?? 0).join("/");
|
|
122
122
|
};
|
|
123
|
-
const renderSkillsOption = (professionPackages, skillGroup) => mapNullable(getTotalingAPValues(professionPackages, pkg => pkg.content.options?.skills?.group === skillGroup.id
|
|
124
|
-
? pkg.content.options?.skills
|
|
125
|
-
: undefined), apValue => translateR("{$apValue} AP to improve other {$skillsOfGroup}", {
|
|
123
|
+
const renderSkillsOption = (professionPackages, skillGroup) => mapNullable(getTotalingAPValues(professionPackages, pkg => pkg.content.options?.skills?.group === skillGroup.id ? pkg.content.options.skills : undefined), apValue => translateR("{$apValue} AP to improve other {$skillsOfGroup}", {
|
|
126
124
|
apValue,
|
|
127
125
|
skillsOfGroup: skillGroup.nameOfSkillsOfGroup,
|
|
128
126
|
})) ?? Reader.of(undefined);
|
|
@@ -171,6 +169,7 @@ const renderCantripsOption = (professionPackages) => {
|
|
|
171
169
|
return Reader.of(undefined);
|
|
172
170
|
}
|
|
173
171
|
if (allSame(cantripsOptions, deepEqual)) {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- not all are nullish and because all are the same, none is nullish
|
|
174
173
|
return renderSingleCantripsOption(cantripsOptions[0]);
|
|
175
174
|
}
|
|
176
175
|
else {
|
|
@@ -245,7 +244,7 @@ const renderVariantSkillsOption = (baseOptions, variantOptions) => renderVariant
|
|
|
245
244
|
apValue: override.ap_value,
|
|
246
245
|
skillsOfGroup: nameOfSkillsOfGroup,
|
|
247
246
|
})),
|
|
248
|
-
update: (base, override) => plainOrInsteadOfR(base, override, b => b.ap_value, equal, Reader.of).thenW(apValue => plainOrInsteadOfR(base, override, b => b.group, equal, nameOfSkillsOfGroupR).thenW(nameOfSkillsOfGroup => translateR("{$apValue} AP to improve other {$skillsOfGroup}", {
|
|
247
|
+
update: (base, override) => plainOrInsteadOfR(base, override, b => b.ap_value, equal, b => Reader.of(b)).thenW(apValue => plainOrInsteadOfR(base, override, b => b.group, equal, nameOfSkillsOfGroupR).thenW(nameOfSkillsOfGroup => translateR("{$apValue} AP to improve other {$skillsOfGroup}", {
|
|
249
248
|
apValue,
|
|
250
249
|
skillsOfGroup: nameOfSkillsOfGroup,
|
|
251
250
|
}))),
|
|
@@ -389,10 +388,11 @@ const renderBlessings = (professionPackages) => {
|
|
|
389
388
|
return Reader.of(undefined);
|
|
390
389
|
}
|
|
391
390
|
else if (allSame(traditions, deepEqual)) {
|
|
391
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- not all are empty and because all are the same, none is empty
|
|
392
392
|
return renderSingleBlessings(traditions[0]);
|
|
393
393
|
}
|
|
394
394
|
else {
|
|
395
|
-
return Reader.traverse(traditions, option => option ===
|
|
395
|
+
return Reader.traverse(traditions, option => option.length === 0 ? Reader.of("—") : renderSingleBlessings(option)).map(list => list.join(" / "));
|
|
396
396
|
}
|
|
397
397
|
};
|
|
398
398
|
const renderLiturgicalChantName = (liturgyIds) => Reader.traverse(liturgyIds, strictNameR).thenW(list => localeJoinR(list, "disjunction"));
|
|
@@ -404,7 +404,7 @@ const renderLiturgicalChants = (professionPackages) => Reader.sequence([
|
|
|
404
404
|
const renderRatedVariantChanges = (baseList, variantList, renderInstance) => Reader.traverse(variantList ?? [], ({ id, rating_modifier }) => {
|
|
405
405
|
const baseValue = baseList?.find(item => deepEqual(item.id, id))?.rating_modifier ?? 0;
|
|
406
406
|
return renderInstance(id).thenW(name => translateR("{$replacement} instead of {$base}", {
|
|
407
|
-
replacement: `${name} ${baseValue + rating_modifier}`,
|
|
407
|
+
replacement: `${name} ${(baseValue + rating_modifier).toFixed()}`,
|
|
408
408
|
base: baseValue,
|
|
409
409
|
}));
|
|
410
410
|
}).thenW(localeSortR);
|
|
@@ -495,9 +495,14 @@ export const getProfessionVersionEntityDescription = createEntityDescriptionCrea
|
|
|
495
495
|
}
|
|
496
496
|
return {
|
|
497
497
|
title: translation.name.default +
|
|
498
|
-
(
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
parensIf(ensureNonEmpty([
|
|
499
|
+
translation.specification?.default,
|
|
500
|
+
professionPackages.length > 1
|
|
501
|
+
? professionPackages
|
|
502
|
+
.map(pkg => translateMap(pkg.experienceLevel.translations)?.name)
|
|
503
|
+
.join("/")
|
|
504
|
+
: undefined,
|
|
505
|
+
].filter(isNotNullish))?.join(", ")),
|
|
501
506
|
className: "profession",
|
|
502
507
|
body: [
|
|
503
508
|
{
|
|
@@ -529,7 +534,7 @@ export const getProfessionVersionEntityDescription = createEntityDescriptionCrea
|
|
|
529
534
|
curses: pkg.content.options?.curses,
|
|
530
535
|
list: pkg.content.special_abilities,
|
|
531
536
|
}), deepEqual, specialAbilityLists => Reader.of(specialAbilityLists
|
|
532
|
-
.map(specialAbilities => specialAbilities === undefined
|
|
537
|
+
.map(specialAbilities => Object.values(specialAbilities).every(list => list === undefined)
|
|
533
538
|
? translate("none")
|
|
534
539
|
: renderSpecialAbilities(specialAbilities).run(env))
|
|
535
540
|
.join(" / "))).run(env),
|
package/lib/entities/race.js
CHANGED
|
@@ -10,11 +10,10 @@ import { renderCommonnessRatedAdvantagesAndDisadvantages, renderCommonnessRatedA
|
|
|
10
10
|
import { MISSING_VALUE } from "./partial/unknown.js";
|
|
11
11
|
const renderBaseValueItem = (label, value) => Reader.asks(({ translate }) => ({
|
|
12
12
|
label: translate(label),
|
|
13
|
-
value: value < 0 ? sign(value) : value.
|
|
13
|
+
value: value < 0 ? sign(value) : value.toFixed(),
|
|
14
14
|
}));
|
|
15
15
|
const renderAttributeAdjustmentsItem = (totalAttributesCount, adjustments) => Reader.asks(({ translate, translateMap, localeJoin, getInstanceById, }) => {
|
|
16
|
-
const getAttributeAbbreviation = (id) => translateMap(getInstanceById("Attribute", id)?.translations)
|
|
17
|
-
?.abbreviation ?? MISSING_VALUE;
|
|
16
|
+
const getAttributeAbbreviation = (id) => translateMap(getInstanceById("Attribute", id)?.translations)?.abbreviation ?? MISSING_VALUE;
|
|
18
17
|
return {
|
|
19
18
|
label: translate("Attribute Adjustments"),
|
|
20
19
|
value: [
|
|
@@ -35,7 +34,9 @@ const renderVariantValues = (label, variants, selector, renderValue, translation
|
|
|
35
34
|
};
|
|
36
35
|
});
|
|
37
36
|
const sameValues = anySameIndices(values, on(value => [value.value, value.valueTranslation], deepEqual));
|
|
38
|
-
if (sameValues
|
|
37
|
+
if (isNotEmpty(sameValues) &&
|
|
38
|
+
sameValues.length === 1 &&
|
|
39
|
+
sameValues[0].length === values.length) {
|
|
39
40
|
return {
|
|
40
41
|
label: translate(label),
|
|
41
42
|
value: values[0] === undefined
|
|
@@ -50,9 +51,7 @@ const renderVariantValues = (label, variants, selector, renderValue, translation
|
|
|
50
51
|
{
|
|
51
52
|
type: "definitionList",
|
|
52
53
|
style: "nested",
|
|
53
|
-
items: Map.groupBy(values
|
|
54
|
-
.toSorted(on(item => item.name, localeCompare))
|
|
55
|
-
.map(value => ({
|
|
54
|
+
items: Map.groupBy(values.toSorted(on(item => item.name, localeCompare)).map(value => ({
|
|
56
55
|
label: value.name,
|
|
57
56
|
value: value.valueTranslation ?? renderValue(value.value),
|
|
58
57
|
})), item => item.value)
|
|
@@ -72,17 +71,14 @@ const renderAutomaticAdvantagesOrDisadvantages = (entity, items) => Reader.asks(
|
|
|
72
71
|
: items
|
|
73
72
|
.map(item => {
|
|
74
73
|
const instanceTranslation = translateMap(getInstanceById(entity, item.id)?.translations);
|
|
75
|
-
return (instanceTranslation?.name_in_library ??
|
|
76
|
-
instanceTranslation?.name ??
|
|
77
|
-
MISSING_VALUE);
|
|
74
|
+
return (instanceTranslation?.name_in_library ?? instanceTranslation?.name ?? MISSING_VALUE);
|
|
78
75
|
})
|
|
79
76
|
.toSorted(localeCompare)
|
|
80
77
|
.join(", "));
|
|
81
78
|
const renderCommonCultures = (items) => Reader.asks(({ translate, translateMap, getInstanceById, localeCompare }) => items === undefined || !isNotEmpty(items)
|
|
82
79
|
? translate("none")
|
|
83
80
|
: items
|
|
84
|
-
.map(itemId => translateMap(getInstanceById("Culture", itemId)?.translations)
|
|
85
|
-
?.name)
|
|
81
|
+
.map(itemId => translateMap(getInstanceById("Culture", itemId)?.translations)?.name)
|
|
86
82
|
.filter(isNotNullish)
|
|
87
83
|
.toSorted(localeCompare)
|
|
88
84
|
.join(", "));
|
|
@@ -112,7 +108,9 @@ export const getRaceEntityDescription = createEntityDescriptionCreator(({ getIns
|
|
|
112
108
|
items: [
|
|
113
109
|
{
|
|
114
110
|
label: translate("AP Value"),
|
|
115
|
-
value: translate(".input {$value :number} {{{$value} Adventure Points}}", {
|
|
111
|
+
value: translate(".input {$value :number} {{{$value} Adventure Points}}", {
|
|
112
|
+
value: entry.ap_value,
|
|
113
|
+
}),
|
|
116
114
|
},
|
|
117
115
|
renderBaseValueItem("Life Point Base Value", entry.base_values.life_points).run(env),
|
|
118
116
|
renderBaseValueItem("Spirit Base Value", entry.base_values.spirit).run(env),
|
|
@@ -22,9 +22,7 @@ export const getSexPracticeEntityDescription = createEntityDescriptionCreator((_
|
|
|
22
22
|
label: translate("Prerequisites"),
|
|
23
23
|
value: translation.prerequisites,
|
|
24
24
|
},
|
|
25
|
-
translation.failed
|
|
26
|
-
? undefined
|
|
27
|
-
: { label: translate("Failed"), value: translation.failed },
|
|
25
|
+
{ label: translate("Failed"), value: translation.failed },
|
|
28
26
|
],
|
|
29
27
|
},
|
|
30
28
|
],
|
package/lib/entities/skill.js
CHANGED
|
@@ -109,10 +109,9 @@ export const getSkillEntityDescription = createEntityDescriptionCreator(({ getIn
|
|
|
109
109
|
? translate("Yes")
|
|
110
110
|
: entry.encumbrance.kind === "No"
|
|
111
111
|
? translate("No")
|
|
112
|
-
: (translation.encumbrance_description ??
|
|
113
|
-
translate("Maybe")),
|
|
112
|
+
: (translation.encumbrance_description ?? translate("Maybe")),
|
|
114
113
|
},
|
|
115
|
-
translation
|
|
114
|
+
translation.tools === undefined
|
|
116
115
|
? undefined
|
|
117
116
|
: {
|
|
118
117
|
label: translate("Tools"),
|
package/lib/entities/spell.js
CHANGED
|
@@ -16,7 +16,7 @@ import { renderCastingTime, renderFastSkillNonModifiableCastingTime, renderSlowS
|
|
|
16
16
|
import { renderMagicalActionCost, renderModifiableOneTimeCost, renderNonModifiableOneTimeCost, } from "./partial/rated/activatable/cost.js";
|
|
17
17
|
import { renderCheckResultBasedDuration, renderMusicDuration, renderOneTimeDuration, renderSustainedDuration, } from "./partial/rated/activatable/duration.js";
|
|
18
18
|
import { renderEffect } from "./partial/rated/activatable/effect.js";
|
|
19
|
-
import { renderFastPerformanceParameters, renderSlowOneTimePerformanceParameters, renderSlowPerformanceParameters, } from "./partial/rated/activatable/index.js";
|
|
19
|
+
import { combineGeneratedTextWithStaticTranslation, renderFastPerformanceParameters, renderSlowOneTimePerformanceParameters, renderSlowPerformanceParameters, } from "./partial/rated/activatable/index.js";
|
|
20
20
|
import { ModifiableParameter } from "./partial/rated/activatable/nonModifiableSuffix.js";
|
|
21
21
|
import { parensIf } from "./partial/rated/activatable/parensIf.js";
|
|
22
22
|
import { renderNonModifiableRange } from "./partial/rated/activatable/range.js";
|
|
@@ -28,18 +28,6 @@ import { formatEnergyR, localeJoinR, responsiveR, responsiveTextR, responsiveTra
|
|
|
28
28
|
import { appendNoteIfNeeded, getResponsiveText, ResponsiveTextSize, } from "./partial/responsiveText.js";
|
|
29
29
|
import { formatTimeSpanR } from "./partial/units/timeSpan.js";
|
|
30
30
|
import { MISSING_VALUE } from "./partial/unknown.js";
|
|
31
|
-
const combineGeneratedTextWithStaticTranslation = (label, generatedText, staticText) => {
|
|
32
|
-
if (generatedText === undefined) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
const normalizedStaticText = typeof staticText === "string" ? staticText : staticText?.full;
|
|
36
|
-
return {
|
|
37
|
-
label,
|
|
38
|
-
value: normalizedStaticText !== undefined && generatedText !== normalizedStaticText
|
|
39
|
-
? `***${generatedText}*** (${normalizedStaticText})`
|
|
40
|
-
: generatedText,
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
31
|
const renderProperty = (id) => Reader.asks(({ translate, translateMap, getInstanceById }) => {
|
|
44
32
|
const text = (() => {
|
|
45
33
|
const staticEntry = getInstanceById("Property", id);
|
|
@@ -854,7 +842,7 @@ const renderMagicalRuneCost = (options, cost) => {
|
|
|
854
842
|
case "Disjunction":
|
|
855
843
|
return Reader.sequence(cost.Disjunction.list.map(costItem => formatEnergyR(costItem.value).thenW(text => appendNoteIfNeeded(costItem.translations, text)))).thenW(text => localeJoinR(text, "disjunction"));
|
|
856
844
|
case "DerivedFromOption":
|
|
857
|
-
return deriveValueGroupsFromMagicalRuneOptions(options, option => option.cost?.value, compareNullish(numAsc), num => num?.
|
|
845
|
+
return deriveValueGroupsFromMagicalRuneOptions(options, option => option.cost?.value, compareNullish(numAsc), num => num?.toFixed() ?? MISSING_VALUE).thenW(formatEnergyR);
|
|
858
846
|
default:
|
|
859
847
|
return assertExhaustive(cost);
|
|
860
848
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as Database from "optolith-database-schema/gen";
|
|
2
|
-
import { IdArgsVariant } from "tsondb/schema/gen";
|
|
1
|
+
import type * as Database from "optolith-database-schema/gen";
|
|
2
|
+
import type { IdArgsVariant } from "tsondb/schema/gen";
|
|
3
3
|
export type GetInstanceById<in T extends Extract<keyof Database.EntityMap, string>> = <U extends T>(...args: IdArgsVariant<Database.EntityMap, U>) => Database.EntityMap[U] | undefined;
|
|
4
4
|
export type GetAllInstances<T extends keyof Database.EntityMap> = <U extends T>(entity: U) => {
|
|
5
5
|
id: string;
|
package/lib/helpers/locale.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Compare } from "@optolith/helpers/compare";
|
|
1
|
+
import type { Compare } from "@optolith/helpers/compare";
|
|
2
2
|
import type { LocaleMeasurementAdjustments } from "optolith-database-schema/gen";
|
|
3
|
-
import { Translate, TranslateMap
|
|
3
|
+
import type { Format, Translate, TranslateMap } from "./translate.js";
|
|
4
4
|
/**
|
|
5
5
|
* The type of list to join in a locale-aware way.
|
|
6
6
|
*/
|
|
@@ -12,6 +12,7 @@ export type LocaleEnvironment = {
|
|
|
12
12
|
id: string;
|
|
13
13
|
format: Format;
|
|
14
14
|
formatDate: (date: Date) => string;
|
|
15
|
+
formatNumber: FormatNumber;
|
|
15
16
|
translate: Translate;
|
|
16
17
|
translateMap: TranslateMap;
|
|
17
18
|
compare: LocaleCompare;
|
|
@@ -26,3 +27,7 @@ export type LocaleCompare = Compare<string>;
|
|
|
26
27
|
* A function that joins a list of strings according to the locale's rules for the given type.
|
|
27
28
|
*/
|
|
28
29
|
export type LocaleJoin = (list: string[], type: LocaleJoinType) => string;
|
|
30
|
+
/**
|
|
31
|
+
* A function that formats a number according to the locale’s rules.
|
|
32
|
+
*/
|
|
33
|
+
export type FormatNumber = (value: number) => string;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,13 +6,14 @@ import type { EntityDescriptionCreator } from "./creator.js";
|
|
|
6
6
|
import type { GetResolvedSelectOptionById } from "./entities/partial/prerequisites/single/activatable.js";
|
|
7
7
|
import type { CountInstances, GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "./helpers/getTypes.js";
|
|
8
8
|
import type { LocaleEnvironment } from "./helpers/locale.js";
|
|
9
|
-
export { LocaleEnvironment };
|
|
9
|
+
export type { LocaleEnvironment };
|
|
10
10
|
/**
|
|
11
11
|
* A JSON representation of the rules text for a library entry.
|
|
12
12
|
*/
|
|
13
13
|
export type EntityDescription = {
|
|
14
14
|
title: string;
|
|
15
15
|
subtitle?: string;
|
|
16
|
+
badge?: number;
|
|
16
17
|
className: string;
|
|
17
18
|
body: EntityDescriptionSection[];
|
|
18
19
|
errata?: {
|
|
@@ -44,6 +45,7 @@ export type EntityDescriptionSectionContent<DL = DefinitionListEntityDescription
|
|
|
44
45
|
export type RawEntityDescription = {
|
|
45
46
|
title: string;
|
|
46
47
|
subtitle?: string;
|
|
48
|
+
badge?: number;
|
|
47
49
|
className: string;
|
|
48
50
|
body: (RawEntityDescriptionSection | undefined)[];
|
|
49
51
|
errata?: Errata;
|
package/lib/index.js
CHANGED
|
@@ -171,6 +171,7 @@ export const supportedEntities = Object.keys(registeredEntityDescriptionCreators
|
|
|
171
171
|
/**
|
|
172
172
|
* Get a JSON representation of the rules text for an entry in the database.
|
|
173
173
|
*/
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive
|
|
174
175
|
export const getEntityDescription = (database, localeEnv, idMap, getResolvedSelectOptionById, getAllResolvedSelectOptions, getAllResolvedNewSkillApplications, getAllResolvedSkillUses, entityName, instanceId) => {
|
|
175
176
|
const creator = registeredEntityDescriptionCreators[entityName];
|
|
176
177
|
const instance = database.getInstanceOfEntityById(entityName, instanceId);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PublicationRefs } from "optolith-database-schema/gen";
|
|
2
2
|
import type { GetInstanceById } from "../helpers/getTypes.js";
|
|
3
|
-
import { LocaleEnvironment } from "../helpers/locale.js";
|
|
3
|
+
import type { LocaleEnvironment } from "../helpers/locale.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns the translation of the references.
|
|
6
6
|
*/
|
package/lib/references/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNotNullish } from "@optolith/helpers/nullable";
|
|
2
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
-
import { fromRawPageRange, normalizePageRanges, printPageRanges
|
|
3
|
+
import { fromRawPageRange, normalizePageRanges, printPageRanges } from "./pageRange.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns the translation of the references.
|
|
6
6
|
*/
|
package/lib/references/page.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Compare } from "@optolith/helpers/compare";
|
|
2
|
-
import { Page } from "optolith-database-schema/gen";
|
|
3
|
-
import { Translate } from "../helpers/translate.js";
|
|
1
|
+
import type { Compare } from "@optolith/helpers/compare";
|
|
2
|
+
import type { Page } from "optolith-database-schema/gen";
|
|
3
|
+
import type { Translate } from "../helpers/translate.js";
|
|
4
4
|
/**
|
|
5
5
|
* A comparison function for two pages.
|
|
6
6
|
*/
|
package/lib/references/page.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Page, PageRange as RawPageRange } from "optolith-database-schema/gen";
|
|
2
|
-
import { Translate } from "../helpers/translate.js";
|
|
1
|
+
import type { Page, PageRange as RawPageRange } from "optolith-database-schema/gen";
|
|
2
|
+
import type { Translate } from "../helpers/translate.js";
|
|
3
3
|
/**
|
|
4
4
|
* A range of pages, including the first and last page, if the range includes
|
|
5
5
|
* more than on page.
|