feat: consume selected mechanic revisions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Database } from '@tursodatabase/database';
|
||||
import { attachWeaponCategoryBonuses } from '$lib/weapons/category-bonuses';
|
||||
import { hydrateSkillChipProfileRows } from '$lib/skill-chips/profiles';
|
||||
import { loadBuildMechanicRuntimes } from './build-mechanic-runtime';
|
||||
|
||||
export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
const [
|
||||
@@ -37,6 +38,7 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
specializationNodes,
|
||||
specializationRanks,
|
||||
specializationRankEffects,
|
||||
specializationRankCombatEffects,
|
||||
] = await Promise.all([
|
||||
(
|
||||
await database.prepare(
|
||||
@@ -172,9 +174,35 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
'SELECT * FROM specialization_tree_rank_effects ORDER BY node_id,rank,effect_order',
|
||||
)
|
||||
).all(),
|
||||
(
|
||||
await database.prepare(`SELECT attachment.*,effect.name AS definition_name
|
||||
FROM specialization_tree_rank_combat_effects attachment
|
||||
JOIN specialization_tree_node_ranks rank
|
||||
ON rank.node_id=attachment.node_id AND rank.rank=attachment.rank
|
||||
JOIN specialization_tree_nodes node ON node.id=attachment.node_id AND node.active=1
|
||||
JOIN specialization_focuses focus ON focus.id=node.focus_id AND focus.active=1
|
||||
JOIN specializations specialization
|
||||
ON specialization.id=focus.specialization_id AND specialization.active=1
|
||||
JOIN specialization_combat_effects effect
|
||||
ON effect.id=attachment.combat_effect_id
|
||||
AND effect.specialization_id=focus.specialization_id
|
||||
AND effect.active=1
|
||||
ORDER BY specialization.id,focus.display_order,focus.name COLLATE NOCASE,
|
||||
node.row_number,node.column_number,attachment.rank,
|
||||
attachment.effect_order,attachment.id`)
|
||||
).all(),
|
||||
]);
|
||||
const mechanics = await loadBuildMechanicRuntimes(database, {
|
||||
talentIds: talents.map((talent) => String(talent.id)),
|
||||
protocolTalentIds: protocolTalents.map((talent) => String(talent.id)),
|
||||
skillChipTalentIds: chipTalents.map((talent) => String(talent.id)),
|
||||
specializationAttachmentIds: specializationRankCombatEffects.map((effect) =>
|
||||
String(effect.id),
|
||||
),
|
||||
});
|
||||
|
||||
return {
|
||||
mechanics,
|
||||
attributes,
|
||||
gear,
|
||||
gearAugments,
|
||||
@@ -187,6 +215,7 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
weapons: attachWeaponCategoryBonuses(weapons, weaponBonuses),
|
||||
talents: talents.map((talent) => ({
|
||||
...talent,
|
||||
runtime: mechanics.talents[String(talent.id)] ?? null,
|
||||
template:
|
||||
talentTemplates.find((item) => item.talent_id === talent.id)
|
||||
?.template ?? '',
|
||||
@@ -231,6 +260,7 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
talent: talent
|
||||
? {
|
||||
...talent,
|
||||
runtime: mechanics.skillChipTalents[String(talent.id)] ?? null,
|
||||
effects: chipTalentEffects.filter(
|
||||
(effect) => effect.talent_id === talent.id,
|
||||
),
|
||||
@@ -260,6 +290,7 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
talent: talent
|
||||
? {
|
||||
...talent,
|
||||
runtime: mechanics.protocolTalents[String(talent.id)] ?? null,
|
||||
effects: protocolTalentEffects.filter(
|
||||
(effect) => effect.talent_id === talent.id,
|
||||
),
|
||||
@@ -298,6 +329,23 @@ export async function loadSharedBuildSummaryCatalog(database: Database) {
|
||||
effect.node_id === node.id &&
|
||||
Number(effect.rank) === Number(rank.rank),
|
||||
),
|
||||
combatEffects: specializationRankCombatEffects
|
||||
.filter(
|
||||
(effect) =>
|
||||
effect.node_id === node.id &&
|
||||
Number(effect.rank) === Number(rank.rank),
|
||||
)
|
||||
.map((effect) => ({
|
||||
...effect,
|
||||
definition: {
|
||||
id: String(effect.combat_effect_id),
|
||||
name: String(effect.definition_name),
|
||||
},
|
||||
runtime:
|
||||
mechanics.specializationAttachments[
|
||||
String(effect.id)
|
||||
] ?? null,
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user