@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { on } from "@elyukai/utils/function";
|
|
2
|
+
import { mapNullable } from "@elyukai/utils/nullable";
|
|
3
|
+
import { numAsc } from "@optolith/helpers/compare";
|
|
4
|
+
import { isNotNullish } from "@optolith/helpers/nullable";
|
|
5
|
+
import { romanize } from "@optolith/helpers/roman";
|
|
6
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
7
|
+
import { renderActivatableNameComponents, renderActivatableNameComponentsCombinedIfPossible, } from "../activatableNameChunks.js";
|
|
8
|
+
import { MISSING_VALUE } from "../unknown.js";
|
|
9
|
+
import { printDisplayOption } from "./displayOption.js";
|
|
10
|
+
import { hasPartValueObject, joinPrerequisiteParts } from "./part.js";
|
|
11
|
+
import { printAdvantageDisadvantagePrerequisiteGroup, printAnimistPowerPrerequisiteGroup, printArcaneTraditionPrerequisiteGroup, printDerivedCharacteristicPrerequisiteGroup, printEnhancementPrerequisiteGroup, printGeneralPrerequisiteGroup, printGeodeRitualPrerequisiteGroup, printInfluencePrerequisiteGroup, printLanguagePrerequisiteGroup, printLiturgyPrerequisiteGroup, printPersonalityTraitPrerequisiteGroup, printProfessionPrerequisiteGroup, printPublicationPrerequisiteGroup, printSpellworkPrerequisiteGroup, } from "./prerequisiteGroups.js";
|
|
12
|
+
const printPrerequisiteGroup = (translateMap, group) => ({
|
|
13
|
+
value: translateMap(group.translations)?.text ?? MISSING_VALUE,
|
|
14
|
+
sentenceType: undefined,
|
|
15
|
+
isMeta: false,
|
|
16
|
+
});
|
|
17
|
+
const printPrerequisitesDisjunction = (getPrerequisiteTranslation, locale, disjunction) => {
|
|
18
|
+
if (disjunction.display_option !== undefined) {
|
|
19
|
+
return printDisplayOption(locale.translateMap, disjunction.display_option);
|
|
20
|
+
}
|
|
21
|
+
const [first, ...other] = disjunction.list.map(getPrerequisiteTranslation).filter(isNotNullish);
|
|
22
|
+
if (first === undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
if (disjunction.list.length < 2 ||
|
|
26
|
+
disjunction.list.slice(1).every(part => part.kind === disjunction.list[0].kind)) {
|
|
27
|
+
return {
|
|
28
|
+
label: first.label,
|
|
29
|
+
value: hasPartValueObject(first) && other.every(hasPartValueObject)
|
|
30
|
+
? renderActivatableNameComponentsCombinedIfPossible(locale.translateMap, [first.value, ...other.map(part => part.value)], true, list => locale.join(list, "disjunction"))
|
|
31
|
+
: locale.join([first, ...other].map(part => typeof part.value === "string"
|
|
32
|
+
? part.value
|
|
33
|
+
: renderActivatableNameComponents(locale.translateMap, part.value, true)), "disjunction"),
|
|
34
|
+
sentenceType: undefined,
|
|
35
|
+
isMeta: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
value: locale.join([first, ...other].map(part => (part.label ?? "") + part.value), "disjunction"),
|
|
40
|
+
sentenceType: undefined,
|
|
41
|
+
isMeta: false,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Print prerequisites element as a string.
|
|
46
|
+
*/
|
|
47
|
+
const printPrerequisitesElement = (printPrerequisite, locale, element) => {
|
|
48
|
+
switch (element.kind) {
|
|
49
|
+
case "Single":
|
|
50
|
+
return printPrerequisite(element.Single);
|
|
51
|
+
case "Disjunction":
|
|
52
|
+
return printPrerequisitesDisjunction(printPrerequisite, locale, element.Disjunction);
|
|
53
|
+
case "Group":
|
|
54
|
+
return printPrerequisiteGroup(locale.translateMap, element.Group);
|
|
55
|
+
default:
|
|
56
|
+
return assertExhaustive(element);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Print plain prerequisites as a string.
|
|
61
|
+
*/
|
|
62
|
+
const printPlainPrerequisites = (printPrerequisite, locale, prerequisites) => joinPrerequisiteParts(locale.translate, locale.translateMap, locale.compare, prerequisites
|
|
63
|
+
.map(element => mapNullable(printPrerequisitesElement(printPrerequisite, locale, element), part => ({
|
|
64
|
+
type: element.kind === "Single" ? element.Single.kind : element.kind,
|
|
65
|
+
part,
|
|
66
|
+
})))
|
|
67
|
+
.filter(isNotNullish));
|
|
68
|
+
/**
|
|
69
|
+
* Print prerequisite for level as a string.
|
|
70
|
+
*/
|
|
71
|
+
const printPrerequisiteForLevel = (printPrerequisite, locale, value) => printPrerequisitesElement(printPrerequisite, locale, value.prerequisite);
|
|
72
|
+
/**
|
|
73
|
+
* Print prerequisites for levels as a string.
|
|
74
|
+
*/
|
|
75
|
+
const printPrerequisitesForLevels = (printPrerequisite, locale, value, printPreviousLevelPrerequisites) => {
|
|
76
|
+
const previousLevelPrerequisites = printPreviousLevelPrerequisites === undefined
|
|
77
|
+
? []
|
|
78
|
+
: Array.from({ length: printPreviousLevelPrerequisites.levels - 1 }, (_, i) => ({
|
|
79
|
+
level: i + 2,
|
|
80
|
+
prerequisite: {
|
|
81
|
+
kind: "Single",
|
|
82
|
+
Single: printPreviousLevelPrerequisites.createPreerequisite(i + 2),
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
const groupedByLevel = Map.groupBy([...value, ...previousLevelPrerequisites], prerequisite => prerequisite.level);
|
|
86
|
+
const hasBasePrerequisites = groupedByLevel.has(1);
|
|
87
|
+
const sortedByLevel = groupedByLevel
|
|
88
|
+
.entries()
|
|
89
|
+
.toArray()
|
|
90
|
+
.sort(on(item => item[0], numAsc));
|
|
91
|
+
const hasOnlyBasePrerequisites = groupedByLevel.size === 1 && hasBasePrerequisites;
|
|
92
|
+
const printedParts = [
|
|
93
|
+
...(hasBasePrerequisites
|
|
94
|
+
? []
|
|
95
|
+
: [
|
|
96
|
+
`${locale.translate("Level {$level}", {
|
|
97
|
+
level: romanize(1),
|
|
98
|
+
})}: ${locale.translate("none")}`,
|
|
99
|
+
]),
|
|
100
|
+
...sortedByLevel.map(([levelNumber, prerequisites]) => {
|
|
101
|
+
const prerequisitesString = joinPrerequisiteParts(locale.translate, locale.translateMap, locale.compare, prerequisites
|
|
102
|
+
.map(element => mapNullable(printPrerequisiteForLevel(printPrerequisite, locale, element), part => ({
|
|
103
|
+
type: element.prerequisite.kind === "Single"
|
|
104
|
+
? element.prerequisite.Single.kind
|
|
105
|
+
: element.prerequisite.kind,
|
|
106
|
+
part,
|
|
107
|
+
})))
|
|
108
|
+
.filter(isNotNullish));
|
|
109
|
+
return hasOnlyBasePrerequisites
|
|
110
|
+
? prerequisitesString
|
|
111
|
+
: `${locale.translate("Level {$level}", {
|
|
112
|
+
level: romanize(levelNumber),
|
|
113
|
+
})}: ${prerequisitesString}`;
|
|
114
|
+
}),
|
|
115
|
+
];
|
|
116
|
+
return printedParts.join("; ");
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Print derived characteristic prerequisites as a string.
|
|
120
|
+
*/
|
|
121
|
+
export const printDerivedCharacteristicPrerequisites = (locale, value) => printPlainPrerequisites(prerequisite => printDerivedCharacteristicPrerequisiteGroup(locale, prerequisite), locale, value);
|
|
122
|
+
/**
|
|
123
|
+
* Print publication prerequisites as a string.
|
|
124
|
+
*/
|
|
125
|
+
export const printPublicationPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printPublicationPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
126
|
+
/**
|
|
127
|
+
* Print plain general prerequisites as a string.
|
|
128
|
+
*/
|
|
129
|
+
export const printPlainGeneralPrerequisites = (getInstanceById, getResolvedSelectOptionById, locale, value) => printPlainPrerequisites(prerequisite => printGeneralPrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite), locale, value);
|
|
130
|
+
/**
|
|
131
|
+
* Print general prerequisites as a string.
|
|
132
|
+
*/
|
|
133
|
+
export const printGeneralPrerequisites = (getInstanceById, getResolvedSelectOptionById, locale, value, printPreviousLevelPrerequisites) => printPrerequisitesForLevels(prerequisite => printGeneralPrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite), locale, value, printPreviousLevelPrerequisites === undefined
|
|
134
|
+
? undefined
|
|
135
|
+
: {
|
|
136
|
+
levels: printPreviousLevelPrerequisites.levels,
|
|
137
|
+
createPreerequisite: (level) => ({
|
|
138
|
+
kind: "Activatable",
|
|
139
|
+
Activatable: {
|
|
140
|
+
id: printPreviousLevelPrerequisites.id,
|
|
141
|
+
active: true,
|
|
142
|
+
level,
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Print profession prerequisites as a string.
|
|
148
|
+
*/
|
|
149
|
+
export const printProfessionPrerequisites = (getInstanceById, getResolvedSelectOptionById, locale, value) => printPlainPrerequisites(prerequisite => printProfessionPrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite), locale, value);
|
|
150
|
+
/**
|
|
151
|
+
* Print advantage disadvantage prerequisites as a string.
|
|
152
|
+
*/
|
|
153
|
+
export const printAdvantageDisadvantagePrerequisites = (getInstanceById, getResolvedSelectOptionById, locale, value, name, type) => printPrerequisitesForLevels(prerequisite => printAdvantageDisadvantagePrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite, name, type), locale, value);
|
|
154
|
+
/**
|
|
155
|
+
* Print arcane tradition prerequisites as a string.
|
|
156
|
+
*/
|
|
157
|
+
export const printArcaneTraditionPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printArcaneTraditionPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
158
|
+
/**
|
|
159
|
+
* Print personality trait prerequisites as a string.
|
|
160
|
+
*/
|
|
161
|
+
export const printPersonalityTraitPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printPersonalityTraitPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
162
|
+
/**
|
|
163
|
+
* Print spellwork prerequisites as a string.
|
|
164
|
+
*/
|
|
165
|
+
export const printSpellworkPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printSpellworkPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
166
|
+
/**
|
|
167
|
+
* Print liturgy prerequisites as a string.
|
|
168
|
+
*/
|
|
169
|
+
export const printLiturgyPrerequisites = (locale, value) => printPlainPrerequisites(prerequisite => printLiturgyPrerequisiteGroup(locale, prerequisite), locale, value);
|
|
170
|
+
/**
|
|
171
|
+
* Print influence prerequisites as a string.
|
|
172
|
+
*/
|
|
173
|
+
export const printInfluencePrerequisites = (getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, value) => printPlainPrerequisites(prerequisite => printInfluencePrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, prerequisite), locale, value);
|
|
174
|
+
/**
|
|
175
|
+
* Print language prerequisites as a string.
|
|
176
|
+
*/
|
|
177
|
+
export const printLanguagePrerequisites = (getInstanceById, getResolvedSelectOptionById, locale, value) => printPrerequisitesForLevels(prerequisite => printLanguagePrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite), locale, value);
|
|
178
|
+
/**
|
|
179
|
+
* Print animist power prerequisites as a string.
|
|
180
|
+
*/
|
|
181
|
+
export const printAnimistPowerPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printAnimistPowerPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
182
|
+
/**
|
|
183
|
+
* Print geode ritual prerequisites as a string.
|
|
184
|
+
*/
|
|
185
|
+
export const printGeodeRitualPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printGeodeRitualPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
186
|
+
/**
|
|
187
|
+
* Print enhancement prerequisites as a string.
|
|
188
|
+
*/
|
|
189
|
+
export const printEnhancementPrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printEnhancementPrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SentenceType } from "optolith-database-schema/gen";
|
|
2
|
+
import type { LocaleCompare } from "../../../helpers/locale.js";
|
|
3
|
+
import type { Translate, TranslateMap } from "../../../helpers/translate.js";
|
|
4
|
+
import { type ActivatableNameComponents } from "../activatableNameChunks.js";
|
|
5
|
+
/**
|
|
6
|
+
* A part of the total list of prerequisites.
|
|
7
|
+
*/
|
|
8
|
+
export type PrerequisitePart = {
|
|
9
|
+
label?: string;
|
|
10
|
+
value: string | ActivatableNameComponents;
|
|
11
|
+
sentenceType: SentenceType | undefined;
|
|
12
|
+
isMeta: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for prerequisite parts with a value object.
|
|
16
|
+
*/
|
|
17
|
+
export declare const hasPartValueObject: (part: PrerequisitePart) => part is PrerequisitePart & {
|
|
18
|
+
value: ActivatableNameComponents;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Join prerequisite parts using their configuration.
|
|
22
|
+
*/
|
|
23
|
+
export declare const joinPrerequisiteParts: (translate: Translate, translateMap: TranslateMap, localeCompare: LocaleCompare, parts: {
|
|
24
|
+
type: string;
|
|
25
|
+
part: PrerequisitePart;
|
|
26
|
+
}[]) => string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { groupBy } from "@elyukai/utils/array/groups";
|
|
2
|
+
import { deepEqual, equal } from "@elyukai/utils/equality";
|
|
3
|
+
import { on } from "@elyukai/utils/function";
|
|
4
|
+
import { compareNumber, reduceCompare } from "@elyukai/utils/ordering";
|
|
5
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
6
|
+
import { renderActivatableNameComponents, renderActivatableNameComponentsCombinedIfPossible, } from "../activatableNameChunks.js";
|
|
7
|
+
/**
|
|
8
|
+
* Type guard for prerequisite parts with a value object.
|
|
9
|
+
*/
|
|
10
|
+
export const hasPartValueObject = (part) => typeof part.value !== "string";
|
|
11
|
+
const countFurtherToCombined = (part, remainingParts) => {
|
|
12
|
+
const indexHasDifferentBaseValues = remainingParts.findIndex(remaining => !(part.label === remaining.label &&
|
|
13
|
+
deepEqual(part.value.id, remaining.value.id) &&
|
|
14
|
+
part.value.level === remaining.value.level));
|
|
15
|
+
return indexHasDifferentBaseValues === -1
|
|
16
|
+
? // if -1 is returned, all remaining parts have the same base values, so we can combine with all of them
|
|
17
|
+
remainingParts.length
|
|
18
|
+
: indexHasDifferentBaseValues;
|
|
19
|
+
};
|
|
20
|
+
const joinAdjacentParts = (translateMap, localeCompare, part, remainingParts) => {
|
|
21
|
+
const valuesWithSameBase = remainingParts.slice(0, countFurtherToCombined(part, remainingParts));
|
|
22
|
+
if (valuesWithSameBase.length > 0) {
|
|
23
|
+
return [
|
|
24
|
+
renderActivatableNameComponentsCombinedIfPossible(translateMap, [part.value, ...valuesWithSameBase.map(p => p.value)], true, list => list.toSorted(localeCompare).join(", ")),
|
|
25
|
+
valuesWithSameBase.length,
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
return [renderActivatableNameComponents(translateMap, part.value, true), 0];
|
|
29
|
+
};
|
|
30
|
+
const appendBySentenceType = (previouslyRendered, currentRendered, sentenceType, isLast) => {
|
|
31
|
+
switch (sentenceType?.kind) {
|
|
32
|
+
case "Standalone":
|
|
33
|
+
return `${/[.;]$/u.test(previouslyRendered)
|
|
34
|
+
? `${previouslyRendered.slice(0, -1)}. `
|
|
35
|
+
: `${previouslyRendered}. `}${currentRendered}${currentRendered.endsWith(".") ? "" : "."}`;
|
|
36
|
+
case "Connected":
|
|
37
|
+
return `${previouslyRendered === "" ? "" : /[.;]$/u.test(previouslyRendered) ? `${previouslyRendered} ` : `${previouslyRendered}; `}${currentRendered}${isLast ? "" : ";"}`;
|
|
38
|
+
case undefined:
|
|
39
|
+
return previouslyRendered === ""
|
|
40
|
+
? currentRendered
|
|
41
|
+
: `${previouslyRendered}${/[.;]$/u.test(previouslyRendered) ? " " : ", "}${currentRendered}`;
|
|
42
|
+
default:
|
|
43
|
+
return assertExhaustive(sentenceType);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const activatableKindToGroup = (kind) => kind === "Advantage" ? "Advantage" : kind === "Disadvantage" ? "Disadvantage" : "SpecialAbility";
|
|
47
|
+
const activatableGroupOrder = ["Advantage", "Disadvantage", "SpecialAbility"];
|
|
48
|
+
const sortByActivatableGroup = on(group => activatableGroupOrder.indexOf(group), compareNumber);
|
|
49
|
+
const sortByActivatableGroupAndName = (localeCompare) => reduceCompare(on(item => item[0], sortByActivatableGroup), on(item => item[1], localeCompare));
|
|
50
|
+
const appendPrerequisitePartGroup = (previous, translateMap, localeCompare, parts, isLast) => {
|
|
51
|
+
if (parts.length === 0) {
|
|
52
|
+
return previous;
|
|
53
|
+
}
|
|
54
|
+
else if (parts.every(hasPartValueObject)) {
|
|
55
|
+
return appendBySentenceType(previous, parts
|
|
56
|
+
.reduce((acc, current, i, arr) => {
|
|
57
|
+
if (acc[1] > 0) {
|
|
58
|
+
return [acc[0], acc[1] - 1];
|
|
59
|
+
}
|
|
60
|
+
const [rendered, furtherIncluded] = joinAdjacentParts(translateMap, localeCompare, current, arr.slice(i + 1));
|
|
61
|
+
return [
|
|
62
|
+
[
|
|
63
|
+
...acc[0],
|
|
64
|
+
[activatableKindToGroup(current.value.id.kind), (current.label ?? "") + rendered],
|
|
65
|
+
],
|
|
66
|
+
furtherIncluded,
|
|
67
|
+
];
|
|
68
|
+
}, [[], 0])[0]
|
|
69
|
+
.toSorted(sortByActivatableGroupAndName(localeCompare))
|
|
70
|
+
.map(grouped => grouped[1])
|
|
71
|
+
.join(", "), undefined, isLast);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return parts.reduce((acc, current, i, arr) => appendBySentenceType(acc, (current.label ?? "") +
|
|
75
|
+
(typeof current.value === "string"
|
|
76
|
+
? current.value
|
|
77
|
+
: renderActivatableNameComponents(translateMap, current.value, true)), current.sentenceType, isLast && i === arr.length - 1), previous);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Join prerequisite parts using their configuration.
|
|
82
|
+
*/
|
|
83
|
+
export const joinPrerequisiteParts = (translate, translateMap, localeCompare, parts) => groupBy(parts, on(part => part.type, equal))
|
|
84
|
+
.map(group => ({
|
|
85
|
+
type: group[0].type,
|
|
86
|
+
parts: group.map(groupItem => groupItem.part),
|
|
87
|
+
}))
|
|
88
|
+
.reduce((acc, partGroup, i, arr) => appendPrerequisitePartGroup(acc, translateMap, localeCompare, partGroup.parts, i === arr.length - 1), parts.every(({ part }) => part.isMeta) ? translate("none") : "");
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AdvantageDisadvantagePrerequisiteGroup, AnimistPowerPrerequisiteGroup, ArcaneTraditionPrerequisiteGroup, DerivedCharacteristicPrerequisiteGroup, EnhancementPrerequisiteGroup, GeneralPrerequisiteGroup, GeodeRitualPrerequisiteGroup, InfluencePrerequisiteGroup, LanguagePrerequisiteGroup, LiturgyPrerequisiteGroup, PersonalityTraitPrerequisiteGroup, PreconditionGroup, ProfessionPrerequisiteGroup, PublicationPrerequisiteGroup, SpellworkPrerequisiteGroup, type ActivatableIdentifier, type RatedIdentifier } from "optolith-database-schema/gen";
|
|
2
|
+
import type { GetAllChildInstancesForParent, GetInstanceById } from "../../../helpers/getTypes.js";
|
|
3
|
+
import { LocaleEnvironment } from "../../../helpers/locale.js";
|
|
4
|
+
import { PrerequisitePart } from "./part.js";
|
|
5
|
+
import { GetResolvedSelectOptionById } from "./single/activatable.js";
|
|
6
|
+
/**
|
|
7
|
+
* Print the translation of a derived characteristic prerequisite group.
|
|
8
|
+
*/
|
|
9
|
+
export declare const printDerivedCharacteristicPrerequisiteGroup: (locale: LocaleEnvironment, prerequisite: DerivedCharacteristicPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Print the translation of a publication prerequisite group.
|
|
12
|
+
*/
|
|
13
|
+
export declare const printPublicationPrerequisiteGroup: (getInstanceById: GetInstanceById<"Publication">, locale: LocaleEnvironment, prerequisite: PublicationPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Print the translation of a general prerequisite group.
|
|
16
|
+
*/
|
|
17
|
+
export declare const printGeneralPrerequisiteGroup: (getInstanceById: GetInstanceById<"Race" | "Culture" | "PactCategory" | "PactDomain" | "SocialStatus" | "State" | ActivatableIdentifier["kind"] | RatedIdentifier["kind"] | "Property" | "Aspect" | "Enhancement">, getResolvedSelectOptionById: GetResolvedSelectOptionById, locale: LocaleEnvironment, prerequisite: GeneralPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Print the translation of a profession prerequisite group.
|
|
20
|
+
*/
|
|
21
|
+
export declare const printProfessionPrerequisiteGroup: (getInstanceById: GetInstanceById<"Race" | "Culture" | ActivatableIdentifier["kind"] | RatedIdentifier["kind"] | "Aspect">, getResolvedSelectOptionById: GetResolvedSelectOptionById, locale: Pick<LocaleEnvironment, "translate" | "translateMap">, prerequisite: ProfessionPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Print the translation of an advantage/disadvantage prerequisite group.
|
|
24
|
+
*/
|
|
25
|
+
export declare const printAdvantageDisadvantagePrerequisiteGroup: (getInstanceById: GetInstanceById<"Race" | "Culture" | "PactCategory" | "PactDomain" | "SocialStatus" | "State" | ActivatableIdentifier["kind"] | RatedIdentifier["kind"] | "Property" | "Aspect" | "Enhancement">, getResolvedSelectOptionById: GetResolvedSelectOptionById, locale: LocaleEnvironment, prerequisite: AdvantageDisadvantagePrerequisiteGroup, name: string, type: "Advantage" | "Disadvantage") => PrerequisitePart | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Print the translation of an arcane tradition prerequisite group.
|
|
28
|
+
*/
|
|
29
|
+
export declare const printArcaneTraditionPrerequisiteGroup: (getInstanceById: GetInstanceById<"Culture">, locale: LocaleEnvironment, prerequisite: ArcaneTraditionPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Print the translation of a personality trait prerequisite group.
|
|
32
|
+
*/
|
|
33
|
+
export declare const printPersonalityTraitPrerequisiteGroup: (getInstanceById: GetInstanceById<"Race" | "Culture" | "PersonalityTrait">, locale: LocaleEnvironment, prerequisite: PersonalityTraitPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Print the translation of a spellwork prerequisite group.
|
|
36
|
+
*/
|
|
37
|
+
export declare const printSpellworkPrerequisiteGroup: (getInstanceById: GetInstanceById<RatedIdentifier["kind"]>, locale: LocaleEnvironment, prerequisite: SpellworkPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Print the translation of a liturgy prerequisite group.
|
|
40
|
+
*/
|
|
41
|
+
export declare const printLiturgyPrerequisiteGroup: (locale: LocaleEnvironment, prerequisite: LiturgyPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Print the translation of an influence prerequisite group.
|
|
44
|
+
*/
|
|
45
|
+
export declare const printInfluencePrerequisiteGroup: (getInstanceById: GetInstanceById<"Influence" | "Race" | ActivatableIdentifier["kind"] | "Aspect">, getResolvedSelectOptionById: GetResolvedSelectOptionById, getChildInstancesForInstanceId: GetAllChildInstancesForParent<"ProfessionVersion">, locale: LocaleEnvironment, prerequisite: InfluencePrerequisiteGroup) => PrerequisitePart | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Print the translation of a language prerequisite group.
|
|
48
|
+
*/
|
|
49
|
+
export declare const printLanguagePrerequisiteGroup: (getInstanceById: GetInstanceById<"Race" | ActivatableIdentifier["kind"] | "Aspect">, getResolvedSelectOptionById: GetResolvedSelectOptionById, locale: LocaleEnvironment, prerequisite: LanguagePrerequisiteGroup) => PrerequisitePart | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Print the translation of an animist power prerequisite group.
|
|
52
|
+
*/
|
|
53
|
+
export declare const printAnimistPowerPrerequisiteGroup: (getInstanceById: GetInstanceById<"AnimistPower">, locale: LocaleEnvironment, prerequisite: AnimistPowerPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Print the translation of a geode ritual prerequisite group.
|
|
56
|
+
*/
|
|
57
|
+
export declare const printGeodeRitualPrerequisiteGroup: (getInstanceById: GetInstanceById<"Influence">, locale: LocaleEnvironment, prerequisite: GeodeRitualPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Print the translation of an enhancement prerequisite group.
|
|
60
|
+
*/
|
|
61
|
+
export declare const printEnhancementPrerequisiteGroup: (getInstanceById: GetInstanceById<RatedIdentifier["kind"] | "Enhancement">, locale: Pick<LocaleEnvironment, "translate" | "translateMap">, prerequisite: EnhancementPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Print the translation of a precondition group.
|
|
64
|
+
*/
|
|
65
|
+
export declare const printPreconditionGroup: (getInstanceById: GetInstanceById<"Publication">, locale: LocaleEnvironment, prerequisite: PreconditionGroup) => PrerequisitePart | undefined;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
+
import { printActivatablePrerequisite } from "./single/activatable.js";
|
|
3
|
+
import { printAnimistPowerPrerequisite } from "./single/animistPower.js";
|
|
4
|
+
import { printBlessedTraditionPrerequisite } from "./single/blessedTradition.js";
|
|
5
|
+
import { printCommonSuggestedByRCPPrerequisite } from "./single/commonSuggestedByRCP.js";
|
|
6
|
+
import { printCulturePrerequisite } from "./single/culture.js";
|
|
7
|
+
import { printEnhancementPrerequisite } from "./single/enhancement.js";
|
|
8
|
+
import { printInfluencePrerequisite } from "./single/influence.js";
|
|
9
|
+
import { printMagicalTraditionPrerequisite } from "./single/magicalTradition.js";
|
|
10
|
+
import { printNoOtherAncestorBloodAdvantagePrerequisite } from "./single/noOtherAncestorBloodAdvantage.js";
|
|
11
|
+
import { printPactPrerequisite } from "./single/pact.js";
|
|
12
|
+
import { printPersonalityTraitPrerequisite } from "./single/personalityTrait.js";
|
|
13
|
+
import { printPrimaryAttributePrerequisite } from "./single/primaryAttribute.js";
|
|
14
|
+
import { printProfessionPrerequisite } from "./single/profession.js";
|
|
15
|
+
import { printPublicationPrerequisite } from "./single/publication.js";
|
|
16
|
+
import { printRacePrerequisite } from "./single/race.js";
|
|
17
|
+
import { printRatedPrerequisite } from "./single/rated.js";
|
|
18
|
+
import { printRatedMinimumNumberPrerequisite } from "./single/ratedMinimumNumber.js";
|
|
19
|
+
import { printRatedSumPrerequisite } from "./single/ratedSum.js";
|
|
20
|
+
import { printRulePrerequisite } from "./single/rule.js";
|
|
21
|
+
import { printBinarySexPrerequisite } from "./single/sex.js";
|
|
22
|
+
import { printSexualCharacteristicPrerequisite } from "./single/sexualCharacteristic.js";
|
|
23
|
+
import { printSocialStatusPrerequisite } from "./single/socialStatus.js";
|
|
24
|
+
import { printStatePrerequisite } from "./single/state.js";
|
|
25
|
+
import { printTextPrerequisite } from "./single/text.js";
|
|
26
|
+
/**
|
|
27
|
+
* Print the translation of a derived characteristic prerequisite group.
|
|
28
|
+
*/
|
|
29
|
+
export const printDerivedCharacteristicPrerequisiteGroup = (locale, prerequisite) => {
|
|
30
|
+
switch (prerequisite.kind) {
|
|
31
|
+
case "Rule":
|
|
32
|
+
return printRulePrerequisite(locale, prerequisite.Rule);
|
|
33
|
+
case "BlessedTradition":
|
|
34
|
+
return printBlessedTraditionPrerequisite(locale, prerequisite.BlessedTradition);
|
|
35
|
+
case "MagicalTradition":
|
|
36
|
+
return printMagicalTraditionPrerequisite(locale, prerequisite.MagicalTradition);
|
|
37
|
+
default:
|
|
38
|
+
return assertExhaustive(prerequisite);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Print the translation of a publication prerequisite group.
|
|
43
|
+
*/
|
|
44
|
+
export const printPublicationPrerequisiteGroup = (getInstanceById, locale, prerequisite) =>
|
|
45
|
+
// switch (prerequisite.tag) {
|
|
46
|
+
// case "Publication":
|
|
47
|
+
// default:
|
|
48
|
+
// return assertExhaustive(prerequisite)
|
|
49
|
+
// }
|
|
50
|
+
printPublicationPrerequisite(getInstanceById, locale, prerequisite.Publication);
|
|
51
|
+
/**
|
|
52
|
+
* Print the translation of a general prerequisite group.
|
|
53
|
+
*/
|
|
54
|
+
export const printGeneralPrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, locale, prerequisite) => {
|
|
55
|
+
switch (prerequisite.kind) {
|
|
56
|
+
case "Sex":
|
|
57
|
+
return printBinarySexPrerequisite(locale.translate, prerequisite.Sex);
|
|
58
|
+
case "Race":
|
|
59
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
60
|
+
case "Culture":
|
|
61
|
+
return printCulturePrerequisite(getInstanceById, locale, prerequisite.Culture);
|
|
62
|
+
case "Pact":
|
|
63
|
+
return printPactPrerequisite(getInstanceById, locale, prerequisite.Pact);
|
|
64
|
+
case "SocialStatus":
|
|
65
|
+
return printSocialStatusPrerequisite(getInstanceById, locale, prerequisite.SocialStatus);
|
|
66
|
+
case "State":
|
|
67
|
+
return printStatePrerequisite(getInstanceById, locale, prerequisite.State);
|
|
68
|
+
case "Rule":
|
|
69
|
+
return printRulePrerequisite(locale, prerequisite.Rule);
|
|
70
|
+
case "PrimaryAttribute":
|
|
71
|
+
return printPrimaryAttributePrerequisite(locale, prerequisite.PrimaryAttribute);
|
|
72
|
+
case "Activatable":
|
|
73
|
+
return printActivatablePrerequisite(getInstanceById, getResolvedSelectOptionById, locale, prerequisite.Activatable, false);
|
|
74
|
+
case "BlessedTradition":
|
|
75
|
+
return printBlessedTraditionPrerequisite(locale, prerequisite.BlessedTradition);
|
|
76
|
+
case "MagicalTradition":
|
|
77
|
+
return printMagicalTraditionPrerequisite(locale, prerequisite.MagicalTradition);
|
|
78
|
+
case "Rated":
|
|
79
|
+
return printRatedPrerequisite(getInstanceById, locale, prerequisite.Rated);
|
|
80
|
+
case "RatedMinimumNumber":
|
|
81
|
+
return printRatedMinimumNumberPrerequisite(getInstanceById, locale, prerequisite.RatedMinimumNumber);
|
|
82
|
+
case "RatedSum":
|
|
83
|
+
return printRatedSumPrerequisite(getInstanceById, locale, prerequisite.RatedSum);
|
|
84
|
+
case "Enhancement":
|
|
85
|
+
return printEnhancementPrerequisite(getInstanceById, locale, prerequisite.Enhancement);
|
|
86
|
+
case "Text":
|
|
87
|
+
return printTextPrerequisite(locale, prerequisite.Text);
|
|
88
|
+
case "SexualCharacteristic":
|
|
89
|
+
return printSexualCharacteristicPrerequisite(locale, prerequisite.SexualCharacteristic);
|
|
90
|
+
default:
|
|
91
|
+
return assertExhaustive(prerequisite);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Print the translation of a profession prerequisite group.
|
|
96
|
+
*/
|
|
97
|
+
export const printProfessionPrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, locale, prerequisite) => {
|
|
98
|
+
switch (prerequisite.kind) {
|
|
99
|
+
case "Sex":
|
|
100
|
+
return printBinarySexPrerequisite(locale.translate, prerequisite.Sex);
|
|
101
|
+
case "Race":
|
|
102
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
103
|
+
case "Culture":
|
|
104
|
+
return printCulturePrerequisite(getInstanceById, locale, prerequisite.Culture);
|
|
105
|
+
case "Activatable":
|
|
106
|
+
return printActivatablePrerequisite(getInstanceById, getResolvedSelectOptionById, locale, prerequisite.Activatable, true);
|
|
107
|
+
case "Rated":
|
|
108
|
+
return printRatedPrerequisite(getInstanceById, locale, prerequisite.Rated);
|
|
109
|
+
default:
|
|
110
|
+
return assertExhaustive(prerequisite);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Print the translation of an advantage/disadvantage prerequisite group.
|
|
115
|
+
*/
|
|
116
|
+
export const printAdvantageDisadvantagePrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, locale, prerequisite, name, type) => {
|
|
117
|
+
switch (prerequisite.kind) {
|
|
118
|
+
case "CommonSuggestedByRCP":
|
|
119
|
+
return printCommonSuggestedByRCPPrerequisite(locale, name, type);
|
|
120
|
+
case "NoOtherAncestorBloodAdvantage":
|
|
121
|
+
return printNoOtherAncestorBloodAdvantagePrerequisite(locale);
|
|
122
|
+
case "Sex":
|
|
123
|
+
case "Race":
|
|
124
|
+
case "Culture":
|
|
125
|
+
case "Pact":
|
|
126
|
+
case "SocialStatus":
|
|
127
|
+
case "State":
|
|
128
|
+
case "Rule":
|
|
129
|
+
case "PrimaryAttribute":
|
|
130
|
+
case "Activatable":
|
|
131
|
+
case "BlessedTradition":
|
|
132
|
+
case "MagicalTradition":
|
|
133
|
+
case "Rated":
|
|
134
|
+
case "RatedMinimumNumber":
|
|
135
|
+
case "RatedSum":
|
|
136
|
+
case "Enhancement":
|
|
137
|
+
case "Text":
|
|
138
|
+
case "SexualCharacteristic":
|
|
139
|
+
return printGeneralPrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, locale, prerequisite);
|
|
140
|
+
default:
|
|
141
|
+
return assertExhaustive(prerequisite);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Print the translation of an arcane tradition prerequisite group.
|
|
146
|
+
*/
|
|
147
|
+
export const printArcaneTraditionPrerequisiteGroup = (getInstanceById, locale, prerequisite) => {
|
|
148
|
+
switch (prerequisite.kind) {
|
|
149
|
+
case "Sex":
|
|
150
|
+
return printBinarySexPrerequisite(locale.translate, prerequisite.Sex);
|
|
151
|
+
case "Culture":
|
|
152
|
+
return printCulturePrerequisite(getInstanceById, locale, prerequisite.Culture);
|
|
153
|
+
default:
|
|
154
|
+
return assertExhaustive(prerequisite);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Print the translation of a personality trait prerequisite group.
|
|
159
|
+
*/
|
|
160
|
+
export const printPersonalityTraitPrerequisiteGroup = (getInstanceById, locale, prerequisite) => {
|
|
161
|
+
switch (prerequisite.kind) {
|
|
162
|
+
case "Race":
|
|
163
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
164
|
+
case "Culture":
|
|
165
|
+
return printCulturePrerequisite(getInstanceById, locale, prerequisite.Culture);
|
|
166
|
+
case "PersonalityTrait":
|
|
167
|
+
return printPersonalityTraitPrerequisite(getInstanceById, locale, prerequisite.PersonalityTrait);
|
|
168
|
+
case "Text":
|
|
169
|
+
return printTextPrerequisite(locale, prerequisite.Text);
|
|
170
|
+
default:
|
|
171
|
+
return assertExhaustive(prerequisite);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Print the translation of a spellwork prerequisite group.
|
|
176
|
+
*/
|
|
177
|
+
export const printSpellworkPrerequisiteGroup = (getInstanceById, locale, prerequisite) => {
|
|
178
|
+
switch (prerequisite.kind) {
|
|
179
|
+
case "Rule":
|
|
180
|
+
return printRulePrerequisite(locale, prerequisite.Rule);
|
|
181
|
+
case "Rated":
|
|
182
|
+
return printRatedPrerequisite(getInstanceById, locale, prerequisite.Rated);
|
|
183
|
+
default:
|
|
184
|
+
return assertExhaustive(prerequisite);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Print the translation of a liturgy prerequisite group.
|
|
189
|
+
*/
|
|
190
|
+
export const printLiturgyPrerequisiteGroup = (locale, prerequisite) =>
|
|
191
|
+
// switch (prerequisite.tag) {
|
|
192
|
+
// case "Rule":
|
|
193
|
+
// default:
|
|
194
|
+
// return assertExhaustive(prerequisite)
|
|
195
|
+
// }
|
|
196
|
+
printRulePrerequisite(locale, prerequisite.Rule);
|
|
197
|
+
/**
|
|
198
|
+
* Print the translation of an influence prerequisite group.
|
|
199
|
+
*/
|
|
200
|
+
export const printInfluencePrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, prerequisite) => {
|
|
201
|
+
switch (prerequisite.kind) {
|
|
202
|
+
case "Influence":
|
|
203
|
+
return printInfluencePrerequisite(getInstanceById, locale, prerequisite.Influence);
|
|
204
|
+
case "Race":
|
|
205
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
206
|
+
case "Profession":
|
|
207
|
+
return printProfessionPrerequisite(getChildInstancesForInstanceId, locale, prerequisite.Profession);
|
|
208
|
+
case "Activatable":
|
|
209
|
+
return printActivatablePrerequisite(getInstanceById, getResolvedSelectOptionById, locale, prerequisite.Activatable, false);
|
|
210
|
+
case "Text":
|
|
211
|
+
return printTextPrerequisite(locale, prerequisite.Text);
|
|
212
|
+
default:
|
|
213
|
+
return assertExhaustive(prerequisite);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Print the translation of a language prerequisite group.
|
|
218
|
+
*/
|
|
219
|
+
export const printLanguagePrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, locale, prerequisite) => {
|
|
220
|
+
switch (prerequisite.kind) {
|
|
221
|
+
case "Race":
|
|
222
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
223
|
+
case "Activatable":
|
|
224
|
+
return printActivatablePrerequisite(getInstanceById, getResolvedSelectOptionById, locale, prerequisite.Activatable, false);
|
|
225
|
+
case "Text":
|
|
226
|
+
return printTextPrerequisite(locale, prerequisite.Text);
|
|
227
|
+
default:
|
|
228
|
+
return assertExhaustive(prerequisite);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Print the translation of an animist power prerequisite group.
|
|
233
|
+
*/
|
|
234
|
+
export const printAnimistPowerPrerequisiteGroup = (getInstanceById, locale, prerequisite) =>
|
|
235
|
+
// switch (prerequisite.tag) {
|
|
236
|
+
// case "AnimistPower":
|
|
237
|
+
// default:
|
|
238
|
+
// return assertExhaustive(prerequisite)
|
|
239
|
+
// }
|
|
240
|
+
printAnimistPowerPrerequisite(getInstanceById, locale, prerequisite.AnimistPower);
|
|
241
|
+
/**
|
|
242
|
+
* Print the translation of a geode ritual prerequisite group.
|
|
243
|
+
*/
|
|
244
|
+
export const printGeodeRitualPrerequisiteGroup = (getInstanceById, locale, prerequisite) =>
|
|
245
|
+
// switch (prerequisite.tag) {
|
|
246
|
+
// case "Influence":
|
|
247
|
+
// default:
|
|
248
|
+
// return assertExhaustive(prerequisite)
|
|
249
|
+
// }
|
|
250
|
+
printInfluencePrerequisite(getInstanceById, locale, prerequisite.Influence);
|
|
251
|
+
/**
|
|
252
|
+
* Print the translation of an enhancement prerequisite group.
|
|
253
|
+
*/
|
|
254
|
+
export const printEnhancementPrerequisiteGroup = (getInstanceById, locale, prerequisite) => {
|
|
255
|
+
switch (prerequisite.kind) {
|
|
256
|
+
case "Rated":
|
|
257
|
+
return printRatedPrerequisite(getInstanceById, locale, prerequisite.Rated);
|
|
258
|
+
case "Enhancement":
|
|
259
|
+
return printEnhancementPrerequisite(getInstanceById, locale, prerequisite.Enhancement);
|
|
260
|
+
default:
|
|
261
|
+
return assertExhaustive(prerequisite);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Print the translation of a precondition group.
|
|
266
|
+
*/
|
|
267
|
+
export const printPreconditionGroup = (getInstanceById, locale, prerequisite) => {
|
|
268
|
+
switch (prerequisite.kind) {
|
|
269
|
+
case "Publication":
|
|
270
|
+
return printPublicationPrerequisite(getInstanceById, locale, prerequisite.Publication);
|
|
271
|
+
case "Rule":
|
|
272
|
+
return printRulePrerequisite(locale, prerequisite.Rule);
|
|
273
|
+
case "SexualCharacteristic":
|
|
274
|
+
return printSexualCharacteristicPrerequisite(locale, prerequisite.SexualCharacteristic);
|
|
275
|
+
default:
|
|
276
|
+
return assertExhaustive(prerequisite);
|
|
277
|
+
}
|
|
278
|
+
};
|