optolith-database-schema 0.28.2 → 0.29.0
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 +15 -0
- package/gen/types.d.ts +7 -612
- package/lib/cache/activatableSelectOptions.d.ts +18 -0
- package/lib/cache/activatableSelectOptions.js +761 -0
- package/lib/cache/ancestorBloodAdvantages.d.ts +4 -0
- package/lib/cache/ancestorBloodAdvantages.js +13 -0
- package/lib/cache/index.d.ts +31 -0
- package/lib/cache/index.js +22 -0
- package/lib/cache/internal.d.ts +4 -0
- package/lib/cache/internal.js +1 -0
- package/lib/cache/magicalAndBlessedAdvantagesAndDisadvantages.d.ts +3 -0
- package/lib/cache/magicalAndBlessedAdvantagesAndDisadvantages.js +103 -0
- package/lib/cache/newApplicationsAndUses.d.ts +22 -0
- package/lib/cache/newApplicationsAndUses.js +12 -0
- package/lib/types/Advantage.d.ts +3 -3
- package/lib/types/AnimalDisease.d.ts +1 -1
- package/lib/types/Blessing.d.ts +1 -1
- package/lib/types/Cantrip.d.ts +1 -1
- package/lib/types/Ceremony.d.ts +2 -2
- package/lib/types/CombatTechnique.d.ts +2 -2
- package/lib/types/Condition.d.ts +1 -1
- package/lib/types/Culture.d.ts +1 -1
- package/lib/types/DerivedCharacteristic.d.ts +1 -1
- package/lib/types/Disadvantage.d.ts +3 -3
- package/lib/types/Disease.d.ts +1 -1
- package/lib/types/FamiliarsTrick.d.ts +1 -1
- package/lib/types/Lessons.d.ts +1 -1
- package/lib/types/LiturgicalChant.d.ts +2 -2
- package/lib/types/Locale.d.ts +5 -0
- package/lib/types/Locale.js +9 -0
- package/lib/types/MetaCondition.d.ts +1 -1
- package/lib/types/PactCategory.d.ts +1 -1
- package/lib/types/Patron.d.ts +1 -1
- package/lib/types/PersonalityTrait.d.ts +1 -1
- package/lib/types/Profession.d.ts +2 -2
- package/lib/types/Race.d.ts +1 -1
- package/lib/types/Ritual.d.ts +2 -2
- package/lib/types/Service.d.ts +1 -1
- package/lib/types/SexPractice.d.ts +1 -1
- package/lib/types/Skill.d.ts +1 -1
- package/lib/types/Spell.d.ts +2 -2
- package/lib/types/State.d.ts +1 -1
- package/lib/types/Talisman.d.ts +1 -1
- package/lib/types/_ActivatableSelectOptions.d.ts +2 -2
- package/lib/types/_Enhancements.d.ts +2 -2
- package/lib/types/_Influence.d.ts +1 -1
- package/lib/types/equipment/EquipmentPackage.d.ts +1 -1
- package/lib/types/equipment/item/Ammunition.d.ts +1 -1
- package/lib/types/equipment/item/Animal.d.ts +1 -1
- package/lib/types/equipment/item/AnimalCare.d.ts +1 -1
- package/lib/types/equipment/item/Armor.d.ts +1 -1
- package/lib/types/equipment/item/BandageOrRemedy.d.ts +1 -1
- package/lib/types/equipment/item/Book.d.ts +1 -1
- package/lib/types/equipment/item/CeremonialItem.d.ts +1 -1
- package/lib/types/equipment/item/Clothes.d.ts +1 -1
- package/lib/types/equipment/item/ClothingPackage.d.ts +1 -1
- package/lib/types/equipment/item/Container.d.ts +1 -1
- package/lib/types/equipment/item/Elixir.d.ts +1 -1
- package/lib/types/equipment/item/EquipmentOfBlessedOnes.d.ts +1 -1
- package/lib/types/equipment/item/GemOrPreciousStone.d.ts +1 -1
- package/lib/types/equipment/item/IlluminationLightSource.d.ts +1 -1
- package/lib/types/equipment/item/IlluminationRefillOrSupply.d.ts +1 -1
- package/lib/types/equipment/item/Jewelry.d.ts +1 -1
- package/lib/types/equipment/item/Laboratory.d.ts +1 -1
- package/lib/types/equipment/item/Liebesspielzeug.d.ts +1 -1
- package/lib/types/equipment/item/LuxuryGood.d.ts +1 -1
- package/lib/types/equipment/item/MagicalArtifact.d.ts +1 -1
- package/lib/types/equipment/item/MusicalInstrument.d.ts +1 -1
- package/lib/types/equipment/item/Newspaper.d.ts +1 -1
- package/lib/types/equipment/item/OrienteeringAid.d.ts +1 -1
- package/lib/types/equipment/item/Poison.d.ts +1 -1
- package/lib/types/equipment/item/RopeOrChain.d.ts +1 -1
- package/lib/types/equipment/item/Stationery.d.ts +1 -1
- package/lib/types/equipment/item/ThievesTool.d.ts +1 -1
- package/lib/types/equipment/item/ToolOfTheTrade.d.ts +1 -1
- package/lib/types/equipment/item/TravelGearOrTool.d.ts +1 -1
- package/lib/types/equipment/item/Vehicle.d.ts +1 -1
- package/lib/types/equipment/item/Weapon.d.ts +1 -1
- package/lib/types/equipment/item/WeaponAccessory.d.ts +1 -1
- package/lib/types/equipment/item/_Item.d.ts +1 -1
- package/lib/types/magicalActions/AnimistPower.d.ts +2 -2
- package/lib/types/magicalActions/Curse.d.ts +1 -1
- package/lib/types/magicalActions/DominationRitual.d.ts +1 -1
- package/lib/types/magicalActions/ElvenMagicalSong.d.ts +1 -1
- package/lib/types/magicalActions/GeodeRitual.d.ts +1 -1
- package/lib/types/magicalActions/JesterTrick.d.ts +1 -1
- package/lib/types/magicalActions/MagicalDance.d.ts +1 -1
- package/lib/types/magicalActions/MagicalMelody.d.ts +1 -1
- package/lib/types/magicalActions/MagicalRune.d.ts +1 -1
- package/lib/types/magicalActions/ZibiljaRitual.d.ts +1 -1
- package/lib/types/rule/AlternativeRule.d.ts +1 -1
- package/lib/types/rule/CoreRule.d.ts +1 -1
- package/lib/types/rule/FocusRule.d.ts +1 -1
- package/lib/types/rule/OptionalRule.d.ts +1 -1
- package/lib/types/source/_PublicationRef.d.ts +4 -4
- package/lib/types/source/_PublicationRef.js +34 -30
- package/lib/types/specialAbility/AdvancedCombatSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/AdvancedKarmaSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/AdvancedMagicalSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/AdvancedSkillSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/AncestorGlyph.d.ts +3 -3
- package/lib/types/specialAbility/BlessedTradition.d.ts +4 -4
- package/lib/types/specialAbility/BlessedTradition.js +2 -2
- package/lib/types/specialAbility/BrawlingSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/CeremonialItemSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/CombatSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/CombatStyleSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/CommandSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/FamiliarSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/FatePointSexSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/FatePointSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/GeneralSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/KarmaSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/LiturgicalStyleSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/LycantropicGift.d.ts +3 -3
- package/lib/types/specialAbility/MagicStyleSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/MagicalSign.d.ts +1 -1
- package/lib/types/specialAbility/MagicalSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/MagicalTradition.d.ts +3 -3
- package/lib/types/specialAbility/PactGift.d.ts +3 -3
- package/lib/types/specialAbility/ProtectiveWardingCircleSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/Sermon.d.ts +3 -3
- package/lib/types/specialAbility/SexSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/SikaryanDrainSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/SkillStyleSpecialAbility.d.ts +3 -3
- package/lib/types/specialAbility/VampiricGift.d.ts +3 -3
- package/lib/types/specialAbility/Vision.d.ts +3 -3
- package/lib/types/specialAbility/sub/Language.d.ts +1 -1
- package/lib/types/specialAbility/sub/Script.d.ts +1 -1
- package/lib/types/specialAbility/sub/TradeSecret.d.ts +3 -3
- package/lib/types/traditionArtifacts/ArcaneOrbEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/AttireEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/Beutelzauber.d.ts +3 -3
- package/lib/types/traditionArtifacts/BowlEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/CauldronEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/ChronicleEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/DaggerRitual.d.ts +3 -3
- package/lib/types/traditionArtifacts/FoolsHatEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/Haubenzauber.d.ts +3 -3
- package/lib/types/traditionArtifacts/InstrumentEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/Krallenkettenzauber.d.ts +3 -3
- package/lib/types/traditionArtifacts/Kristallkugelzauber.d.ts +3 -3
- package/lib/types/traditionArtifacts/OrbEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/RingEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/SickleRitual.d.ts +3 -3
- package/lib/types/traditionArtifacts/SpellSwordEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/StaffEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/ToyEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/Trinkhornzauber.d.ts +3 -3
- package/lib/types/traditionArtifacts/WandEnchantment.d.ts +3 -3
- package/lib/types/traditionArtifacts/WeaponEnchantment.d.ts +3 -3
- package/package.json +7 -10
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
import { on } from "@elyukai/utils/function";
|
|
2
|
+
import { isNotNullish } from "@elyukai/utils/nullable";
|
|
3
|
+
import { mapObject } from "@elyukai/utils/object";
|
|
4
|
+
import { compareNullish, compareNumber } from "@elyukai/utils/ordering";
|
|
5
|
+
import { assertExhaustive } from "@elyukai/utils/typeSafety";
|
|
6
|
+
import { Case, fromUniformCase } from "tsondb/schema/gen";
|
|
7
|
+
const wrapPlainApValue = (apValue) => apValue === undefined ? undefined : Case("Fixed", apValue);
|
|
8
|
+
const matchesSpecificSkillishIdList = (id, config) => {
|
|
9
|
+
switch (config.operation.kind) {
|
|
10
|
+
case "Intersection":
|
|
11
|
+
return config.list.includes(id);
|
|
12
|
+
case "Difference":
|
|
13
|
+
return !config.list.includes(id);
|
|
14
|
+
default:
|
|
15
|
+
return assertExhaustive(config.operation);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const getSkillishPrerequisites = (ps, id) => {
|
|
19
|
+
if (ps === undefined) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return ps.map(p => {
|
|
23
|
+
switch (p.kind) {
|
|
24
|
+
case "Self":
|
|
25
|
+
return {
|
|
26
|
+
level: 1,
|
|
27
|
+
prerequisite: Case("Single", Case("Rated", {
|
|
28
|
+
id,
|
|
29
|
+
value: p.Self.value,
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
case "SelectOption":
|
|
33
|
+
return {
|
|
34
|
+
level: 1,
|
|
35
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
36
|
+
id: p.SelectOption.id,
|
|
37
|
+
active: p.SelectOption.active,
|
|
38
|
+
level: p.SelectOption.level,
|
|
39
|
+
options: [id],
|
|
40
|
+
})),
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
return assertExhaustive(p);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const getSkillishBindingCost = (bindingCost, id) => {
|
|
48
|
+
if (bindingCost === undefined) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return (bindingCost.Fixed.map.find(mapping => equalsSkillishIdGroup(mapping.id, id))?.bindingCost ??
|
|
52
|
+
bindingCost.Fixed.default);
|
|
53
|
+
};
|
|
54
|
+
const equalsSkillishIdGroup = (a, b) => {
|
|
55
|
+
switch (a.kind) {
|
|
56
|
+
case "Skill":
|
|
57
|
+
return b.kind === "Skill" && a.Skill === b.Skill;
|
|
58
|
+
case "Spell":
|
|
59
|
+
return b.kind === "Spell" && a.Spell === b.Spell;
|
|
60
|
+
case "Ritual":
|
|
61
|
+
return b.kind === "Ritual" && a.Ritual === b.Ritual;
|
|
62
|
+
case "LiturgicalChant":
|
|
63
|
+
return b.kind === "LiturgicalChant" && a.LiturgicalChant === b.LiturgicalChant;
|
|
64
|
+
case "Ceremony":
|
|
65
|
+
return b.kind === "Ceremony" && a.Ceremony === b.Ceremony;
|
|
66
|
+
case "CloseCombatTechnique":
|
|
67
|
+
return b.kind === "CloseCombatTechnique" && a.CloseCombatTechnique === b.CloseCombatTechnique;
|
|
68
|
+
case "RangedCombatTechnique":
|
|
69
|
+
return (b.kind === "RangedCombatTechnique" && a.RangedCombatTechnique === b.RangedCombatTechnique);
|
|
70
|
+
default:
|
|
71
|
+
return assertExhaustive(a);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const getApValueForSkillish = (config, id, ic) => {
|
|
75
|
+
if (config === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
switch (config.kind) {
|
|
79
|
+
case "DerivedFromImprovementCost":
|
|
80
|
+
return ((() => {
|
|
81
|
+
switch (ic.kind) {
|
|
82
|
+
case "A":
|
|
83
|
+
return 1;
|
|
84
|
+
case "B":
|
|
85
|
+
return 2;
|
|
86
|
+
case "C":
|
|
87
|
+
return 3;
|
|
88
|
+
case "D":
|
|
89
|
+
return 4;
|
|
90
|
+
default:
|
|
91
|
+
assertExhaustive(ic);
|
|
92
|
+
}
|
|
93
|
+
})() *
|
|
94
|
+
(config.DerivedFromImprovementCost.multiplier ?? 1) +
|
|
95
|
+
(config.DerivedFromImprovementCost.offset ?? 0));
|
|
96
|
+
case "Fixed":
|
|
97
|
+
return (config.Fixed.map.find(mapping => equalsSkillishIdGroup(mapping.id, id))?.ap_value ??
|
|
98
|
+
config.Fixed.default);
|
|
99
|
+
default:
|
|
100
|
+
return assertExhaustive(config);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const convertSkillApplicationOrUse = (entryId, id, applicationOrUse) => ({
|
|
104
|
+
id: fromUniformCase(entryId) + "+" + applicationOrUse.id,
|
|
105
|
+
content: {
|
|
106
|
+
parent: entryId,
|
|
107
|
+
skills: [id],
|
|
108
|
+
translations: applicationOrUse.translations,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
const getDefaultSkillishFilter = (category) => {
|
|
112
|
+
const { specific } = category;
|
|
113
|
+
return specific === undefined
|
|
114
|
+
? undefined
|
|
115
|
+
: ({ id }) => matchesSpecificSkillishIdList(id, specific);
|
|
116
|
+
};
|
|
117
|
+
const getDerivedSkillishSelectOptions = (database, entryId, entity, category, options, filter = getDefaultSkillishFilter(category)) => {
|
|
118
|
+
const { prerequisites } = category;
|
|
119
|
+
const { bindingCost, ap_value } = options;
|
|
120
|
+
const instances = database.getAllInstanceContainersOfEntity(entity);
|
|
121
|
+
const filteredInstances = filter === undefined ? instances : instances.filter(filter);
|
|
122
|
+
return filteredInstances.map(({ id, content }) => {
|
|
123
|
+
const wrappedId = Case(entity, id);
|
|
124
|
+
return {
|
|
125
|
+
id: wrappedId,
|
|
126
|
+
content: {
|
|
127
|
+
parent: entryId,
|
|
128
|
+
prerequisites: getSkillishPrerequisites(prerequisites, wrappedId),
|
|
129
|
+
binding_cost: getSkillishBindingCost(bindingCost, wrappedId),
|
|
130
|
+
ap_value: wrapPlainApValue(getApValueForSkillish(ap_value, wrappedId, content.improvement_cost)),
|
|
131
|
+
src: content.src,
|
|
132
|
+
translations: mapObject(content.translations, t10n => ({
|
|
133
|
+
name: t10n.name,
|
|
134
|
+
})),
|
|
135
|
+
},
|
|
136
|
+
newApplications: category.skill_applications?.map(app => convertSkillApplicationOrUse(entryId, id, app)) ??
|
|
137
|
+
[],
|
|
138
|
+
uses: category.skill_uses?.map(use => convertSkillApplicationOrUse(entryId, id, use)) ?? [],
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const getDerivedSelectOptions = (selectOptionCategory, entryId, database, idMap) => {
|
|
143
|
+
switch (selectOptionCategory.kind) {
|
|
144
|
+
case "Blessings":
|
|
145
|
+
return database.getAllInstanceContainersOfEntity("Blessing").map(({ id, content }) => ({
|
|
146
|
+
id: Case("Blessing", id),
|
|
147
|
+
content: {
|
|
148
|
+
parent: entryId,
|
|
149
|
+
src: content.src,
|
|
150
|
+
translations: mapObject(content.translations, t10n => ({ name: t10n.name })),
|
|
151
|
+
},
|
|
152
|
+
newApplications: [],
|
|
153
|
+
uses: [],
|
|
154
|
+
}));
|
|
155
|
+
case "Cantrips":
|
|
156
|
+
return database.getAllInstanceContainersOfEntity("Cantrip").map(({ id, content }) => ({
|
|
157
|
+
id: Case("Cantrip", id),
|
|
158
|
+
content: {
|
|
159
|
+
parent: entryId,
|
|
160
|
+
src: content.src,
|
|
161
|
+
translations: mapObject(content.translations, t10n => ({ name: t10n.name })),
|
|
162
|
+
},
|
|
163
|
+
newApplications: [],
|
|
164
|
+
uses: [],
|
|
165
|
+
}));
|
|
166
|
+
case "TradeSecrets":
|
|
167
|
+
return database.getAllInstanceContainersOfEntity("TradeSecret").map(({ id, content }) => ({
|
|
168
|
+
id: Case("TradeSecret", id),
|
|
169
|
+
content: {
|
|
170
|
+
parent: entryId,
|
|
171
|
+
prerequisites: content.prerequisites?.map(p => ({ level: 1, prerequisite: p })),
|
|
172
|
+
ap_value: content.ap_value,
|
|
173
|
+
src: content.src,
|
|
174
|
+
translations: mapObject(content.translations, t10n => ({
|
|
175
|
+
name: t10n.name,
|
|
176
|
+
errata: t10n.errata,
|
|
177
|
+
})),
|
|
178
|
+
},
|
|
179
|
+
newApplications: [],
|
|
180
|
+
uses: [],
|
|
181
|
+
}));
|
|
182
|
+
case "Scripts":
|
|
183
|
+
return database.getAllInstanceContainersOfEntity("Script").map(({ id, content }) => ({
|
|
184
|
+
id: Case("Script", id),
|
|
185
|
+
content: {
|
|
186
|
+
parent: entryId,
|
|
187
|
+
ap_value: wrapPlainApValue(content.ap_value),
|
|
188
|
+
src: content.src,
|
|
189
|
+
translations: mapObject(content.translations, t10n => ({
|
|
190
|
+
name: t10n.name,
|
|
191
|
+
errata: t10n.errata,
|
|
192
|
+
})),
|
|
193
|
+
},
|
|
194
|
+
newApplications: [],
|
|
195
|
+
uses: [],
|
|
196
|
+
}));
|
|
197
|
+
case "AnimalShapes": {
|
|
198
|
+
const animalShapePaths = database.getAllInstanceContainersOfEntity("AnimalShapePath");
|
|
199
|
+
const animalShapeSizes = database.getAllInstanceContainersOfEntity("AnimalShapeSize");
|
|
200
|
+
const animalShapes = database.getAllInstanceContainersOfEntity("AnimalShape");
|
|
201
|
+
const pathsWithOrderedIds = animalShapePaths.reduce((acc, { id }) => ({
|
|
202
|
+
...acc,
|
|
203
|
+
[id]: animalShapes
|
|
204
|
+
.toSorted(on(item => database.getInstanceContainerOfEntityById("AnimalShapeSize", item.content.size)
|
|
205
|
+
?.content.volume, compareNullish(compareNumber)))
|
|
206
|
+
.map(({ id }) => id),
|
|
207
|
+
}), {});
|
|
208
|
+
return animalShapes.map(({ id, content }) => {
|
|
209
|
+
const path = animalShapePaths.find(({ id: pathId }) => pathId === content.path);
|
|
210
|
+
const size = animalShapeSizes.find(({ id: sizeId }) => sizeId === content.size);
|
|
211
|
+
const pathIndex = path !== undefined ? (pathsWithOrderedIds[path.id]?.indexOf(id) ?? -1) : -1;
|
|
212
|
+
return {
|
|
213
|
+
id: Case("AnimalShape", id),
|
|
214
|
+
content: {
|
|
215
|
+
parent: entryId,
|
|
216
|
+
prerequisites: pathIndex >= 0
|
|
217
|
+
? pathIndex === 0
|
|
218
|
+
? animalShapePaths
|
|
219
|
+
.filter(({ id: pathId }) => pathId !== content.path && pathsWithOrderedIds[pathId]?.[0] !== undefined)
|
|
220
|
+
.map(({ id: pathId }) => ({
|
|
221
|
+
level: 1,
|
|
222
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
223
|
+
id: entryId,
|
|
224
|
+
active: false,
|
|
225
|
+
options: [Case("AnimalShape", pathsWithOrderedIds[pathId][0])],
|
|
226
|
+
})),
|
|
227
|
+
}))
|
|
228
|
+
: [
|
|
229
|
+
{
|
|
230
|
+
level: 1,
|
|
231
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
232
|
+
id: entryId,
|
|
233
|
+
active: true,
|
|
234
|
+
options: [
|
|
235
|
+
Case("AnimalShape", pathsWithOrderedIds[path.id][pathIndex - 1]),
|
|
236
|
+
],
|
|
237
|
+
})),
|
|
238
|
+
},
|
|
239
|
+
]
|
|
240
|
+
: undefined,
|
|
241
|
+
volume: size?.content.volume,
|
|
242
|
+
ap_value: wrapPlainApValue(size?.content.ap_value),
|
|
243
|
+
translations: mapObject(content.translations, (t10n, lang) => ({
|
|
244
|
+
name: path?.content.translations[lang] !== undefined
|
|
245
|
+
? `${t10n.name} (${path.content.translations[lang].name})`
|
|
246
|
+
: t10n.name,
|
|
247
|
+
})),
|
|
248
|
+
},
|
|
249
|
+
newApplications: [],
|
|
250
|
+
uses: [],
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
case "ArcaneBardTraditions":
|
|
255
|
+
return database.getAllInstanceContainersOfEntity("ArcaneBardTradition").map(({ id, content }) => ({
|
|
256
|
+
id: Case("ArcaneBardTradition", id),
|
|
257
|
+
content: {
|
|
258
|
+
parent: entryId,
|
|
259
|
+
prerequisites: content.prerequisites.map(p => ({
|
|
260
|
+
level: 1,
|
|
261
|
+
prerequisite: p,
|
|
262
|
+
})),
|
|
263
|
+
translations: mapObject(content.translations, t10n => ({
|
|
264
|
+
name: t10n.name,
|
|
265
|
+
})),
|
|
266
|
+
},
|
|
267
|
+
newApplications: [],
|
|
268
|
+
uses: [],
|
|
269
|
+
}));
|
|
270
|
+
case "ArcaneDancerTraditions":
|
|
271
|
+
return database.getAllInstanceContainersOfEntity("ArcaneDancerTradition").map(({ id, content }) => ({
|
|
272
|
+
id: Case("ArcaneDancerTradition", id),
|
|
273
|
+
content: {
|
|
274
|
+
parent: entryId,
|
|
275
|
+
prerequisites: content.prerequisites.map(p => ({
|
|
276
|
+
level: 1,
|
|
277
|
+
prerequisite: p,
|
|
278
|
+
})),
|
|
279
|
+
translations: mapObject(content.translations, t10n => ({
|
|
280
|
+
name: t10n.name,
|
|
281
|
+
})),
|
|
282
|
+
},
|
|
283
|
+
newApplications: [],
|
|
284
|
+
uses: [],
|
|
285
|
+
}));
|
|
286
|
+
case "SexPractices":
|
|
287
|
+
return database.getAllInstanceContainersOfEntity("SexPractice").map(({ id, content }) => ({
|
|
288
|
+
id: Case("SexPractice", id),
|
|
289
|
+
content: {
|
|
290
|
+
parent: entryId,
|
|
291
|
+
src: content.src,
|
|
292
|
+
translations: mapObject(content.translations, t10n => ({
|
|
293
|
+
name: t10n.name,
|
|
294
|
+
})),
|
|
295
|
+
},
|
|
296
|
+
newApplications: [],
|
|
297
|
+
uses: [],
|
|
298
|
+
}));
|
|
299
|
+
case "Races":
|
|
300
|
+
return database.getAllInstanceContainersOfEntity("Race").map(({ id, content }) => ({
|
|
301
|
+
id: Case("Race", id),
|
|
302
|
+
content: {
|
|
303
|
+
parent: entryId,
|
|
304
|
+
src: content.src,
|
|
305
|
+
translations: mapObject(content.translations, t10n => ({
|
|
306
|
+
name: t10n.name,
|
|
307
|
+
})),
|
|
308
|
+
},
|
|
309
|
+
newApplications: [],
|
|
310
|
+
uses: [],
|
|
311
|
+
}));
|
|
312
|
+
case "Cultures":
|
|
313
|
+
return database.getAllInstanceContainersOfEntity("Culture").map(({ id, content }) => ({
|
|
314
|
+
id: Case("Culture", id),
|
|
315
|
+
content: {
|
|
316
|
+
parent: entryId,
|
|
317
|
+
src: content.src,
|
|
318
|
+
translations: mapObject(content.translations, t10n => ({
|
|
319
|
+
name: t10n.name,
|
|
320
|
+
})),
|
|
321
|
+
},
|
|
322
|
+
newApplications: [],
|
|
323
|
+
uses: [],
|
|
324
|
+
}));
|
|
325
|
+
case "RacesAndCultures":
|
|
326
|
+
return [
|
|
327
|
+
...database.getAllInstanceContainersOfEntity("Race").map(({ id, content }) => ({
|
|
328
|
+
id: Case("Race", id),
|
|
329
|
+
content: {
|
|
330
|
+
parent: entryId,
|
|
331
|
+
src: content.src,
|
|
332
|
+
translations: mapObject(content.translations, t10n => ({
|
|
333
|
+
name: t10n.name,
|
|
334
|
+
})),
|
|
335
|
+
},
|
|
336
|
+
newApplications: [],
|
|
337
|
+
uses: [],
|
|
338
|
+
})),
|
|
339
|
+
...database.getAllInstanceContainersOfEntity("Culture").map(({ id, content }) => ({
|
|
340
|
+
id: Case("Culture", id),
|
|
341
|
+
content: {
|
|
342
|
+
parent: entryId,
|
|
343
|
+
src: content.src,
|
|
344
|
+
translations: mapObject(content.translations, t10n => ({
|
|
345
|
+
name: t10n.name,
|
|
346
|
+
})),
|
|
347
|
+
},
|
|
348
|
+
newApplications: [],
|
|
349
|
+
uses: [],
|
|
350
|
+
})),
|
|
351
|
+
];
|
|
352
|
+
case "HomunculusTypes":
|
|
353
|
+
return database.getAllInstanceContainersOfEntity("HomunculusType").map(({ id, content }) => ({
|
|
354
|
+
id: Case("HomunculusType", id),
|
|
355
|
+
content: {
|
|
356
|
+
parent: entryId,
|
|
357
|
+
translations: mapObject(content.translations, t10n => ({
|
|
358
|
+
name: t10n.name,
|
|
359
|
+
})),
|
|
360
|
+
},
|
|
361
|
+
newApplications: [],
|
|
362
|
+
uses: [],
|
|
363
|
+
}));
|
|
364
|
+
case "BlessedTraditions": {
|
|
365
|
+
const getPrerequisites = (blessedTradition) => {
|
|
366
|
+
if (selectOptionCategory.BlessedTraditions.require_principles &&
|
|
367
|
+
blessedTradition.associated_principles_id !== undefined) {
|
|
368
|
+
const option = database.getInstanceContainerOfEntityById("GeneralSelectOption", blessedTradition.associated_principles_id);
|
|
369
|
+
if (option === undefined || option.content.parent.kind === "TradeSecret") {
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
return [
|
|
373
|
+
{
|
|
374
|
+
level: 1,
|
|
375
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
376
|
+
id: option.content.parent,
|
|
377
|
+
active: true,
|
|
378
|
+
options: [Case("General", blessedTradition.associated_principles_id)],
|
|
379
|
+
})),
|
|
380
|
+
},
|
|
381
|
+
];
|
|
382
|
+
}
|
|
383
|
+
return undefined;
|
|
384
|
+
};
|
|
385
|
+
return database.getAllInstanceContainersOfEntity("BlessedTradition").map(({ id, content }) => ({
|
|
386
|
+
id: Case("BlessedTradition", id),
|
|
387
|
+
content: {
|
|
388
|
+
parent: entryId,
|
|
389
|
+
prerequisites: getPrerequisites(content),
|
|
390
|
+
src: content.src,
|
|
391
|
+
translations: mapObject(content.translations, t10n => ({
|
|
392
|
+
name: t10n.name,
|
|
393
|
+
})),
|
|
394
|
+
},
|
|
395
|
+
newApplications: [],
|
|
396
|
+
uses: [],
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
399
|
+
case "Elements": {
|
|
400
|
+
const mapToResolvedSelectOption = ({ id, content, }) => ({
|
|
401
|
+
id: Case("Element", id),
|
|
402
|
+
content: {
|
|
403
|
+
parent: entryId,
|
|
404
|
+
translations: mapObject(content.translations, t10n => ({
|
|
405
|
+
name: t10n.name,
|
|
406
|
+
})),
|
|
407
|
+
},
|
|
408
|
+
newApplications: [],
|
|
409
|
+
uses: [],
|
|
410
|
+
});
|
|
411
|
+
const specific = selectOptionCategory.Elements.specific;
|
|
412
|
+
if (specific) {
|
|
413
|
+
return database
|
|
414
|
+
.getAllInstanceContainersOfEntity("Element")
|
|
415
|
+
.filter(({ id }) => specific.includes(id))
|
|
416
|
+
.map(mapToResolvedSelectOption);
|
|
417
|
+
}
|
|
418
|
+
return database.getAllInstanceContainersOfEntity("Element").map(mapToResolvedSelectOption);
|
|
419
|
+
}
|
|
420
|
+
case "Properties": {
|
|
421
|
+
const getPrerequisites = (id) => {
|
|
422
|
+
if (selectOptionCategory.Properties.require_knowledge !== undefined ||
|
|
423
|
+
selectOptionCategory.Properties.require_minimum_spellworks_on !== undefined) {
|
|
424
|
+
const knowledgePrerequisite = selectOptionCategory.Properties.require_knowledge !== undefined
|
|
425
|
+
? {
|
|
426
|
+
level: 1,
|
|
427
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
428
|
+
id: Case("MagicalSpecialAbility", idMap.MagicalSpecialAbility.PropertyKnowledge),
|
|
429
|
+
active: true,
|
|
430
|
+
options: [Case("Property", id)],
|
|
431
|
+
})),
|
|
432
|
+
}
|
|
433
|
+
: undefined;
|
|
434
|
+
const minimumSpellworksPrerequisite = selectOptionCategory.Properties.require_minimum_spellworks_on !== undefined
|
|
435
|
+
? {
|
|
436
|
+
level: 1,
|
|
437
|
+
prerequisite: Case("Single", Case("RatedMinimumNumber", {
|
|
438
|
+
number: selectOptionCategory.Properties.require_minimum_spellworks_on.number,
|
|
439
|
+
value: selectOptionCategory.Properties.require_minimum_spellworks_on.rating,
|
|
440
|
+
targets: Case("Spellworks", {
|
|
441
|
+
property: id,
|
|
442
|
+
}),
|
|
443
|
+
})),
|
|
444
|
+
}
|
|
445
|
+
: undefined;
|
|
446
|
+
return [knowledgePrerequisite, minimumSpellworksPrerequisite].filter(isNotNullish);
|
|
447
|
+
}
|
|
448
|
+
return undefined;
|
|
449
|
+
};
|
|
450
|
+
return database.getAllInstanceContainersOfEntity("Property").map(({ id, content }) => ({
|
|
451
|
+
id: Case("Property", id),
|
|
452
|
+
content: {
|
|
453
|
+
parent: entryId,
|
|
454
|
+
prerequisites: getPrerequisites(id),
|
|
455
|
+
translations: mapObject(content.translations, t10n => ({
|
|
456
|
+
name: t10n.name,
|
|
457
|
+
})),
|
|
458
|
+
},
|
|
459
|
+
newApplications: [],
|
|
460
|
+
uses: [],
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
case "Aspects": {
|
|
464
|
+
const getPrerequisites = (id) => {
|
|
465
|
+
if (selectOptionCategory.Aspects.require_knowledge !== undefined ||
|
|
466
|
+
selectOptionCategory.Aspects.require_minimum_liturgies_on !== undefined) {
|
|
467
|
+
const knowledgePrerequisite = selectOptionCategory.Aspects.require_knowledge !== undefined
|
|
468
|
+
? {
|
|
469
|
+
level: 1,
|
|
470
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
471
|
+
id: Case("KarmaSpecialAbility", idMap.KarmaSpecialAbility.AspectKnowledge),
|
|
472
|
+
active: true,
|
|
473
|
+
options: [Case("Aspect", id)],
|
|
474
|
+
})),
|
|
475
|
+
}
|
|
476
|
+
: undefined;
|
|
477
|
+
const minimumSpellworksPrerequisite = selectOptionCategory.Aspects.require_minimum_liturgies_on !== undefined
|
|
478
|
+
? {
|
|
479
|
+
level: 1,
|
|
480
|
+
prerequisite: Case("Single", Case("RatedMinimumNumber", {
|
|
481
|
+
number: selectOptionCategory.Aspects.require_minimum_liturgies_on.number,
|
|
482
|
+
value: selectOptionCategory.Aspects.require_minimum_liturgies_on.rating,
|
|
483
|
+
targets: Case("Liturgies", {
|
|
484
|
+
aspect: id,
|
|
485
|
+
}),
|
|
486
|
+
})),
|
|
487
|
+
}
|
|
488
|
+
: undefined;
|
|
489
|
+
return [knowledgePrerequisite, minimumSpellworksPrerequisite].filter(isNotNullish);
|
|
490
|
+
}
|
|
491
|
+
return undefined;
|
|
492
|
+
};
|
|
493
|
+
if (selectOptionCategory.Aspects.use_master_of_suffix_as_name === true) {
|
|
494
|
+
return database
|
|
495
|
+
.getAllInstanceContainersOfEntity("Aspect")
|
|
496
|
+
.map(({ id, content }) => ({
|
|
497
|
+
id: Case("Aspect", id),
|
|
498
|
+
content: {
|
|
499
|
+
parent: entryId,
|
|
500
|
+
prerequisites: getPrerequisites(id),
|
|
501
|
+
translations: mapObject(content.translations, t10n => t10n.master_of_aspect_suffix === undefined
|
|
502
|
+
? undefined
|
|
503
|
+
: {
|
|
504
|
+
name: t10n.master_of_aspect_suffix,
|
|
505
|
+
}),
|
|
506
|
+
},
|
|
507
|
+
newApplications: [],
|
|
508
|
+
uses: [],
|
|
509
|
+
}))
|
|
510
|
+
.filter(value => Object.keys(value.content.translations).length > 0);
|
|
511
|
+
}
|
|
512
|
+
return database.getAllInstanceContainersOfEntity("Aspect").map(({ id, content }) => ({
|
|
513
|
+
id: Case("Aspect", id),
|
|
514
|
+
content: {
|
|
515
|
+
parent: entryId,
|
|
516
|
+
prerequisites: getPrerequisites(id),
|
|
517
|
+
translations: mapObject(content.translations, t10n => ({
|
|
518
|
+
name: t10n.name,
|
|
519
|
+
})),
|
|
520
|
+
},
|
|
521
|
+
newApplications: [],
|
|
522
|
+
uses: [],
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
case "Diseases":
|
|
526
|
+
return database.getAllInstanceContainersOfEntity("Disease").map(({ id, content }) => ({
|
|
527
|
+
id: Case("Disease", id),
|
|
528
|
+
content: {
|
|
529
|
+
parent: entryId,
|
|
530
|
+
ap_value: wrapPlainApValue(selectOptionCategory.Diseases.use_half_level_as_ap_value === true
|
|
531
|
+
? Math.round(content.level / 3)
|
|
532
|
+
: content.level),
|
|
533
|
+
src: content.src,
|
|
534
|
+
translations: mapObject(content.translations, t10n => ({
|
|
535
|
+
name: t10n.name,
|
|
536
|
+
})),
|
|
537
|
+
},
|
|
538
|
+
newApplications: [],
|
|
539
|
+
uses: [],
|
|
540
|
+
}));
|
|
541
|
+
case "Poisons": {
|
|
542
|
+
const getLevel = (poison) => {
|
|
543
|
+
switch (poison.source_type.kind) {
|
|
544
|
+
case "AnimalVenom":
|
|
545
|
+
switch (poison.source_type.AnimalVenom.level.kind) {
|
|
546
|
+
case "Constant":
|
|
547
|
+
return poison.source_type.AnimalVenom.level.Constant;
|
|
548
|
+
case "QualityLevel":
|
|
549
|
+
return 6;
|
|
550
|
+
case "BySubtype":
|
|
551
|
+
return Math.min(6, Math.max(...poison.source_type.AnimalVenom.level.BySubtype.map(subtype => subtype.value)));
|
|
552
|
+
default:
|
|
553
|
+
return assertExhaustive(poison.source_type.AnimalVenom.level);
|
|
554
|
+
}
|
|
555
|
+
case "AlchemicalPoison":
|
|
556
|
+
return 6;
|
|
557
|
+
case "MineralPoison":
|
|
558
|
+
return poison.source_type.MineralPoison.level;
|
|
559
|
+
case "PlantPoison":
|
|
560
|
+
return poison.source_type.PlantPoison.level;
|
|
561
|
+
case "DemonicPoison":
|
|
562
|
+
switch (poison.source_type.DemonicPoison.level.kind) {
|
|
563
|
+
case "Constant":
|
|
564
|
+
return poison.source_type.DemonicPoison.level.Constant.value;
|
|
565
|
+
case "QualityLevel":
|
|
566
|
+
return 6;
|
|
567
|
+
default:
|
|
568
|
+
return assertExhaustive(poison.source_type.DemonicPoison.level);
|
|
569
|
+
}
|
|
570
|
+
default:
|
|
571
|
+
return assertExhaustive(poison.source_type);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
return database.getAllInstanceContainersOfEntity("Poison").map(({ id, content }) => ({
|
|
575
|
+
id: Case("Poison", id),
|
|
576
|
+
content: {
|
|
577
|
+
parent: entryId,
|
|
578
|
+
ap_value: wrapPlainApValue(selectOptionCategory.Poisons.use_half_level_as_ap_value === true
|
|
579
|
+
? Math.round(getLevel(content) / 3)
|
|
580
|
+
: getLevel(content)),
|
|
581
|
+
src: content.src,
|
|
582
|
+
translations: mapObject(content.translations, t10n => ({
|
|
583
|
+
name: t10n.name,
|
|
584
|
+
})),
|
|
585
|
+
},
|
|
586
|
+
newApplications: [],
|
|
587
|
+
uses: [],
|
|
588
|
+
}));
|
|
589
|
+
}
|
|
590
|
+
case "Languages": {
|
|
591
|
+
const getPrerequisites = (id) => {
|
|
592
|
+
if (selectOptionCategory.Languages.prerequisites !== undefined) {
|
|
593
|
+
return selectOptionCategory.Languages.prerequisites.map(config => ({
|
|
594
|
+
level: 1,
|
|
595
|
+
prerequisite: Case("Single", Case("Activatable", {
|
|
596
|
+
id: config.SelectOption.id,
|
|
597
|
+
active: config.SelectOption.active,
|
|
598
|
+
level: config.SelectOption.level,
|
|
599
|
+
options: [Case("Language", id)],
|
|
600
|
+
})),
|
|
601
|
+
}));
|
|
602
|
+
}
|
|
603
|
+
return undefined;
|
|
604
|
+
};
|
|
605
|
+
return database.getAllInstanceContainersOfEntity("Language").map(({ id, content }) => ({
|
|
606
|
+
id: Case("Language", id),
|
|
607
|
+
content: {
|
|
608
|
+
parent: entryId,
|
|
609
|
+
prerequisites: getPrerequisites(id),
|
|
610
|
+
src: content.src,
|
|
611
|
+
translations: mapObject(content.translations, t10n => ({
|
|
612
|
+
name: t10n.name,
|
|
613
|
+
})),
|
|
614
|
+
},
|
|
615
|
+
newApplications: [],
|
|
616
|
+
uses: [],
|
|
617
|
+
}));
|
|
618
|
+
}
|
|
619
|
+
case "Skills":
|
|
620
|
+
return selectOptionCategory.Skills.categories.flatMap(category => {
|
|
621
|
+
switch (category.kind) {
|
|
622
|
+
case "Skills":
|
|
623
|
+
return getDerivedSkillishSelectOptions(database, entryId, "Skill", category.Skills, selectOptionCategory.Skills, ({ id, content }) => {
|
|
624
|
+
const matchesGroupRequirement = category.Skills.groups === undefined ||
|
|
625
|
+
category.Skills.groups.some(ref => ref === content.group);
|
|
626
|
+
const matchesIdRequirement = category.Skills.specific === undefined ||
|
|
627
|
+
matchesSpecificSkillishIdList(id, category.Skills.specific);
|
|
628
|
+
return matchesGroupRequirement && matchesIdRequirement;
|
|
629
|
+
});
|
|
630
|
+
case "Spells":
|
|
631
|
+
return getDerivedSkillishSelectOptions(database, entryId, "Spell", category.Spells, selectOptionCategory.Skills);
|
|
632
|
+
case "Rituals":
|
|
633
|
+
return getDerivedSkillishSelectOptions(database, entryId, "Ritual", category.Rituals, selectOptionCategory.Skills);
|
|
634
|
+
case "LiturgicalChants":
|
|
635
|
+
return getDerivedSkillishSelectOptions(database, entryId, "LiturgicalChant", category.LiturgicalChants, selectOptionCategory.Skills);
|
|
636
|
+
case "Ceremonies":
|
|
637
|
+
return getDerivedSkillishSelectOptions(database, entryId, "Ceremony", category.Ceremonies, selectOptionCategory.Skills);
|
|
638
|
+
default:
|
|
639
|
+
return assertExhaustive(category);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
case "CombatTechniques":
|
|
643
|
+
return selectOptionCategory.CombatTechniques.categories.flatMap(category => {
|
|
644
|
+
switch (category.kind) {
|
|
645
|
+
case "CloseCombatTechniques":
|
|
646
|
+
return getDerivedSkillishSelectOptions(database, entryId, "CloseCombatTechnique", category.CloseCombatTechniques, selectOptionCategory.CombatTechniques);
|
|
647
|
+
case "RangedCombatTechniques":
|
|
648
|
+
return getDerivedSkillishSelectOptions(database, entryId, "RangedCombatTechnique", category.RangedCombatTechniques, selectOptionCategory.CombatTechniques);
|
|
649
|
+
default:
|
|
650
|
+
return assertExhaustive(category);
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
case "TargetCategories": {
|
|
654
|
+
const mapToResolvedSelectOption = ({ id, content }, specificTargetCategory) => ({
|
|
655
|
+
id: Case("TargetCategory", id),
|
|
656
|
+
content: {
|
|
657
|
+
parent: entryId,
|
|
658
|
+
volume: specificTargetCategory?.volume,
|
|
659
|
+
translations: mapObject(content.translations, t10n => ({
|
|
660
|
+
name: t10n.name,
|
|
661
|
+
})),
|
|
662
|
+
},
|
|
663
|
+
newApplications: [],
|
|
664
|
+
uses: [],
|
|
665
|
+
});
|
|
666
|
+
const list = selectOptionCategory.TargetCategories.list;
|
|
667
|
+
if (list) {
|
|
668
|
+
return database
|
|
669
|
+
.getAllInstanceContainersOfEntity("TargetCategory")
|
|
670
|
+
.filter(({ id }) => list.some(ref => ref.id === id))
|
|
671
|
+
.map(({ id, content }) => mapToResolvedSelectOption({ id, content }, list.find(ref => ref.id === id)));
|
|
672
|
+
}
|
|
673
|
+
return database
|
|
674
|
+
.getAllInstanceContainersOfEntity("TargetCategory")
|
|
675
|
+
.map(tc => mapToResolvedSelectOption(tc));
|
|
676
|
+
}
|
|
677
|
+
default:
|
|
678
|
+
return assertExhaustive(selectOptionCategory);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
const getExplicitSelectOptions = (id, database) => database.getAllChildInstanceContainersForParent("GeneralSelectOption", id).map(({ id, content }) => ({
|
|
682
|
+
id: Case("General", id),
|
|
683
|
+
content: {
|
|
684
|
+
...content,
|
|
685
|
+
ap_value: wrapPlainApValue(content.ap_value),
|
|
686
|
+
},
|
|
687
|
+
newApplications: [], // database.getAllChildInstanceContainersForParent("NewSkillApplication", Case("GeneralSelectOption", id)), // prevent duplicates as these can already be queried from the database
|
|
688
|
+
uses: [], // database.getAllChildInstanceContainersForParent("SkillUse", Case("GeneralSelectOption", id)), // prevent duplicates as these can already be queried from the database
|
|
689
|
+
}));
|
|
690
|
+
const getSelectOptions = (selectOptions, id, database, idMap) => [
|
|
691
|
+
...(selectOptions.derived === undefined
|
|
692
|
+
? []
|
|
693
|
+
: getDerivedSelectOptions(selectOptions.derived, id, database, idMap)),
|
|
694
|
+
...getExplicitSelectOptions(id, database),
|
|
695
|
+
];
|
|
696
|
+
const getSelectOptionsForResults = (database, idMap, entity, results) => results.reduce((acc, { id, content }) => {
|
|
697
|
+
const options = getSelectOptions(content.select_options ?? {}, Case(entity, id), database, idMap);
|
|
698
|
+
if (options.length > 0) {
|
|
699
|
+
acc[id] = options;
|
|
700
|
+
}
|
|
701
|
+
return acc;
|
|
702
|
+
}, {});
|
|
703
|
+
const cacheKeyBase = {
|
|
704
|
+
Advantage: null,
|
|
705
|
+
Disadvantage: null,
|
|
706
|
+
AdvancedCombatSpecialAbility: null,
|
|
707
|
+
AdvancedKarmaSpecialAbility: null,
|
|
708
|
+
AdvancedMagicalSpecialAbility: null,
|
|
709
|
+
AdvancedSkillSpecialAbility: null,
|
|
710
|
+
AncestorGlyph: null,
|
|
711
|
+
ArcaneOrbEnchantment: null,
|
|
712
|
+
AttireEnchantment: null,
|
|
713
|
+
Beutelzauber: null,
|
|
714
|
+
BlessedTradition: null,
|
|
715
|
+
BowlEnchantment: null,
|
|
716
|
+
BrawlingSpecialAbility: null,
|
|
717
|
+
CauldronEnchantment: null,
|
|
718
|
+
CeremonialItemSpecialAbility: null,
|
|
719
|
+
ChronicleEnchantment: null,
|
|
720
|
+
CombatSpecialAbility: null,
|
|
721
|
+
CombatStyleSpecialAbility: null,
|
|
722
|
+
CommandSpecialAbility: null,
|
|
723
|
+
DaggerRitual: null,
|
|
724
|
+
FamiliarSpecialAbility: null,
|
|
725
|
+
FatePointSexSpecialAbility: null,
|
|
726
|
+
FatePointSpecialAbility: null,
|
|
727
|
+
FoolsHatEnchantment: null,
|
|
728
|
+
GeneralSpecialAbility: null,
|
|
729
|
+
Haubenzauber: null,
|
|
730
|
+
InstrumentEnchantment: null,
|
|
731
|
+
KarmaSpecialAbility: null,
|
|
732
|
+
Krallenkettenzauber: null,
|
|
733
|
+
Kristallkugelzauber: null,
|
|
734
|
+
LiturgicalStyleSpecialAbility: null,
|
|
735
|
+
LycantropicGift: null,
|
|
736
|
+
MagicalSign: null,
|
|
737
|
+
MagicalSpecialAbility: null,
|
|
738
|
+
MagicalTradition: null,
|
|
739
|
+
MagicStyleSpecialAbility: null,
|
|
740
|
+
OrbEnchantment: null,
|
|
741
|
+
PactGift: null,
|
|
742
|
+
ProtectiveWardingCircleSpecialAbility: null,
|
|
743
|
+
RingEnchantment: null,
|
|
744
|
+
Sermon: null,
|
|
745
|
+
SexSpecialAbility: null,
|
|
746
|
+
SickleRitual: null,
|
|
747
|
+
SikaryanDrainSpecialAbility: null,
|
|
748
|
+
SkillStyleSpecialAbility: null,
|
|
749
|
+
SpellSwordEnchantment: null,
|
|
750
|
+
StaffEnchantment: null,
|
|
751
|
+
ToyEnchantment: null,
|
|
752
|
+
Trinkhornzauber: null,
|
|
753
|
+
VampiricGift: null,
|
|
754
|
+
Vision: null,
|
|
755
|
+
WandEnchantment: null,
|
|
756
|
+
WeaponEnchantment: null,
|
|
757
|
+
};
|
|
758
|
+
export const activatableSelectOptionsCacheBuilder = (database, idMap) => Object.fromEntries(Object.keys(cacheKeyBase).map((entity) => [
|
|
759
|
+
entity,
|
|
760
|
+
getSelectOptionsForResults(database, idMap, entity, database.getAllInstanceContainersOfEntity(entity)),
|
|
761
|
+
]));
|