@optolith/entity-descriptions 0.2.1 → 0.3.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 +65 -0
- package/lib/creator.d.ts +32 -0
- package/lib/creator.js +72 -0
- package/lib/entities/activatable.d.ts +52 -0
- package/lib/entities/activatable.js +609 -0
- package/lib/entities/alternativeRule.d.ts +7 -0
- package/lib/entities/alternativeRule.js +21 -0
- package/lib/entities/attribute.d.ts +6 -0
- package/lib/entities/attribute.js +15 -0
- package/lib/entities/combatTechnique.d.ts +5 -7
- package/lib/entities/combatTechnique.js +34 -24
- package/lib/entities/condition.d.ts +12 -0
- package/lib/entities/condition.js +63 -0
- package/lib/entities/culture.d.ts +8 -0
- package/lib/entities/culture.js +309 -0
- package/lib/entities/curriculum.d.ts +11 -0
- package/lib/entities/curriculum.js +266 -0
- package/lib/entities/derivedCharacteristic.d.ts +9 -0
- package/lib/entities/derivedCharacteristic.js +91 -0
- package/lib/entities/disease.d.ts +9 -0
- package/lib/entities/disease.js +88 -0
- package/lib/entities/elixir.d.ts +10 -0
- package/lib/entities/elixir.js +76 -0
- package/lib/entities/equipment.d.ts +24 -0
- package/lib/entities/equipment.js +605 -0
- package/lib/entities/equipmentPackage.d.ts +8 -0
- package/lib/entities/equipmentPackage.js +300 -0
- package/lib/entities/experienceLevel.d.ts +3 -2
- package/lib/entities/experienceLevel.js +33 -28
- package/lib/entities/focusRule.d.ts +3 -4
- package/lib/entities/focusRule.js +13 -5
- package/lib/entities/influence.d.ts +11 -0
- package/lib/entities/influence.js +43 -0
- package/lib/entities/liturgicalChant.d.ts +13 -23
- package/lib/entities/liturgicalChant.js +171 -131
- package/lib/entities/optionalRule.d.ts +3 -2
- package/lib/entities/optionalRule.js +4 -3
- package/lib/entities/partial/activatableNameChunks.d.ts +58 -0
- package/lib/entities/partial/activatableNameChunks.js +356 -0
- package/lib/entities/partial/adventurePointsValue.d.ts +9 -0
- package/lib/entities/partial/adventurePointsValue.js +243 -0
- package/lib/entities/partial/animalTypes.d.ts +11 -0
- package/lib/entities/partial/animalTypes.js +13 -0
- package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.d.ts +16 -0
- package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.js +40 -0
- package/lib/entities/partial/dice.d.ts +10 -0
- package/lib/entities/partial/dice.js +13 -0
- package/lib/entities/partial/enhancements.d.ts +7 -0
- package/lib/entities/partial/enhancements.js +26 -0
- package/lib/entities/partial/herbary.d.ts +28 -0
- package/lib/entities/partial/herbary.js +65 -0
- package/lib/entities/partial/map.d.ts +49 -0
- package/lib/entities/partial/map.js +43 -0
- package/lib/entities/partial/mathOperation.d.ts +36 -0
- package/lib/entities/partial/mathOperation.js +107 -0
- package/lib/entities/partial/prerequisites/displayOption.d.ts +7 -0
- package/lib/entities/partial/prerequisites/displayOption.js +19 -0
- package/lib/entities/partial/prerequisites/index.d.ts +67 -0
- package/lib/entities/partial/prerequisites/index.js +189 -0
- package/lib/entities/partial/prerequisites/part.d.ts +26 -0
- package/lib/entities/partial/prerequisites/part.js +88 -0
- package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +65 -0
- package/lib/entities/partial/prerequisites/prerequisiteGroups.js +278 -0
- package/lib/entities/partial/prerequisites/single/activatable.d.ts +18 -0
- package/lib/entities/partial/prerequisites/single/activatable.js +40 -0
- package/lib/entities/partial/prerequisites/single/animistPower.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/animistPower.js +23 -0
- package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/blessedTradition.js +32 -0
- package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +6 -0
- package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.js +19 -0
- package/lib/entities/partial/prerequisites/single/culture.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/culture.js +20 -0
- package/lib/entities/partial/prerequisites/single/enhancement.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/enhancement.js +41 -0
- package/lib/entities/partial/prerequisites/single/influence.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/influence.js +17 -0
- package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/magicalTradition.js +27 -0
- package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +6 -0
- package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.js +8 -0
- package/lib/entities/partial/prerequisites/single/pact.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/pact.js +30 -0
- package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/personalityTrait.js +28 -0
- package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/primaryAttribute.js +15 -0
- package/lib/entities/partial/prerequisites/single/profession.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/profession.js +19 -0
- package/lib/entities/partial/prerequisites/single/publication.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/publication.js +19 -0
- package/lib/entities/partial/prerequisites/single/race.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/race.js +20 -0
- package/lib/entities/partial/prerequisites/single/rated.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/rated.js +41 -0
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +89 -0
- package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/ratedSum.js +21 -0
- package/lib/entities/partial/prerequisites/single/rule.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/rule.js +4 -0
- package/lib/entities/partial/prerequisites/single/sex.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/sex.js +19 -0
- package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/sexualCharacteristic.js +21 -0
- package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/socialStatus.js +21 -0
- package/lib/entities/partial/prerequisites/single/state.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/state.js +20 -0
- package/lib/entities/partial/prerequisites/single/text.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/text.js +9 -0
- package/lib/entities/partial/professions.d.ts +15 -0
- package/lib/entities/partial/professions.js +19 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +16 -7
- package/lib/entities/partial/rated/activatable/castingTime.js +35 -20
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +18 -3
- package/lib/entities/partial/rated/activatable/checkResultBased.js +18 -10
- package/lib/entities/partial/rated/activatable/cost.d.ts +88 -8
- package/lib/entities/partial/rated/activatable/cost.js +183 -115
- package/lib/entities/partial/rated/activatable/duration.d.ts +36 -13
- package/lib/entities/partial/rated/activatable/duration.js +72 -61
- package/lib/entities/partial/rated/activatable/effect.d.ts +4 -4
- package/lib/entities/partial/rated/activatable/effect.js +32 -25
- package/lib/entities/partial/rated/activatable/index.d.ts +31 -27
- package/lib/entities/partial/rated/activatable/index.js +63 -28
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +5 -6
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +8 -5
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +2 -4
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +7 -42
- package/lib/entities/partial/rated/activatable/range.d.ts +22 -14
- package/lib/entities/partial/rated/activatable/range.js +54 -54
- package/lib/entities/partial/rated/activatable/speed.d.ts +11 -2
- package/lib/entities/partial/rated/activatable/speed.js +14 -1
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +4 -5
- package/lib/entities/partial/rated/activatable/targetCategory.js +19 -24
- package/lib/entities/partial/rated/improvementCost.d.ts +8 -4
- package/lib/entities/partial/rated/improvementCost.js +9 -4
- package/lib/entities/partial/rated/skillCheck.d.ts +20 -17
- package/lib/entities/partial/rated/skillCheck.js +56 -54
- package/lib/entities/partial/reader.d.ts +266 -0
- package/lib/entities/partial/reader.js +175 -0
- package/lib/entities/partial/responsiveText.d.ts +10 -5
- package/lib/entities/partial/responsiveText.js +19 -3
- package/lib/entities/partial/units/energy.d.ts +5 -8
- package/lib/entities/partial/units/energy.js +5 -23
- package/lib/entities/partial/units/length.d.ts +20 -2
- package/lib/entities/partial/units/length.js +24 -5
- package/lib/entities/partial/units/timeSpan.d.ts +25 -4
- package/lib/entities/partial/units/timeSpan.js +27 -15
- package/lib/entities/partial/unknown.d.ts +5 -1
- package/lib/entities/partial/unknown.js +5 -1
- package/lib/entities/personalityTrait.d.ts +7 -0
- package/lib/entities/personalityTrait.js +56 -0
- package/lib/entities/poison.d.ts +12 -0
- package/lib/entities/poison.js +368 -0
- package/lib/entities/profession.d.ts +12 -0
- package/lib/entities/profession.js +585 -0
- package/lib/entities/race.d.ts +9 -0
- package/lib/entities/race.js +146 -0
- package/lib/entities/sexPractice.d.ts +6 -0
- package/lib/entities/sexPractice.js +33 -0
- package/lib/entities/skill.d.ts +9 -9
- package/lib/entities/skill.js +124 -91
- package/lib/entities/spell.d.ts +86 -26
- package/lib/entities/spell.js +842 -147
- package/lib/entities/state.d.ts +6 -0
- package/lib/entities/state.js +17 -0
- package/lib/helpers/enums.d.ts +11 -0
- package/lib/helpers/enums.js +6 -0
- package/lib/helpers/getTypes.d.ts +12 -482
- package/lib/helpers/getTypes.js +1 -0
- package/lib/helpers/identifiers.d.ts +314 -0
- package/lib/helpers/identifiers.js +333 -0
- package/lib/helpers/locale.d.ts +21 -2
- package/lib/helpers/translate.d.ts +47 -5
- package/lib/helpers/translate.js +13 -6
- package/lib/index.d.ts +854 -21
- package/lib/index.js +182 -17
- package/lib/references/index.d.ts +6 -3
- package/lib/references/index.js +25 -33
- package/lib/references/page.d.ts +1 -1
- package/lib/references/page.js +14 -14
- package/lib/references/pageRange.d.ts +1 -5
- package/lib/references/pageRange.js +7 -16
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +31 -10
- package/.prettierrc.yml +0 -1
- package/lib/entities/partial/rated/activatable/entity.d.ts +0 -11
- package/lib/entities/partial/rated/activatable/entity.js +0 -12
- package/lib/references/occurrence.d.ts +0 -4
- package/lib/references/occurrence.js +0 -3
|
@@ -1,149 +1,217 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { identity } from "@elyukai/utils/function";
|
|
2
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
3
|
+
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
4
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { renderResponsiveMap } from "../../map.js";
|
|
6
|
+
import { additionFormatter } from "../../mathOperation.js";
|
|
7
|
+
import { formatEnergyFnR, formatEnergyR, getInstanceByIdFnR, modifiableBySpeedR, responsiveLocaleJoinR, responsiveR, responsiveTextR, responsiveTranslateR, translateMapR, translateR, } from "../../reader.js";
|
|
8
|
+
import { appendNoteIfNeeded, replaceTextIfNeeded, } from "../../responsiveText.js";
|
|
9
|
+
import { formatCombinedTimeSpanR } from "../../units/timeSpan.js";
|
|
6
10
|
import { MISSING_VALUE } from "../../unknown.js";
|
|
11
|
+
import { appendCheckResultModifier } from "./checkResultBased.js";
|
|
7
12
|
import { wrapIfMinimum } from "./isMinimumMaximum.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const withNote = appendNoteIfRequested("note", value.translations, locale.translateMap, responsiveTextSize, costWrappedIfMinimum);
|
|
29
|
-
const cannotModify = getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize);
|
|
30
|
-
return withNote + cannotModify;
|
|
13
|
+
import { appendNonModifiableSuffix, ModifiableParameter, } from "./nonModifiableSuffix.js";
|
|
14
|
+
const deriveModifiableCost = (modificationLevelId) => getInstanceByIdFnR().thenW(getInstanceById => mapNullable(getInstanceById("SkillModificationLevel", modificationLevelId), modificationLevel => modifiableBySpeedR("cost", modificationLevel)) ?? Reader.of(undefined));
|
|
15
|
+
const appendPerCountableToCostIfNeeded = (value, baseCost) => {
|
|
16
|
+
if (value === undefined) {
|
|
17
|
+
return Reader.of(baseCost);
|
|
18
|
+
}
|
|
19
|
+
const { translations, minimum_total } = value;
|
|
20
|
+
return translateMapR(translations).thenW(translation => {
|
|
21
|
+
if (translation === undefined) {
|
|
22
|
+
return Reader.of(baseCost);
|
|
23
|
+
}
|
|
24
|
+
return responsiveTextR(translation.countable)
|
|
25
|
+
.thenW(countable => responsiveTranslateR("{$cost} per {$countable}", "{$cost}/{$countable}", { cost: baseCost, countable }))
|
|
26
|
+
.thenW(text => minimum_total === undefined
|
|
27
|
+
? Reader.of(text)
|
|
28
|
+
: formatEnergyR(minimum_total).then(cost => translateR("{$baseCost}, minimum of {$value}", {
|
|
29
|
+
baseCost: text,
|
|
30
|
+
value: cost,
|
|
31
|
+
})));
|
|
32
|
+
});
|
|
31
33
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const appendPermanentCostIfNeeded = (permanentValue, baseCost) => mapNullable(permanentValue, value => responsiveTranslateR(".input {$value :number} {{, {$value} of which are permanent}}", " ({$value} perm.)", { value }).map(text => baseCost + text)) ?? Reader.of(baseCost);
|
|
35
|
+
const appendElvenPermanentCostIfNeeded = (permanent, baseCost) => mapNullable(permanent, value => responsiveTranslateR(".input {$value :number} {{{$value} permanent AE}}", "{$value} pAE", { value: value.value })
|
|
36
|
+
.thenW(text => replaceTextIfNeeded(value.translations, text))
|
|
37
|
+
.map(text => baseCost + text)) ?? Reader.of(baseCost);
|
|
38
|
+
const appendFamiliarsTrickLPCostIfNeeded = (lpValue, baseCost) => lpValue === undefined
|
|
39
|
+
? Reader.of(baseCost)
|
|
40
|
+
: formatEnergyR(lpValue)
|
|
41
|
+
.with((env) => ({ ...env, energyUnit: "LifePoints" }))
|
|
42
|
+
.thenW(formattedLpCost => responsiveLocaleJoinR([baseCost, formattedLpCost], "conjunction"));
|
|
43
|
+
/**
|
|
44
|
+
* Returns the text for the modifiable one-time cost of an activatable skill.
|
|
45
|
+
*/
|
|
46
|
+
export const renderModifiableOneTimeCost = (value) => deriveModifiableCost(value.initial_modification_level).thenW(cost => cost === undefined
|
|
47
|
+
? Reader.of(MISSING_VALUE)
|
|
48
|
+
: formatEnergyR(cost)
|
|
49
|
+
.thenW(text => replaceTextIfNeeded(value.translations, text))
|
|
50
|
+
.then(text => translateMapR(value.translations).thenW(translation => {
|
|
51
|
+
if (translation?.additional === undefined) {
|
|
52
|
+
return Reader.of(text);
|
|
53
|
+
}
|
|
54
|
+
return responsiveTextR(translation.additional).map(additional => additionFormatter(text, additional));
|
|
55
|
+
})));
|
|
56
|
+
const appendIntervalToCost = (interval, baseCost) => interval === undefined
|
|
57
|
+
? Reader.of(baseCost)
|
|
58
|
+
: formatCombinedTimeSpanR(interval).then(formattedInterval => responsiveTranslateR("{$cost} per {$interval}", "{$cost}/{$interval}", {
|
|
59
|
+
cost: baseCost,
|
|
60
|
+
interval: formattedInterval,
|
|
61
|
+
}));
|
|
62
|
+
/**
|
|
63
|
+
* Returns the text for a non-modifiable one-time cost of an activatable skill.
|
|
64
|
+
*/
|
|
65
|
+
export const renderNonModifiableOneTimeCost = (value, shouldAppendNonModifiableSuffix) => formatEnergyR(value.value)
|
|
66
|
+
.thenW(base => appendFamiliarsTrickLPCostIfNeeded(value.lp_value, base))
|
|
67
|
+
.thenW(base => appendPerCountableToCostIfNeeded(value.per, base))
|
|
68
|
+
.then(base => appendPermanentCostIfNeeded(value.permanent_value, base))
|
|
69
|
+
.then(base => appendIntervalToCost(value.interval, base))
|
|
70
|
+
.then(base => appendElvenPermanentCostIfNeeded(value.permanent, base))
|
|
71
|
+
.then(base => wrapIfMinimum(value.is_minimum, base))
|
|
72
|
+
.then(base => appendNoteIfNeeded(value.translations, base))
|
|
73
|
+
.then(shouldAppendNonModifiableSuffix
|
|
74
|
+
? base => appendNonModifiableSuffix(ModifiableParameter.Cost, base)
|
|
75
|
+
: Reader.of);
|
|
76
|
+
/**
|
|
77
|
+
* Returns the text for the indefinite cost of an activatable skill.
|
|
78
|
+
*/
|
|
79
|
+
export const renderIndefiniteCost = (value, shouldAppendNonModifiableSuffix) => {
|
|
80
|
+
const { modifier, translations } = value;
|
|
81
|
+
return translateMapR(translations)
|
|
82
|
+
.thenW(translation => translation === undefined
|
|
83
|
+
? Reader.of(MISSING_VALUE)
|
|
84
|
+
: responsiveTextR(translation.description))
|
|
85
|
+
.map(modifier === undefined
|
|
86
|
+
? identity
|
|
87
|
+
: base => appendCheckResultModifier(base, modifier))
|
|
88
|
+
.thenW(shouldAppendNonModifiableSuffix
|
|
89
|
+
? base => appendNonModifiableSuffix(ModifiableParameter.Cost, base)
|
|
90
|
+
: Reader.of);
|
|
91
|
+
};
|
|
92
|
+
const renderSingleOneTimeCost = (value) => {
|
|
93
|
+
switch (value.kind) {
|
|
36
94
|
case "Modifiable":
|
|
37
|
-
return
|
|
95
|
+
return renderModifiableOneTimeCost(value.Modifiable);
|
|
38
96
|
case "NonModifiable":
|
|
39
|
-
return
|
|
97
|
+
return renderNonModifiableOneTimeCost(value.NonModifiable, true);
|
|
40
98
|
case "Indefinite":
|
|
41
|
-
return
|
|
99
|
+
return renderIndefiniteCost(value.Indefinite, true);
|
|
42
100
|
default:
|
|
43
101
|
return assertExhaustive(value);
|
|
44
102
|
}
|
|
45
103
|
};
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
?
|
|
49
|
-
:
|
|
50
|
-
return (value
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
switch (type) {
|
|
54
|
-
case "conjunction":
|
|
55
|
-
return responsive(responsiveTextSize, () => locale.translate(" and "), () => locale.translate(" + "));
|
|
56
|
-
case "disjunction":
|
|
57
|
-
return responsive(responsiveTextSize, () => locale.translate(" or "), () => locale.translate(" / "));
|
|
58
|
-
default:
|
|
59
|
-
return assertExhaustive(type);
|
|
60
|
-
}
|
|
61
|
-
})()) + modifiable);
|
|
104
|
+
const renderMultipleOneTimeCosts = (type, value) => {
|
|
105
|
+
const appendNonModifiableIfRequested = !value.every(part => part.kind === "Modifiable")
|
|
106
|
+
? (text) => appendNonModifiableSuffix(ModifiableParameter.Cost, text)
|
|
107
|
+
: Reader.of;
|
|
108
|
+
return Reader.sequence(value.map(renderSingleOneTimeCost))
|
|
109
|
+
.thenW(list => responsiveLocaleJoinR(list, type))
|
|
110
|
+
.then(text => appendNonModifiableIfRequested(text));
|
|
62
111
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Returns the text for a one-time cost map of an activatable skill.
|
|
114
|
+
*/
|
|
115
|
+
export const renderOneTimeCostMap = (value) => Reader.asks(({ translate }) => translate).thenW(translate => formatEnergyFnR
|
|
116
|
+
.thenW(formatEnergy => renderResponsiveMap(value, option => option.value, formatEnergy, value.options.every(option => option.permanent_value !== undefined)
|
|
117
|
+
? {
|
|
118
|
+
surround: values => translate(", {$value} of which are permanent", {
|
|
119
|
+
value: values,
|
|
120
|
+
}),
|
|
121
|
+
getAdditionalValue: option => option.permanent_value,
|
|
70
122
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
? value.options.map((option) => option.permanent_value).join("/")
|
|
77
|
-
: undefined;
|
|
78
|
-
const formatCostP = formatEnergyByEntity.bind(this, locale, entity);
|
|
79
|
-
const notModifiable = getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Cost, responsiveTextSize);
|
|
80
|
-
return (formatCostP(costs) +
|
|
81
|
-
locale.translate(" for ") +
|
|
82
|
-
mapNullableDefault(translation?.list_prepend, (listPrepend) => `${listPrepend} `, "") +
|
|
83
|
-
labels +
|
|
84
|
-
(translation?.list_append ?? "") +
|
|
85
|
-
(permanentCosts !== undefined
|
|
86
|
-
? locale.translate(", {0} of which are permanent", formatCostP(permanentCosts))
|
|
87
|
-
: "") +
|
|
88
|
-
notModifiable);
|
|
89
|
-
};
|
|
123
|
+
: undefined))
|
|
124
|
+
.then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text)));
|
|
125
|
+
const renderSustainedCostMap = (value) => formatEnergyFnR
|
|
126
|
+
.thenW(formatEnergy => renderResponsiveMap(value, option => option.value, formatEnergy))
|
|
127
|
+
.then(text => appendNonModifiableSuffix(ModifiableParameter.Cost, text));
|
|
90
128
|
/**
|
|
91
129
|
* Returns the text for the cost of a one-time activatable skill.
|
|
92
130
|
*/
|
|
93
|
-
export const
|
|
94
|
-
switch (value.
|
|
131
|
+
export const renderOneTimeCost = (value) => {
|
|
132
|
+
switch (value.kind) {
|
|
95
133
|
case "Single":
|
|
96
|
-
return
|
|
134
|
+
return renderSingleOneTimeCost(value.Single);
|
|
97
135
|
case "Conjunction":
|
|
98
|
-
return
|
|
136
|
+
return renderMultipleOneTimeCosts("conjunction", value.Conjunction);
|
|
99
137
|
case "Disjunction":
|
|
100
|
-
return
|
|
138
|
+
return renderMultipleOneTimeCosts("disjunction", value.Disjunction);
|
|
101
139
|
case "Map":
|
|
102
|
-
return
|
|
140
|
+
return renderOneTimeCostMap(value.Map);
|
|
103
141
|
default:
|
|
104
142
|
return assertExhaustive(value);
|
|
105
143
|
}
|
|
106
144
|
};
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
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));
|
|
145
|
+
const buildSustainedCost = (activationCost, intervalCost, interval) => {
|
|
146
|
+
const activationCostWithLabel = responsiveR(() => translateR("activation").map(label => `${activationCost} (${label})`), () => Reader.of(activationCost)).thenW(identity);
|
|
147
|
+
const intervalCostWithLabel = appendIntervalToCost(interval, intervalCost);
|
|
148
|
+
return activationCostWithLabel.map2(intervalCostWithLabel, additionFormatter);
|
|
136
149
|
};
|
|
150
|
+
const renderModifiableSustainedCost = (value) => deriveModifiableCost(value.initial_modification_level).thenW(cost => cost === undefined
|
|
151
|
+
? Reader.of(MISSING_VALUE)
|
|
152
|
+
: formatEnergyFnR.thenW(formatEnergy => {
|
|
153
|
+
const activationCost = formatEnergy(cost);
|
|
154
|
+
const intervalCost = formatEnergy(cost / 2);
|
|
155
|
+
return buildSustainedCost(activationCost, intervalCost, value.interval);
|
|
156
|
+
}));
|
|
157
|
+
/**
|
|
158
|
+
* Returns the text for the non-modifiable cost of a sustained activatable skill.
|
|
159
|
+
*/
|
|
160
|
+
export const renderNonModifiableSustainedCost = (value) => formatEnergyFnR
|
|
161
|
+
.thenW(formatEnergy => {
|
|
162
|
+
const activationCost = formatEnergy(value.value);
|
|
163
|
+
const getIntervalCost = value.is_minimum === true
|
|
164
|
+
? responsiveTranslateR("half of the activation cost", "50%")
|
|
165
|
+
: Reader.of(formatEnergy(value.value / 2));
|
|
166
|
+
return getIntervalCost.then(intervalCost => buildSustainedCost(activationCost, intervalCost, value.interval));
|
|
167
|
+
})
|
|
168
|
+
.thenW(base => appendPerCountableToCostIfNeeded(value.per, base))
|
|
169
|
+
.then(base => wrapIfMinimum(value.is_minimum, base))
|
|
170
|
+
.then(base => appendNonModifiableSuffix(ModifiableParameter.Cost, base));
|
|
137
171
|
/**
|
|
138
172
|
* Returns the text for the cost of a sustained activatable skill.
|
|
139
173
|
*/
|
|
140
|
-
export const
|
|
141
|
-
switch (value.
|
|
174
|
+
export const renderSustainedCost = (value) => {
|
|
175
|
+
switch (value.kind) {
|
|
142
176
|
case "Modifiable":
|
|
143
|
-
return
|
|
177
|
+
return renderModifiableSustainedCost(value.Modifiable);
|
|
144
178
|
case "NonModifiable":
|
|
145
|
-
return
|
|
179
|
+
return renderNonModifiableSustainedCost(value.NonModifiable);
|
|
180
|
+
case "Map":
|
|
181
|
+
return renderSustainedCostMap(value.Map);
|
|
146
182
|
default:
|
|
147
183
|
return assertExhaustive(value);
|
|
148
184
|
}
|
|
149
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* Generates the text for the cost specific to a magical action.
|
|
188
|
+
*/
|
|
189
|
+
export const renderMagicalActionCost = (cost) => {
|
|
190
|
+
switch (cost.kind) {
|
|
191
|
+
case "Fixed":
|
|
192
|
+
return renderNonModifiableOneTimeCost(cost.Fixed, false);
|
|
193
|
+
case "Indefinite":
|
|
194
|
+
return renderIndefiniteCost(cost.Indefinite, false);
|
|
195
|
+
case "FirstPerson":
|
|
196
|
+
return Reader.asks(({ translate }) => translate("{$firstPersonValue} for the first person; {$additionalPersonValue} for each additional person", {
|
|
197
|
+
firstPersonValue: translate("{$value} AE", {
|
|
198
|
+
value: cost.FirstPerson.value,
|
|
199
|
+
}),
|
|
200
|
+
additionalPersonValue: translate("{$value} AE", {
|
|
201
|
+
value: cost.FirstPerson.value / 2,
|
|
202
|
+
}),
|
|
203
|
+
}));
|
|
204
|
+
case "ByPrimaryPatron":
|
|
205
|
+
return translateR("Depends on animal type").thenW(base => appendNoteIfNeeded(cost.ByPrimaryPatron?.translations, base));
|
|
206
|
+
case "All":
|
|
207
|
+
return Reader.asks(({ translate }) => cost.All.minimum === undefined
|
|
208
|
+
? translate("All AE")
|
|
209
|
+
: translate("All AE, at least {$value} AE", {
|
|
210
|
+
value: cost.All.minimum,
|
|
211
|
+
}));
|
|
212
|
+
case "Map":
|
|
213
|
+
return renderOneTimeCostMap(cost.Map);
|
|
214
|
+
default:
|
|
215
|
+
return assertExhaustive(cost);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
@@ -1,21 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
5
|
-
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
1
|
+
import type { CastingTimeDuringLovemaking, CheckResultBasedDuration, DurationForSustained, FixedDuration, Immediate, MusicDuration, PermanentDuration, ResponsiveText } from "optolith-database-schema/gen";
|
|
2
|
+
import type { LocaleMap } from "../../../../helpers/translate.js";
|
|
3
|
+
import { type StdReader } from "../../reader.js";
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
5
|
+
* Renders a duration that is based on the result of the skill check.
|
|
8
6
|
*/
|
|
9
|
-
export declare const
|
|
7
|
+
export declare const renderCheckResultBasedDuration: (value: CheckResultBasedDuration) => StdReader<string, "t" | "tm" | "rts">;
|
|
8
|
+
type OneTimeDuration = {
|
|
9
|
+
kind: "Immediate";
|
|
10
|
+
Immediate?: Immediate;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "Permanent";
|
|
13
|
+
Permanent: PermanentDuration;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "Fixed";
|
|
16
|
+
Fixed: FixedDuration;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "CheckResultBased";
|
|
19
|
+
CheckResultBased: CheckResultBasedDuration;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "Indefinite";
|
|
22
|
+
Indefinite: {
|
|
23
|
+
maximum?: OneTimeDuration;
|
|
24
|
+
translations: LocaleMap<{
|
|
25
|
+
description: ResponsiveText | string;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
kind: "DuringLovemaking";
|
|
30
|
+
DuringLovemaking: CastingTimeDuringLovemaking;
|
|
31
|
+
};
|
|
10
32
|
/**
|
|
11
|
-
* Returns the text for the duration of a
|
|
33
|
+
* Returns the text for the duration of a one-time activatable skill.
|
|
12
34
|
*/
|
|
13
|
-
export declare const
|
|
35
|
+
export declare const renderOneTimeDuration: (value: OneTimeDuration) => StdReader<string, "t" | "tm" | "rts">;
|
|
14
36
|
/**
|
|
15
|
-
* Returns the text for the duration of a
|
|
37
|
+
* Returns the text for the duration of a sustained activatable skill.
|
|
16
38
|
*/
|
|
17
|
-
export declare const
|
|
39
|
+
export declare const renderSustainedDuration: (value: DurationForSustained | undefined) => StdReader<string, "t" | "rts">;
|
|
18
40
|
/**
|
|
19
|
-
*
|
|
41
|
+
* Returns the text for the duration of a musical activatable skill.
|
|
20
42
|
*/
|
|
21
|
-
export declare const
|
|
43
|
+
export declare const renderMusicDuration: (duration: MusicDuration) => StdReader<string, "t">;
|
|
44
|
+
export {};
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
1
2
|
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
3
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { responsiveTextR, responsiveTranslateR, translateMapR, translateR, } from "../../reader.js";
|
|
5
|
+
import { replaceTextIfNeeded } from "../../responsiveText.js";
|
|
6
|
+
import { formatCombinedTimeSpanR, formatTimeSpanR, } from "../../units/timeSpan.js";
|
|
7
|
+
import { MISSING_VALUE } from "../../unknown.js";
|
|
8
|
+
import { renderCheckResultBasedValue } from "./checkResultBased.js";
|
|
6
9
|
import { wrapAsMaximum, wrapIfMaximum } from "./isMinimumMaximum.js";
|
|
7
10
|
import { appendInParensIfNotEmpty } from "./parensIf.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
const renderImmediateDuration = (value) => translateR("Immediate")
|
|
12
|
+
.thenW(base => mapNullable(value?.maximum, max => formatTimeSpanR(max.unit, max.value)
|
|
13
|
+
.then(wrapAsMaximum)
|
|
14
|
+
.map(maxText => appendInParensIfNotEmpty(maxText, base))) ?? Reader.of(base))
|
|
15
|
+
.thenW(text => replaceTextIfNeeded(value?.translations, text));
|
|
16
|
+
const renderPermanentDuration = (value) => translateR("Permanent").thenW(text => replaceTextIfNeeded(value.translations, text));
|
|
17
|
+
const renderFixedDuration = (value) => formatCombinedTimeSpanR(value)
|
|
18
|
+
.then(text => wrapIfMaximum(value.is_maximum, text))
|
|
19
|
+
.thenW(text => replaceTextIfNeeded(value.translations, text));
|
|
20
|
+
/**
|
|
21
|
+
* Renders a duration that is based on the result of the skill check.
|
|
22
|
+
*/
|
|
23
|
+
export const renderCheckResultBasedDuration = (value) => renderCheckResultBasedValue(value)
|
|
24
|
+
.thenW(text => formatTimeSpanR(value.unit, text))
|
|
25
|
+
.then(text => wrapIfMaximum(value.is_maximum, text));
|
|
26
|
+
const renderIndefiniteDuration = (value) => {
|
|
27
|
+
const { maximum, translations } = value;
|
|
28
|
+
return translateMapR(translations)
|
|
29
|
+
.thenW(translation => typeof translation?.description === "object"
|
|
30
|
+
? responsiveTextR(translation.description)
|
|
31
|
+
: Reader.of(translation?.description ?? MISSING_VALUE))
|
|
32
|
+
.thenW(maximum === undefined
|
|
33
|
+
? Reader.of
|
|
34
|
+
: text =>
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
36
|
+
renderOneTimeDuration(maximum).then(maximumText => translateR("{$defaultDuration}, but no more than {$maximumDuration}", {
|
|
37
|
+
defaultDuration: text,
|
|
38
|
+
maximumDuration: maximumText,
|
|
39
|
+
})));
|
|
24
40
|
};
|
|
25
|
-
const
|
|
41
|
+
const renderDurationDuringLovemaking = (value) => formatCombinedTimeSpanR(value);
|
|
26
42
|
/**
|
|
27
43
|
* Returns the text for the duration of a one-time activatable skill.
|
|
28
44
|
*/
|
|
29
|
-
export const
|
|
30
|
-
switch (value.
|
|
45
|
+
export const renderOneTimeDuration = (value) => {
|
|
46
|
+
switch (value.kind) {
|
|
31
47
|
case "Immediate":
|
|
32
|
-
return
|
|
48
|
+
return renderImmediateDuration(value.Immediate);
|
|
33
49
|
case "Permanent":
|
|
34
|
-
return
|
|
50
|
+
return renderPermanentDuration(value.Permanent);
|
|
35
51
|
case "Fixed":
|
|
36
|
-
return
|
|
52
|
+
return renderFixedDuration(value.Fixed);
|
|
37
53
|
case "CheckResultBased":
|
|
38
|
-
return
|
|
54
|
+
return renderCheckResultBasedDuration(value.CheckResultBased);
|
|
39
55
|
case "Indefinite":
|
|
40
|
-
return
|
|
56
|
+
return renderIndefiniteDuration(value.Indefinite);
|
|
57
|
+
case "DuringLovemaking":
|
|
58
|
+
return renderDurationDuringLovemaking(value.DuringLovemaking);
|
|
41
59
|
default:
|
|
42
60
|
return assertExhaustive(value);
|
|
43
61
|
}
|
|
@@ -45,39 +63,32 @@ export const getDurationForOneTimeTranslation = (locale, responsiveTextSize, val
|
|
|
45
63
|
/**
|
|
46
64
|
* Returns the text for the duration of a sustained activatable skill.
|
|
47
65
|
*/
|
|
48
|
-
export const
|
|
49
|
-
?
|
|
50
|
-
:
|
|
51
|
-
const getDurationDuringLovemakingTranslation = (locale, responsiveTextSize, value) => formatTimeSpan(locale, responsiveTextSize, value.unit, value.value);
|
|
52
|
-
/**
|
|
53
|
-
* Returns the text for the duration of a cantrip.
|
|
54
|
-
*/
|
|
55
|
-
export const getDurationTranslationForCantrip = (locale, responsiveTextSize, value) => {
|
|
56
|
-
switch (value.tag) {
|
|
57
|
-
case "Immediate":
|
|
58
|
-
return getImmediateDurationTranslation(locale, responsiveTextSize, value.immediate);
|
|
59
|
-
case "Fixed":
|
|
60
|
-
return getFixedDurationTranslation(locale, responsiveTextSize, value.fixed);
|
|
61
|
-
case "Indefinite":
|
|
62
|
-
return getIndefiniteDurationTranslation(locale, responsiveTextSize, value.indefinite);
|
|
63
|
-
case "DuringLovemaking":
|
|
64
|
-
return getDurationDuringLovemakingTranslation(locale, responsiveTextSize, value.during_lovemaking);
|
|
65
|
-
default:
|
|
66
|
-
return assertExhaustive(value);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
66
|
+
export const renderSustainedDuration = (value) => value === undefined
|
|
67
|
+
? responsiveTranslateR("Sustained", "(S)")
|
|
68
|
+
: formatCombinedTimeSpanR(value.maximum).then(maxText => wrapAsMaximum(maxText));
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Returns the text for the duration of a musical activatable skill.
|
|
71
71
|
*/
|
|
72
|
-
export const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
72
|
+
export const renderMusicDuration = (duration) => Reader.asks(({ translate }) => {
|
|
73
|
+
const length = (() => {
|
|
74
|
+
switch (duration.length.kind) {
|
|
75
|
+
case "Long":
|
|
76
|
+
return translate("long");
|
|
77
|
+
case "Short":
|
|
78
|
+
return translate("short");
|
|
79
|
+
default:
|
|
80
|
+
return assertExhaustive(duration.length);
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
const reusability = (() => {
|
|
84
|
+
switch (duration.reusability.kind) {
|
|
85
|
+
case "OneTime":
|
|
86
|
+
return translate("one-time");
|
|
87
|
+
case "Sustainable":
|
|
88
|
+
return translate("sustainable");
|
|
89
|
+
default:
|
|
90
|
+
return assertExhaustive(duration.reusability);
|
|
91
|
+
}
|
|
92
|
+
})();
|
|
93
|
+
return `${length}, ${reusability}`;
|
|
94
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ActivatableSkillEffect } from "optolith-database-schema/gen";
|
|
2
|
+
import type { RawDefinitionListEntityDescriptionSectionItem } from "../../../../index.js";
|
|
3
|
+
import { type StdReader } from "../../reader.js";
|
|
4
4
|
/**
|
|
5
5
|
* Gets the text for the effect of an activatable skill.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const renderEffect: (effect: ActivatableSkillEffect) => StdReader<RawDefinitionListEntityDescriptionSectionItem, "t">;
|