From df52b31f5ddd37afd4799777c54dbe90bc075b48 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 31 Dec 2025 00:16:52 -0800 Subject: [PATCH] update weapon edit views for new ax skill types - use AugmentSkill instead of SimpleAxSkill - send modifier IDs on save instead of numeric indices --- .../collection/CollectionWeaponPane.svelte | 10 +++--- .../collection/WeaponEditPane.svelte | 36 +++++++------------ .../sidebar/EditWeaponSidebar.svelte | 34 +++++++----------- src/lib/utils/modificationFormatters.ts | 22 +++--------- src/lib/utils/modifiers.ts | 16 +++++---- 5 files changed, 43 insertions(+), 75 deletions(-) diff --git a/src/lib/components/collection/CollectionWeaponPane.svelte b/src/lib/components/collection/CollectionWeaponPane.svelte index 3ce6f37c..b71bf30c 100644 --- a/src/lib/components/collection/CollectionWeaponPane.svelte +++ b/src/lib/components/collection/CollectionWeaponPane.svelte @@ -10,7 +10,7 @@ */ import { onMount } from 'svelte' import type { CollectionWeapon } from '$lib/types/api/collection' - import type { SimpleAxSkill } from '$lib/types/api/entities' + import type { AugmentSkill } from '$lib/types/api/weaponStatModifier' import { useUpdateCollectionWeapon, useRemoveWeaponFromCollection @@ -89,7 +89,7 @@ level: weapon.awakening.level } : null, - axSkills: (weapon.ax as SimpleAxSkill[]) ?? [] + axSkills: (weapon.ax as AugmentSkill[]) ?? [] }) // Element name for theming @@ -247,7 +247,7 @@ // Check conditions const hasAwakening = $derived(weapon.awakening !== null) const hasWeaponKeys = $derived((weapon.weaponKeys?.length ?? 0) > 0) - const hasAxSkills = $derived((weapon.ax?.length ?? 0) > 0 && weapon.ax?.some(ax => ax.modifier >= 0)) + const hasAxSkills = $derived((weapon.ax?.length ?? 0) > 0 && weapon.ax?.some(ax => ax.modifier?.id)) const canChangeElement = $derived(weaponData?.element === 0) // Set up sidebar action on mount and clean up on destroy @@ -334,8 +334,8 @@ {#each weapon.ax ?? [] as ax, i} - {#if ax.modifier >= 0} - + {#if ax.modifier?.id} + {/if} {/each} diff --git a/src/lib/components/collection/WeaponEditPane.svelte b/src/lib/components/collection/WeaponEditPane.svelte index b647e295..3a20ee4f 100644 --- a/src/lib/components/collection/WeaponEditPane.svelte +++ b/src/lib/components/collection/WeaponEditPane.svelte @@ -10,7 +10,8 @@ * - AX skills (for weapons with AX support) * - Awakening (for weapons with awakening support) */ - import type { Weapon, Awakening, SimpleAxSkill } from '$lib/types/api/entities' + import type { Weapon, Awakening } from '$lib/types/api/entities' + import type { AugmentSkill } from '$lib/types/api/weaponStatModifier' import DetailsSection from '$lib/components/sidebar/details/DetailsSection.svelte' import Select from '$lib/components/ui/Select.svelte' import WeaponKeySelect from '$lib/components/sidebar/edit/WeaponKeySelect.svelte' @@ -31,7 +32,7 @@ type?: Awakening level: number } | null - axSkills: SimpleAxSkill[] + axSkills: AugmentSkill[] } export interface WeaponEditUpdates { @@ -46,9 +47,9 @@ id: string level: number } | null - axModifier1?: number + axModifier1Id?: string axStrength1?: number - axModifier2?: number + axModifier2Id?: string axStrength2?: number } @@ -72,14 +73,7 @@ let weaponKey3 = $state(currentValues.weaponKey3Id) let selectedAwakening = $state(currentValues.awakening?.type) let awakeningLevel = $state(currentValues.awakening?.level ?? 1) - let axSkills = $state( - currentValues.axSkills.length > 0 - ? currentValues.axSkills - : [ - { modifier: -1, strength: 0 }, - { modifier: -1, strength: 0 } - ] - ) + let axSkills = $state(currentValues.axSkills ?? []) // Re-initialize when currentValues changes $effect(() => { @@ -91,13 +85,7 @@ weaponKey3 = currentValues.weaponKey3Id selectedAwakening = currentValues.awakening?.type awakeningLevel = currentValues.awakening?.level ?? 1 - axSkills = - currentValues.axSkills.length > 0 - ? currentValues.axSkills - : [ - { modifier: -1, strength: 0 }, - { modifier: -1, strength: 0 } - ] + axSkills = currentValues.axSkills ?? [] }) // Derived conditions @@ -196,13 +184,13 @@ } // AX Skills - if (hasAxSkills && axSkills.length >= 2) { - if (axSkills[0] && axSkills[0].modifier >= 0) { - updates.axModifier1 = axSkills[0].modifier + if (hasAxSkills) { + if (axSkills[0]?.modifier?.id) { + updates.axModifier1Id = axSkills[0].modifier.id updates.axStrength1 = axSkills[0].strength } - if (axSkills[1] && axSkills[1].modifier >= 0) { - updates.axModifier2 = axSkills[1].modifier + if (axSkills[1]?.modifier?.id) { + updates.axModifier2Id = axSkills[1].modifier.id updates.axStrength2 = axSkills[1].strength } } diff --git a/src/lib/components/sidebar/EditWeaponSidebar.svelte b/src/lib/components/sidebar/EditWeaponSidebar.svelte index 437afaff..2ed840a8 100644 --- a/src/lib/components/sidebar/EditWeaponSidebar.svelte +++ b/src/lib/components/sidebar/EditWeaponSidebar.svelte @@ -1,7 +1,8 @@ diff --git a/src/lib/utils/modificationFormatters.ts b/src/lib/utils/modificationFormatters.ts index 22194a26..a3d27109 100644 --- a/src/lib/utils/modificationFormatters.ts +++ b/src/lib/utils/modificationFormatters.ts @@ -1,21 +1,7 @@ -import type { SimpleAxSkill } from '$lib/types/api/entities' +import type { AugmentSkill } from '$lib/types/api/weaponStatModifier' import { getRingStat, getEarringStat, getElementalizedEarringStat } from './masteryUtils' import { isWeaponSeriesRef, type WeaponSeriesRef } from '$lib/types/api/weaponSeries' -const AX_SKILL_NAMES: Record = { - 1: 'Attack', - 2: 'HP', - 3: 'Double Attack', - 4: 'Triple Attack', - 5: 'C.A. DMG', - 6: 'C.A. DMG Cap', - 7: 'Skill DMG', - 8: 'Skill DMG Cap', - 9: 'Stamina', - 10: 'Enmity', - 11: 'Critical Hit' -} - export function formatRingStat( modifier: number, strength: number, @@ -46,9 +32,9 @@ export function formatEarringStat( return `${statName} +${strength}${stat.suffix}` } -export function formatAxSkill(ax: SimpleAxSkill): string { - const skillName = AX_SKILL_NAMES[ax.modifier] || `Unknown (${ax.modifier})` - const suffix = ax.modifier <= 2 ? '' : '%' +export function formatAxSkill(ax: AugmentSkill, locale: 'en' | 'ja' = 'en'): string { + const skillName = locale === 'ja' ? ax.modifier.nameJp : ax.modifier.nameEn + const suffix = ax.modifier.suffix ?? '' return `${skillName} +${ax.strength}${suffix}` } diff --git a/src/lib/utils/modifiers.ts b/src/lib/utils/modifiers.ts index 65a8ec61..38ebf847 100644 --- a/src/lib/utils/modifiers.ts +++ b/src/lib/utils/modifiers.ts @@ -3,7 +3,7 @@ */ import type { Awakening, WeaponKey } from '$lib/types/api/entities' -import type { SimpleAxSkill } from '$lib/types/SimpleAxSkill' +import type { AugmentSkill } from '$lib/types/api/weaponStatModifier' import { isWeaponSeriesRef, type WeaponSeriesRef } from '$lib/types/api/weaponSeries' import { getBasePath } from '$lib/utils/images' @@ -120,10 +120,14 @@ export function getAxSkillImage(axSkill?: { slug?: string }): string | null { /** * Get all AX skill images for a weapon - * Note: This is a placeholder until ax data structure is fully implemented */ -export function getAxSkillImages(ax?: SimpleAxSkill[]): Array<{ url: string; alt: string }> { - // TODO: Implement when ax data reference is available - // This would need to map ax modifiers to actual ax skill data - return [] +export function getAxSkillImages(ax?: AugmentSkill[]): Array<{ url: string; alt: string }> { + if (!ax || ax.length === 0) return [] + + return ax + .filter((skill) => skill.modifier?.slug) + .map((skill) => ({ + url: `${getBasePath()}/ax/${skill.modifier.slug}.png`, + alt: skill.modifier.nameEn || skill.modifier.slug || 'AX Skill' + })) } \ No newline at end of file