update weapon edit views for new ax skill types
- use AugmentSkill instead of SimpleAxSkill - send modifier IDs on save instead of numeric indices
This commit is contained in:
parent
1d8a22c725
commit
df52b31f5d
5 changed files with 43 additions and 75 deletions
|
|
@ -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 @@
|
|||
|
||||
<DetailsSection title="AX Skills" empty={!hasAxSkills} emptyMessage="Not set">
|
||||
{#each weapon.ax ?? [] as ax, i}
|
||||
{#if ax.modifier >= 0}
|
||||
<DetailRow label="Skill {i + 1}" value={`${ax.modifier}: ${ax.strength}`} />
|
||||
{#if ax.modifier?.id}
|
||||
<DetailRow label="Skill {i + 1}" value={`${ax.modifier.nameEn} +${ax.strength}${ax.modifier.suffix ?? ''}`} />
|
||||
{/if}
|
||||
{/each}
|
||||
</DetailsSection>
|
||||
|
|
|
|||
|
|
@ -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<string | undefined>(currentValues.weaponKey3Id)
|
||||
let selectedAwakening = $state<Awakening | undefined>(currentValues.awakening?.type)
|
||||
let awakeningLevel = $state(currentValues.awakening?.level ?? 1)
|
||||
let axSkills = $state<SimpleAxSkill[]>(
|
||||
currentValues.axSkills.length > 0
|
||||
? currentValues.axSkills
|
||||
: [
|
||||
{ modifier: -1, strength: 0 },
|
||||
{ modifier: -1, strength: 0 }
|
||||
]
|
||||
)
|
||||
let axSkills = $state<AugmentSkill[]>(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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<script lang="ts">
|
||||
import type { GridWeapon } from '$lib/types/api/party'
|
||||
import type { WeaponKey } from '$lib/api/adapters/entity.adapter'
|
||||
import type { Awakening, SimpleAxSkill } from '$lib/types/api/entities'
|
||||
import type { Awakening } from '$lib/types/api/entities'
|
||||
import type { AugmentSkill } from '$lib/types/api/weaponStatModifier'
|
||||
import DetailsSection from './details/DetailsSection.svelte'
|
||||
import ItemHeader from './details/ItemHeader.svelte'
|
||||
import Select from '$lib/components/ui/Select.svelte'
|
||||
|
|
@ -52,12 +53,7 @@
|
|||
let awakeningLevel = $state(weapon.awakening?.level ?? 1)
|
||||
|
||||
// AX skill state - initialize from existing AX skills
|
||||
let axSkills = $state<SimpleAxSkill[]>(
|
||||
weapon.ax ?? [
|
||||
{ modifier: -1, strength: 0 },
|
||||
{ modifier: -1, strength: 0 }
|
||||
]
|
||||
)
|
||||
let axSkills = $state<AugmentSkill[]>(weapon.ax ?? [])
|
||||
|
||||
// Weapon data shortcuts
|
||||
const weaponData = $derived(weapon.weapon)
|
||||
|
|
@ -125,9 +121,9 @@
|
|||
weaponKey3Id?: string | null
|
||||
awakeningId?: string | null
|
||||
awakeningLevel?: number
|
||||
axModifier1?: number | null
|
||||
axModifier1Id?: string | null
|
||||
axStrength1?: number | null
|
||||
axModifier2?: number | null
|
||||
axModifier2Id?: string | null
|
||||
axStrength2?: number | null
|
||||
}
|
||||
|
||||
|
|
@ -169,26 +165,23 @@
|
|||
}
|
||||
}
|
||||
|
||||
// AX skills - send modifier/strength pairs
|
||||
// AX skills - send modifier IDs and strength values
|
||||
if (hasAxSkills) {
|
||||
const originalAx = weapon.ax ?? [
|
||||
{ modifier: -1, strength: 0 },
|
||||
{ modifier: -1, strength: 0 }
|
||||
]
|
||||
const originalAx = weapon.ax ?? []
|
||||
|
||||
const ax1 = axSkills[0]
|
||||
const ax2 = axSkills[1]
|
||||
const origAx1 = originalAx[0]
|
||||
const origAx2 = originalAx[1]
|
||||
|
||||
if (ax1?.modifier !== origAx1?.modifier) {
|
||||
updates.axModifier1 = ax1?.modifier ?? null
|
||||
if (ax1?.modifier?.id !== origAx1?.modifier?.id) {
|
||||
updates.axModifier1Id = ax1?.modifier?.id ?? null
|
||||
}
|
||||
if (ax1?.strength !== origAx1?.strength) {
|
||||
updates.axStrength1 = ax1?.strength ?? null
|
||||
}
|
||||
if (ax2?.modifier !== origAx2?.modifier) {
|
||||
updates.axModifier2 = ax2?.modifier ?? null
|
||||
if (ax2?.modifier?.id !== origAx2?.modifier?.id) {
|
||||
updates.axModifier2Id = ax2?.modifier?.id ?? null
|
||||
}
|
||||
if (ax2?.strength !== origAx2?.strength) {
|
||||
updates.axStrength2 = ax2?.strength ?? null
|
||||
|
|
@ -212,10 +205,7 @@
|
|||
weaponKey3 = weapon.weaponKeys?.[2]?.id
|
||||
selectedAwakening = weapon.awakening?.type
|
||||
awakeningLevel = weapon.awakening?.level ?? 1
|
||||
axSkills = weapon.ax ?? [
|
||||
{ modifier: -1, strength: 0 },
|
||||
{ modifier: -1, strength: 0 }
|
||||
]
|
||||
axSkills = weapon.ax ?? []
|
||||
onCancel?.()
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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<number, string> = {
|
||||
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}`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
}))
|
||||
}
|
||||
Loading…
Reference in a new issue