@optolith/entity-descriptions 0.0.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/.prettierrc.yml +1 -0
- package/AUTHORS +1 -0
- package/CHANGELOG.md +5 -0
- package/LICENSE +373 -0
- package/README.md +1 -0
- package/lib/entities/combatTechnique.d.ts +15 -0
- package/lib/entities/combatTechnique.js +59 -0
- package/lib/entities/experienceLevel.d.ts +5 -0
- package/lib/entities/experienceLevel.js +44 -0
- package/lib/entities/liturgicalChant.d.ts +35 -0
- package/lib/entities/liturgicalChant.js +244 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +25 -0
- package/lib/entities/partial/rated/activatable/castingTime.js +50 -0
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +7 -0
- package/lib/entities/partial/rated/activatable/checkResultBased.js +28 -0
- package/lib/entities/partial/rated/activatable/cost.d.ts +30 -0
- package/lib/entities/partial/rated/activatable/cost.js +166 -0
- package/lib/entities/partial/rated/activatable/duration.d.ts +40 -0
- package/lib/entities/partial/rated/activatable/duration.js +100 -0
- package/lib/entities/partial/rated/activatable/effect.d.ts +7 -0
- package/lib/entities/partial/rated/activatable/effect.js +37 -0
- package/lib/entities/partial/rated/activatable/entity.d.ts +11 -0
- package/lib/entities/partial/rated/activatable/entity.js +12 -0
- package/lib/entities/partial/rated/activatable/index.d.ts +69 -0
- package/lib/entities/partial/rated/activatable/index.js +59 -0
- package/lib/entities/partial/rated/activatable/isMaximum.d.ts +6 -0
- package/lib/entities/partial/rated/activatable/isMaximum.js +10 -0
- package/lib/entities/partial/rated/activatable/modifiableParameter.d.ts +8 -0
- package/lib/entities/partial/rated/activatable/modifiableParameter.js +9 -0
- package/lib/entities/partial/rated/activatable/nonModifiable.d.ts +9 -0
- package/lib/entities/partial/rated/activatable/nonModifiable.js +75 -0
- package/lib/entities/partial/rated/activatable/parensIf.d.ts +10 -0
- package/lib/entities/partial/rated/activatable/parensIf.js +10 -0
- package/lib/entities/partial/rated/activatable/range.d.ts +36 -0
- package/lib/entities/partial/rated/activatable/range.js +122 -0
- package/lib/entities/partial/rated/activatable/speed.d.ts +12 -0
- package/lib/entities/partial/rated/activatable/speed.js +22 -0
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +12 -0
- package/lib/entities/partial/rated/activatable/targetCategory.js +36 -0
- package/lib/entities/partial/rated/activatable/units.d.ts +13 -0
- package/lib/entities/partial/rated/activatable/units.js +53 -0
- package/lib/entities/partial/rated/improvementCost.d.ts +7 -0
- package/lib/entities/partial/rated/improvementCost.js +7 -0
- package/lib/entities/partial/rated/skillCheck.d.ts +19 -0
- package/lib/entities/partial/rated/skillCheck.js +58 -0
- package/lib/entities/partial/responsiveText.d.ts +31 -0
- package/lib/entities/partial/responsiveText.js +49 -0
- package/lib/entities/partial/unknown.d.ts +4 -0
- package/lib/entities/partial/unknown.js +4 -0
- package/lib/entities/skill.d.ts +13 -0
- package/lib/entities/skill.js +109 -0
- package/lib/entities/spell.d.ts +38 -0
- package/lib/entities/spell.js +274 -0
- package/lib/helpers/getTypes.d.ts +482 -0
- package/lib/helpers/getTypes.js +1 -0
- package/lib/helpers/translate.d.ts +14 -0
- package/lib/helpers/translate.js +8 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/libraryEntry.d.ts +52 -0
- package/lib/libraryEntry.js +17 -0
- package/package.json +34 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { mapNullableDefault } from "@optolith/helpers/nullable";
|
|
2
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
+
import { getResponsiveText, replaceTextIfRequested, responsive, } from "../../responsiveText.js";
|
|
4
|
+
import { getTextForCheckResultBased } from "./checkResultBased.js";
|
|
5
|
+
import { getTextForIsMaximum } from "./isMaximum.js";
|
|
6
|
+
import { formatTimeSpan } from "./units.js";
|
|
7
|
+
const getTextForImmediateDuration = (deps, value, env) => {
|
|
8
|
+
const text = deps.translate("Immediate") +
|
|
9
|
+
mapNullableDefault(value.maximum, (max) => {
|
|
10
|
+
const maxText = formatTimeSpan(deps.translate, env.responsiveText, max.unit, max.value);
|
|
11
|
+
return responsive(env.responsiveText, () => deps.translate(" (no more than {0})", maxText), () => deps.translate(" (max. {0})", maxText));
|
|
12
|
+
}, "");
|
|
13
|
+
return replaceTextIfRequested(value.translations, text, deps.translateMap, env.responsiveText);
|
|
14
|
+
};
|
|
15
|
+
const getTextForPermanentDuration = (deps, value, env) => {
|
|
16
|
+
const translation = deps.translateMap(value.translations);
|
|
17
|
+
const text = deps.translate("Permanent");
|
|
18
|
+
if (translation?.replacement !== undefined) {
|
|
19
|
+
return getResponsiveText(translation.replacement, env.responsiveText).replace("$1", text);
|
|
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
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getTextForCheckResultBasedDuration = (deps, value, env) => {
|
|
38
|
+
const isMaximum = getTextForIsMaximum(value.is_maximum, deps.translate, env.responsiveText);
|
|
39
|
+
return formatTimeSpan(deps.translate, env.responsiveText, value.unit, isMaximum + getTextForCheckResultBased(value, deps.translate));
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Returns the text for the duration of a one-time activatable skill.
|
|
43
|
+
*/
|
|
44
|
+
export const getTextForDurationForOneTime = (deps, value, env) => {
|
|
45
|
+
switch (value.tag) {
|
|
46
|
+
case "Immediate":
|
|
47
|
+
return getTextForImmediateDuration(deps, value.immediate, env);
|
|
48
|
+
case "Permanent":
|
|
49
|
+
return getTextForPermanentDuration(deps, value.permanent, env);
|
|
50
|
+
case "Fixed":
|
|
51
|
+
return getTextForFixedDuration(deps, value.fixed, env);
|
|
52
|
+
case "CheckResultBased":
|
|
53
|
+
return getTextForCheckResultBasedDuration(deps, value.check_result_based, env);
|
|
54
|
+
case "Indefinite":
|
|
55
|
+
return getResponsiveText(deps.translateMap(value.indefinite.translations)?.description, env.responsiveText);
|
|
56
|
+
default:
|
|
57
|
+
return assertExhaustive(value);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Returns the text for the duration of a sustained activatable skill.
|
|
62
|
+
*/
|
|
63
|
+
export const getTextForDurationForSustained = (deps, value, env) => value === undefined
|
|
64
|
+
? responsive(env.responsiveText, () => deps.translate("Sustained"), () => deps.translate("(S)"))
|
|
65
|
+
: responsive(env.responsiveText, () => deps.translate("no more than "), () => deps.translate("max. ")) +
|
|
66
|
+
formatTimeSpan(deps.translate, env.responsiveText, value.maximum.unit, value.maximum.value);
|
|
67
|
+
/**
|
|
68
|
+
* Returns the text for the duration of a cantrip.
|
|
69
|
+
*/
|
|
70
|
+
export const getTextForCantripDuration = (deps, value, env) => {
|
|
71
|
+
switch (value.tag) {
|
|
72
|
+
case "Immediate":
|
|
73
|
+
return getTextForImmediateDuration(deps, value.immediate, env);
|
|
74
|
+
case "Fixed":
|
|
75
|
+
return getTextForFixedDuration(deps, value.fixed, env);
|
|
76
|
+
case "Indefinite":
|
|
77
|
+
return getResponsiveText(deps.translateMap(value.indefinite.translations)?.description, env.responsiveText);
|
|
78
|
+
case "DuringLovemaking": {
|
|
79
|
+
const { value: lovemakingValue, unit: lovemakingUnit } = value.during_lovemaking;
|
|
80
|
+
return formatTimeSpan(deps.translate, env.responsiveText, lovemakingUnit, lovemakingValue);
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
return assertExhaustive(value);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Returns the text for the duration of a blessing.
|
|
88
|
+
*/
|
|
89
|
+
export const getTextForBlessingDuration = (deps, value, env) => {
|
|
90
|
+
switch (value.tag) {
|
|
91
|
+
case "Immediate":
|
|
92
|
+
return getTextForImmediateDuration(deps, value.immediate, env);
|
|
93
|
+
case "Fixed":
|
|
94
|
+
return getTextForFixedDuration(deps, value.fixed, env);
|
|
95
|
+
case "Indefinite":
|
|
96
|
+
return getResponsiveText(deps.translateMap(value.indefinite.translations)?.description, env.responsiveText);
|
|
97
|
+
default:
|
|
98
|
+
return assertExhaustive(value);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "optolith-database-schema/types/_ActivatableSkillEffect";
|
|
2
|
+
import { Translate } from "../../../../helpers/translate.js";
|
|
3
|
+
import { LibraryEntryContent } from "../../../../libraryEntry.js";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the text for the effect of an activatable skill.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getTextForEffect: (effect: Effect, translate: Translate) => LibraryEntryContent[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { filterNonNullable } from "@optolith/helpers/array";
|
|
2
|
+
import { mapNullable } from "@optolith/helpers/nullable";
|
|
3
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
4
|
+
const getContentPartsForQualityLevels = (source, getQualityLevelString, translate) => filterNonNullable([
|
|
5
|
+
{
|
|
6
|
+
label: translate("Effect"),
|
|
7
|
+
value: source.text_before,
|
|
8
|
+
},
|
|
9
|
+
...source.quality_levels.map((text, index) => ({
|
|
10
|
+
value: text,
|
|
11
|
+
label: translate("QL {0}", getQualityLevelString(index)),
|
|
12
|
+
})),
|
|
13
|
+
mapNullable(source.text_after, (textAfter) => ({
|
|
14
|
+
value: textAfter,
|
|
15
|
+
className: "effect-after",
|
|
16
|
+
})),
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the text for the effect of an activatable skill.
|
|
20
|
+
*/
|
|
21
|
+
export const getTextForEffect = (effect, translate) => {
|
|
22
|
+
switch (effect.tag) {
|
|
23
|
+
case "Plain":
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
label: translate("Effect"),
|
|
27
|
+
value: effect.plain.text,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
case "ForEachQualityLevel":
|
|
31
|
+
return getContentPartsForQualityLevels(effect.for_each_quality_level, (index) => index + 1, translate);
|
|
32
|
+
case "ForEachTwoQualityLevels":
|
|
33
|
+
return getContentPartsForQualityLevels(effect.for_each_two_quality_levels, (index) => `${index * 2 + 1}–${index * 2 + 2}`, translate);
|
|
34
|
+
default:
|
|
35
|
+
return assertExhaustive(effect);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entity type of an activatable skill.
|
|
3
|
+
*/
|
|
4
|
+
export var Entity;
|
|
5
|
+
(function (Entity) {
|
|
6
|
+
Entity[Entity["Cantrip"] = 0] = "Cantrip";
|
|
7
|
+
Entity[Entity["Spell"] = 1] = "Spell";
|
|
8
|
+
Entity[Entity["Ritual"] = 2] = "Ritual";
|
|
9
|
+
Entity[Entity["Blessing"] = 3] = "Blessing";
|
|
10
|
+
Entity[Entity["LiturgicalChant"] = 4] = "LiturgicalChant";
|
|
11
|
+
Entity[Entity["Ceremony"] = 5] = "Ceremony";
|
|
12
|
+
})(Entity || (Entity = {}));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FastOneTimePerformanceParameters, FastSustainedPerformanceParameters, SlowOneTimePerformanceParameters, SlowSustainedPerformanceParameters } from "optolith-database-schema/types/_ActivatableSkill";
|
|
2
|
+
import { GetById } from "../../../../helpers/getTypes.js";
|
|
3
|
+
import { Translate, TranslateMap } from "../../../../helpers/translate.js";
|
|
4
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
5
|
+
import { Entity } from "./entity.js";
|
|
6
|
+
/**
|
|
7
|
+
* Get the texts for all fast one-time performance parameters.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getTextForFastOneTimePerformanceParameters: (deps: {
|
|
10
|
+
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
11
|
+
translate: Translate;
|
|
12
|
+
translateMap: TranslateMap;
|
|
13
|
+
}, value: FastOneTimePerformanceParameters, env: {
|
|
14
|
+
entity: Entity;
|
|
15
|
+
responsiveText: ResponsiveTextSize;
|
|
16
|
+
}) => {
|
|
17
|
+
castingTime: string;
|
|
18
|
+
cost: string;
|
|
19
|
+
range: string;
|
|
20
|
+
duration: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get the texts for all fast sustained performance parameters.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getTextForFastSustainedPerformanceParameters: (deps: {
|
|
26
|
+
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
27
|
+
translate: Translate;
|
|
28
|
+
translateMap: TranslateMap;
|
|
29
|
+
}, value: FastSustainedPerformanceParameters, env: {
|
|
30
|
+
entity: Entity;
|
|
31
|
+
responsiveText: ResponsiveTextSize;
|
|
32
|
+
}) => {
|
|
33
|
+
castingTime: string;
|
|
34
|
+
cost: string;
|
|
35
|
+
range: string;
|
|
36
|
+
duration: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get the texts for all slow one-time performance parameters.
|
|
40
|
+
*/
|
|
41
|
+
export declare const getTextForSlowOneTimePerformanceParameters: (deps: {
|
|
42
|
+
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
43
|
+
translate: Translate;
|
|
44
|
+
translateMap: TranslateMap;
|
|
45
|
+
}, value: SlowOneTimePerformanceParameters, env: {
|
|
46
|
+
entity: Entity;
|
|
47
|
+
responsiveText: ResponsiveTextSize;
|
|
48
|
+
}) => {
|
|
49
|
+
castingTime: string;
|
|
50
|
+
cost: string;
|
|
51
|
+
range: string;
|
|
52
|
+
duration: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get the texts for all slow sustained performance parameters.
|
|
56
|
+
*/
|
|
57
|
+
export declare const getTextForSlowSustainedPerformanceParameters: (deps: {
|
|
58
|
+
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
59
|
+
translate: Translate;
|
|
60
|
+
translateMap: TranslateMap;
|
|
61
|
+
}, value: SlowSustainedPerformanceParameters, env: {
|
|
62
|
+
entity: Entity;
|
|
63
|
+
responsiveText: ResponsiveTextSize;
|
|
64
|
+
}) => {
|
|
65
|
+
castingTime: string;
|
|
66
|
+
cost: string;
|
|
67
|
+
range: string;
|
|
68
|
+
duration: string;
|
|
69
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getTextForFastCastingTime, getTextForSlowCastingTime, } from "./castingTime.js";
|
|
2
|
+
import { getTextForOneTimeCost, getTextForSustainedCost } from "./cost.js";
|
|
3
|
+
import { getTextForDurationForOneTime, getTextForDurationForSustained, } from "./duration.js";
|
|
4
|
+
import { getTextForActivatableSkillRange } from "./range.js";
|
|
5
|
+
import { Speed } from "./speed.js";
|
|
6
|
+
/**
|
|
7
|
+
* Get the texts for all fast one-time performance parameters.
|
|
8
|
+
*/
|
|
9
|
+
export const getTextForFastOneTimePerformanceParameters = (deps, value, env) => ({
|
|
10
|
+
castingTime: getTextForFastCastingTime(deps, value.casting_time, env),
|
|
11
|
+
cost: getTextForOneTimeCost(deps, value.cost, { speed: Speed.Fast, ...env }),
|
|
12
|
+
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
13
|
+
speed: Speed.Fast,
|
|
14
|
+
...env,
|
|
15
|
+
}),
|
|
16
|
+
duration: getTextForDurationForOneTime(deps, value.duration, env),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Get the texts for all fast sustained performance parameters.
|
|
20
|
+
*/
|
|
21
|
+
export const getTextForFastSustainedPerformanceParameters = (deps, value, env) => ({
|
|
22
|
+
castingTime: getTextForFastCastingTime(deps, value.casting_time, env),
|
|
23
|
+
cost: getTextForSustainedCost(deps, value.cost, {
|
|
24
|
+
speed: Speed.Fast,
|
|
25
|
+
...env,
|
|
26
|
+
}),
|
|
27
|
+
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
28
|
+
speed: Speed.Fast,
|
|
29
|
+
...env,
|
|
30
|
+
}),
|
|
31
|
+
duration: getTextForDurationForSustained(deps, value.duration, env),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Get the texts for all slow one-time performance parameters.
|
|
35
|
+
*/
|
|
36
|
+
export const getTextForSlowOneTimePerformanceParameters = (deps, value, env) => ({
|
|
37
|
+
castingTime: getTextForSlowCastingTime(deps, value.casting_time, env),
|
|
38
|
+
cost: getTextForOneTimeCost(deps, value.cost, { speed: Speed.Slow, ...env }),
|
|
39
|
+
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
40
|
+
speed: Speed.Slow,
|
|
41
|
+
...env,
|
|
42
|
+
}),
|
|
43
|
+
duration: getTextForDurationForOneTime(deps, value.duration, env),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Get the texts for all slow sustained performance parameters.
|
|
47
|
+
*/
|
|
48
|
+
export const getTextForSlowSustainedPerformanceParameters = (deps, value, env) => ({
|
|
49
|
+
castingTime: getTextForSlowCastingTime(deps, value.casting_time, env),
|
|
50
|
+
cost: getTextForSustainedCost(deps, value.cost, {
|
|
51
|
+
speed: Speed.Slow,
|
|
52
|
+
...env,
|
|
53
|
+
}),
|
|
54
|
+
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
55
|
+
speed: Speed.Slow,
|
|
56
|
+
...env,
|
|
57
|
+
}),
|
|
58
|
+
duration: getTextForDurationForSustained(deps, value.duration, env),
|
|
59
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Translate } from "../../../../helpers/translate.js";
|
|
2
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the text to prepend for the `is_maximum` property.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getTextForIsMaximum: (is_maximum: boolean | undefined, translate: Translate, responsiveText: ResponsiveTextSize) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { responsive } from "../../responsiveText.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the text to prepend for the `is_maximum` property.
|
|
4
|
+
*/
|
|
5
|
+
export const getTextForIsMaximum = (is_maximum, translate, responsiveText) => {
|
|
6
|
+
if (is_maximum !== true) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
return responsive(responsiveText, () => translate("no more than "), () => translate("max. "));
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A parameter that is designed to be modifiable.
|
|
3
|
+
*/
|
|
4
|
+
export var ModifiableParameter;
|
|
5
|
+
(function (ModifiableParameter) {
|
|
6
|
+
ModifiableParameter[ModifiableParameter["CastingTime"] = 0] = "CastingTime";
|
|
7
|
+
ModifiableParameter[ModifiableParameter["Cost"] = 1] = "Cost";
|
|
8
|
+
ModifiableParameter[ModifiableParameter["Range"] = 2] = "Range";
|
|
9
|
+
})(ModifiableParameter || (ModifiableParameter = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Translate } from "../../../../helpers/translate.js";
|
|
2
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
+
import { Entity } from "./entity.js";
|
|
4
|
+
import { ModifiableParameter } from "./modifiableParameter.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
7
|
+
* that the parameter cannot be modified.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getTextForNonModifiableSuffix: (translate: Translate, entity: Entity, param: ModifiableParameter, responsiveText: ResponsiveTextSize) => string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
+
import { Entity } from "./entity.js";
|
|
4
|
+
import { ModifiableParameter } from "./modifiableParameter.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
7
|
+
* that the parameter cannot be modified.
|
|
8
|
+
*/
|
|
9
|
+
export const getTextForNonModifiableSuffix = (translate, entity, param, responsiveText) => {
|
|
10
|
+
if (responsiveText === ResponsiveTextSize.Compressed) {
|
|
11
|
+
switch (entity) {
|
|
12
|
+
case Entity.Spell:
|
|
13
|
+
case Entity.Ritual:
|
|
14
|
+
case Entity.LiturgicalChant:
|
|
15
|
+
case Entity.Ceremony:
|
|
16
|
+
return translate(" (cannot modify)");
|
|
17
|
+
case Entity.Cantrip:
|
|
18
|
+
case Entity.Blessing:
|
|
19
|
+
return "";
|
|
20
|
+
default:
|
|
21
|
+
return assertExhaustive(entity);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
switch (entity) {
|
|
25
|
+
case Entity.Spell:
|
|
26
|
+
switch (param) {
|
|
27
|
+
case ModifiableParameter.CastingTime:
|
|
28
|
+
return translate(" (you cannot use a modification on this spell’s casting time)");
|
|
29
|
+
case ModifiableParameter.Cost:
|
|
30
|
+
return translate(" (you cannot use a modification on this spell’s cost)");
|
|
31
|
+
case ModifiableParameter.Range:
|
|
32
|
+
return translate(" (you cannot use a modification on this spell’s range)");
|
|
33
|
+
default:
|
|
34
|
+
return assertExhaustive(param);
|
|
35
|
+
}
|
|
36
|
+
case Entity.Ritual:
|
|
37
|
+
switch (param) {
|
|
38
|
+
case ModifiableParameter.CastingTime:
|
|
39
|
+
return translate(" (you cannot use a modification on this ritual’s ritual time)");
|
|
40
|
+
case ModifiableParameter.Cost:
|
|
41
|
+
return translate(" (you cannot use a modification on this ritual’s cost)");
|
|
42
|
+
case ModifiableParameter.Range:
|
|
43
|
+
return translate(" (you cannot use a modification on this ritual’s range)");
|
|
44
|
+
default:
|
|
45
|
+
return assertExhaustive(param);
|
|
46
|
+
}
|
|
47
|
+
case Entity.LiturgicalChant:
|
|
48
|
+
switch (param) {
|
|
49
|
+
case ModifiableParameter.CastingTime:
|
|
50
|
+
return translate(" (you cannot use a modification on this chant’s liturgical time)");
|
|
51
|
+
case ModifiableParameter.Cost:
|
|
52
|
+
return translate(" (you cannot use a modification on this chant’s cost)");
|
|
53
|
+
case ModifiableParameter.Range:
|
|
54
|
+
return translate(" (you cannot use a modification on this chant’s range)");
|
|
55
|
+
default:
|
|
56
|
+
return assertExhaustive(param);
|
|
57
|
+
}
|
|
58
|
+
case Entity.Ceremony:
|
|
59
|
+
switch (param) {
|
|
60
|
+
case ModifiableParameter.CastingTime:
|
|
61
|
+
return translate(" (you cannot use a modification on this ceremony’s ceremonial time)");
|
|
62
|
+
case ModifiableParameter.Cost:
|
|
63
|
+
return translate(" (you cannot use a modification on this ceremony’s cost)");
|
|
64
|
+
case ModifiableParameter.Range:
|
|
65
|
+
return translate(" (you cannot use a modification on this ceremony’s range)");
|
|
66
|
+
default:
|
|
67
|
+
return assertExhaustive(param);
|
|
68
|
+
}
|
|
69
|
+
case Entity.Cantrip:
|
|
70
|
+
case Entity.Blessing:
|
|
71
|
+
return "";
|
|
72
|
+
default:
|
|
73
|
+
return assertExhaustive(entity);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a string in parentheses with a leading space if it is not empty or
|
|
3
|
+
* `undefined`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const parensIf: (text: string | undefined) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Appends a string in parentheses with a leading space if it is not empty or
|
|
8
|
+
* `undefined`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const appendInParens: (text: string, append: string | undefined) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a string in parentheses with a leading space if it is not empty or
|
|
3
|
+
* `undefined`.
|
|
4
|
+
*/
|
|
5
|
+
export const parensIf = (text) => text === undefined || text === "" ? "" : ` (${text})`;
|
|
6
|
+
/**
|
|
7
|
+
* Appends a string in parentheses with a leading space if it is not empty or
|
|
8
|
+
* `undefined`.
|
|
9
|
+
*/
|
|
10
|
+
export const appendInParens = (text, append) => append === undefined || append === "" ? text : `${text} (${append})`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Range } from "optolith-database-schema/types/_ActivatableSkillRange";
|
|
2
|
+
import { BlessingRange } from "optolith-database-schema/types/Blessing";
|
|
3
|
+
import { CantripRange } from "optolith-database-schema/types/Cantrip";
|
|
4
|
+
import { GetById } from "../../../../helpers/getTypes.js";
|
|
5
|
+
import { Translate, TranslateMap } from "../../../../helpers/translate.js";
|
|
6
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
7
|
+
import { Entity } from "./entity.js";
|
|
8
|
+
import { Speed } from "./speed.js";
|
|
9
|
+
/**
|
|
10
|
+
* Returns the text for the range of an activatable skill.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getTextForActivatableSkillRange: (deps: {
|
|
13
|
+
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
14
|
+
translate: Translate;
|
|
15
|
+
translateMap: TranslateMap;
|
|
16
|
+
}, value: Range, env: {
|
|
17
|
+
speed: Speed;
|
|
18
|
+
responsiveText: ResponsiveTextSize;
|
|
19
|
+
entity: Entity;
|
|
20
|
+
}) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the text for the range of a cantrip.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getTextForCantripRange: (deps: {
|
|
25
|
+
translate: Translate;
|
|
26
|
+
}, value: CantripRange, env: {
|
|
27
|
+
responsiveText: ResponsiveTextSize;
|
|
28
|
+
}) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the text for the range of a blessing.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getTextForBlessingRange: (deps: {
|
|
33
|
+
translate: Translate;
|
|
34
|
+
}, value: BlessingRange, env: {
|
|
35
|
+
responsiveText: ResponsiveTextSize;
|
|
36
|
+
}) => string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
+
import { getResponsiveText, getResponsiveTextOptional, responsive, } from "../../responsiveText.js";
|
|
3
|
+
import { MISSING_VALUE } from "../../unknown.js";
|
|
4
|
+
import { getTextForCheckResultBased } from "./checkResultBased.js";
|
|
5
|
+
import { getTextForIsMaximum } from "./isMaximum.js";
|
|
6
|
+
import { ModifiableParameter } from "./modifiableParameter.js";
|
|
7
|
+
import { getTextForNonModifiableSuffix } from "./nonModifiable.js";
|
|
8
|
+
import { Speed } from "./speed.js";
|
|
9
|
+
const toRangeUnit = (unit, value, translate, responsiveText) => {
|
|
10
|
+
switch (unit) {
|
|
11
|
+
case "Steps":
|
|
12
|
+
return responsive(responsiveText, () => translate("{0} yards", value), () => translate("{0} yd", value));
|
|
13
|
+
case "Miles":
|
|
14
|
+
return responsive(responsiveText, () => translate("{0} miles", value), () => translate("{0} mi.", value));
|
|
15
|
+
default:
|
|
16
|
+
return assertExhaustive(unit);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Returns the text for the range of an activatable skill.
|
|
21
|
+
*/
|
|
22
|
+
export const getTextForActivatableSkillRange = (deps, value, env) => {
|
|
23
|
+
const translation = deps.translateMap(value.translations);
|
|
24
|
+
if (value.translations !== undefined && translation === undefined) {
|
|
25
|
+
return MISSING_VALUE;
|
|
26
|
+
}
|
|
27
|
+
const rangeValue = (() => {
|
|
28
|
+
switch (value.value.tag) {
|
|
29
|
+
case "Modifiable": {
|
|
30
|
+
const modificationLevel = deps.getSkillModificationLevelById(value.value.modifiable.initial_modification_level);
|
|
31
|
+
if (modificationLevel === undefined) {
|
|
32
|
+
return MISSING_VALUE;
|
|
33
|
+
}
|
|
34
|
+
const range = (() => {
|
|
35
|
+
switch (env.speed) {
|
|
36
|
+
case Speed.Fast:
|
|
37
|
+
return modificationLevel.fast.range;
|
|
38
|
+
case Speed.Slow:
|
|
39
|
+
return modificationLevel.slow.range;
|
|
40
|
+
default:
|
|
41
|
+
return assertExhaustive(env.speed);
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
if (range === 1) {
|
|
45
|
+
return deps.translate("Touch");
|
|
46
|
+
}
|
|
47
|
+
return toRangeUnit("Steps", range, deps.translate, env.responsiveText);
|
|
48
|
+
}
|
|
49
|
+
case "Sight":
|
|
50
|
+
return deps.translate("Sight");
|
|
51
|
+
case "Self":
|
|
52
|
+
return deps.translate("Self");
|
|
53
|
+
case "Global":
|
|
54
|
+
return deps.translate("Global");
|
|
55
|
+
case "Touch":
|
|
56
|
+
return (deps.translate("Touch") +
|
|
57
|
+
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
58
|
+
case "Fixed": {
|
|
59
|
+
return (toRangeUnit(value.value.fixed.unit, value.value.fixed.value, deps.translate, env.responsiveText) +
|
|
60
|
+
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
61
|
+
}
|
|
62
|
+
case "CheckResultBased": {
|
|
63
|
+
const isMaximum = getTextForIsMaximum(value.value.check_result_based.is_maximum, deps.translate, env.responsiveText);
|
|
64
|
+
const isRadius = value.value.check_result_based.is_radius === true
|
|
65
|
+
? ` ${deps.translate("Radius")}`
|
|
66
|
+
: "";
|
|
67
|
+
return (isMaximum +
|
|
68
|
+
toRangeUnit(value.value.check_result_based.unit, getTextForCheckResultBased(value.value.check_result_based, deps.translate), deps.translate, env.responsiveText) +
|
|
69
|
+
isRadius +
|
|
70
|
+
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
return assertExhaustive(value.value);
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
const withReplacement = translation?.replacement !== undefined
|
|
77
|
+
? getResponsiveText(translation.replacement, env.responsiveText).replace("$1", rangeValue)
|
|
78
|
+
: rangeValue;
|
|
79
|
+
const withNote = (() => {
|
|
80
|
+
if (translation?.note === undefined) {
|
|
81
|
+
return withReplacement;
|
|
82
|
+
}
|
|
83
|
+
const note = getResponsiveTextOptional(translation.note, env.responsiveText);
|
|
84
|
+
if (note === undefined) {
|
|
85
|
+
return withReplacement;
|
|
86
|
+
}
|
|
87
|
+
return `${withReplacement} (${note})`;
|
|
88
|
+
})();
|
|
89
|
+
return withNote;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the text for the range of a cantrip.
|
|
93
|
+
*/
|
|
94
|
+
export const getTextForCantripRange = (deps, value, env) => {
|
|
95
|
+
switch (value.tag) {
|
|
96
|
+
case "Self":
|
|
97
|
+
return deps.translate("Self");
|
|
98
|
+
case "Touch":
|
|
99
|
+
return deps.translate("Touch");
|
|
100
|
+
case "Fixed": {
|
|
101
|
+
return toRangeUnit(value.fixed.unit, value.fixed.value, deps.translate, env.responsiveText);
|
|
102
|
+
}
|
|
103
|
+
default:
|
|
104
|
+
return assertExhaustive(value);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Returns the text for the range of a blessing.
|
|
109
|
+
*/
|
|
110
|
+
export const getTextForBlessingRange = (deps, value, env) => {
|
|
111
|
+
switch (value.tag) {
|
|
112
|
+
case "Self":
|
|
113
|
+
return deps.translate("Self");
|
|
114
|
+
case "Touch":
|
|
115
|
+
return deps.translate("Touch");
|
|
116
|
+
case "Fixed": {
|
|
117
|
+
return toRangeUnit(value.fixed.unit, value.fixed.value, deps.translate, env.responsiveText);
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
return assertExhaustive(value);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FastSkillModificationLevelConfig, SkillModificationLevel, SlowSkillModificationLevelConfig } from "optolith-database-schema/types/SkillModificationLevel";
|
|
2
|
+
/**
|
|
3
|
+
* The speed of an activatable skill.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum Speed {
|
|
6
|
+
Fast = 0,
|
|
7
|
+
Slow = 1
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns a common value for a skill modification level depending on the speed.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getModifiableBySpeed: <T>(level: SkillModificationLevel, speed: Speed, fast: (config: FastSkillModificationLevelConfig) => T, slow: (config: SlowSkillModificationLevelConfig) => T) => T;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
+
/**
|
|
3
|
+
* The speed of an activatable skill.
|
|
4
|
+
*/
|
|
5
|
+
export var Speed;
|
|
6
|
+
(function (Speed) {
|
|
7
|
+
Speed[Speed["Fast"] = 0] = "Fast";
|
|
8
|
+
Speed[Speed["Slow"] = 1] = "Slow";
|
|
9
|
+
})(Speed || (Speed = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Returns a common value for a skill modification level depending on the speed.
|
|
12
|
+
*/
|
|
13
|
+
export const getModifiableBySpeed = (level, speed, fast, slow) => {
|
|
14
|
+
switch (speed) {
|
|
15
|
+
case Speed.Fast:
|
|
16
|
+
return fast(level.fast);
|
|
17
|
+
case Speed.Slow:
|
|
18
|
+
return slow(level.slow);
|
|
19
|
+
default:
|
|
20
|
+
return assertExhaustive(speed);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TargetCategory } from "optolith-database-schema/types/_ActivatableSkillTargetCategory";
|
|
2
|
+
import { GetById } from "../../../../helpers/getTypes.js";
|
|
3
|
+
import { Translate, TranslateMap } from "../../../../helpers/translate.js";
|
|
4
|
+
import { LibraryEntryContent } from "../../../../libraryEntry.js";
|
|
5
|
+
/**
|
|
6
|
+
* Get the text for the target category.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTextForTargetCategory: (deps: {
|
|
9
|
+
translate: Translate;
|
|
10
|
+
translateMap: TranslateMap;
|
|
11
|
+
getTargetCategoryById: GetById.Static.TargetCategory;
|
|
12
|
+
}, values: TargetCategory) => LibraryEntryContent;
|