Updating mechanics for OS protocols
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { gearSlots, scaled, type LoadoutDraft } from '$lib/builder/loadout';
|
||||
import {
|
||||
gearSlots,
|
||||
scaled,
|
||||
type LoadoutDraft,
|
||||
type TalentTier,
|
||||
} from '$lib/builder/loadout';
|
||||
|
||||
export type LoadoutCatalog = {
|
||||
attributes: any[];
|
||||
@@ -100,18 +105,21 @@ function unitValue(catalog: LoadoutCatalog, value: unknown, statId: string) {
|
||||
return unit === 'Shots' ? `${rendered} ${unit}` : `${rendered}${unit}`;
|
||||
}
|
||||
|
||||
function talentTier(catalog: LoadoutCatalog, talentId: string, tier: number) {
|
||||
function talentTier(
|
||||
catalog: LoadoutCatalog,
|
||||
talentId: string,
|
||||
tier: TalentTier,
|
||||
) {
|
||||
const item = catalog.talents.find((entry) => entry.id === talentId);
|
||||
return (
|
||||
item?.tiers.find((entry: any) => entry.tier === (tier >= 2 ? 'II' : 'I')) ??
|
||||
item?.tiers[0]
|
||||
return item?.tiers.find(
|
||||
(entry: any) => entry.tier === (tier === 2 ? 'II' : 'I'),
|
||||
);
|
||||
}
|
||||
|
||||
function talentDescription(
|
||||
catalog: LoadoutCatalog,
|
||||
talentId: string,
|
||||
tier: number,
|
||||
tier: TalentTier,
|
||||
) {
|
||||
const item = catalog.talents.find((entry) => entry.id === talentId);
|
||||
const configured = talentTier(catalog, talentId, tier);
|
||||
@@ -255,12 +263,14 @@ export function summarizeLoadout(
|
||||
rule:
|
||||
catalog.talents.find((entry) => entry.id === selection.talentId)
|
||||
?.rule ?? null,
|
||||
tier: Number(item.tier),
|
||||
tier: selection.talentTier,
|
||||
tierLabel: selection.talentTier === 2 ? 'TIER II' : 'TIER I',
|
||||
isExotic: false,
|
||||
source: slot,
|
||||
description: talentDescription(
|
||||
catalog,
|
||||
selection.talentId,
|
||||
Number(item.tier),
|
||||
selection.talentTier,
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -305,19 +315,39 @@ export function summarizeLoadout(
|
||||
roll.value,
|
||||
`${index ? 'Secondary' : 'Primary'} weapon roll`,
|
||||
);
|
||||
for (const talentId of [
|
||||
selection.talent1Id,
|
||||
selection.talent2Id,
|
||||
item.exotic_talent_id,
|
||||
].filter(Boolean)) {
|
||||
const equippedWeaponTalents = [
|
||||
{
|
||||
id: selection.talent1Id,
|
||||
tier: selection.talent1Tier,
|
||||
isExotic: false,
|
||||
},
|
||||
{
|
||||
id: selection.talent2Id,
|
||||
tier: selection.talent2Tier,
|
||||
isExotic: false,
|
||||
},
|
||||
{
|
||||
id: item.exotic_talent_id,
|
||||
tier: selection.exoticTalentTier,
|
||||
isExotic: true,
|
||||
},
|
||||
].filter((entry) => entry.id);
|
||||
for (const equippedTalent of equippedWeaponTalents) {
|
||||
equippedTalents.push({
|
||||
key: `weapon:${index}:${talentId}`,
|
||||
id: talentId,
|
||||
key: `weapon:${index}:${equippedTalent.id}`,
|
||||
id: equippedTalent.id,
|
||||
rule:
|
||||
catalog.talents.find((entry) => entry.id === talentId)?.rule ?? null,
|
||||
tier: selection.tier,
|
||||
catalog.talents.find((entry) => entry.id === equippedTalent.id)
|
||||
?.rule ?? null,
|
||||
tier: equippedTalent.tier,
|
||||
tierLabel: equippedTalent.tier === 2 ? 'TIER II' : 'TIER I',
|
||||
isExotic: equippedTalent.isExotic,
|
||||
source: index ? 'Secondary weapon' : 'Primary weapon',
|
||||
description: talentDescription(catalog, talentId, selection.tier),
|
||||
description: talentDescription(
|
||||
catalog,
|
||||
equippedTalent.id,
|
||||
equippedTalent.tier,
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user