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 { onMount } from 'svelte'
|
||||||
import type { CollectionWeapon } from '$lib/types/api/collection'
|
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 {
|
import {
|
||||||
useUpdateCollectionWeapon,
|
useUpdateCollectionWeapon,
|
||||||
useRemoveWeaponFromCollection
|
useRemoveWeaponFromCollection
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
level: weapon.awakening.level
|
level: weapon.awakening.level
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
axSkills: (weapon.ax as SimpleAxSkill[]) ?? []
|
axSkills: (weapon.ax as AugmentSkill[]) ?? []
|
||||||
})
|
})
|
||||||
|
|
||||||
// Element name for theming
|
// Element name for theming
|
||||||
|
|
@ -247,7 +247,7 @@
|
||||||
// Check conditions
|
// Check conditions
|
||||||
const hasAwakening = $derived(weapon.awakening !== null)
|
const hasAwakening = $derived(weapon.awakening !== null)
|
||||||
const hasWeaponKeys = $derived((weapon.weaponKeys?.length ?? 0) > 0)
|
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)
|
const canChangeElement = $derived(weaponData?.element === 0)
|
||||||
|
|
||||||
// Set up sidebar action on mount and clean up on destroy
|
// Set up sidebar action on mount and clean up on destroy
|
||||||
|
|
@ -334,8 +334,8 @@
|
||||||
|
|
||||||
<DetailsSection title="AX Skills" empty={!hasAxSkills} emptyMessage="Not set">
|
<DetailsSection title="AX Skills" empty={!hasAxSkills} emptyMessage="Not set">
|
||||||
{#each weapon.ax ?? [] as ax, i}
|
{#each weapon.ax ?? [] as ax, i}
|
||||||
{#if ax.modifier >= 0}
|
{#if ax.modifier?.id}
|
||||||
<DetailRow label="Skill {i + 1}" value={`${ax.modifier}: ${ax.strength}`} />
|
<DetailRow label="Skill {i + 1}" value={`${ax.modifier.nameEn} +${ax.strength}${ax.modifier.suffix ?? ''}`} />
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</DetailsSection>
|
</DetailsSection>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
* - AX skills (for weapons with AX support)
|
* - AX skills (for weapons with AX support)
|
||||||
* - Awakening (for weapons with awakening 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 DetailsSection from '$lib/components/sidebar/details/DetailsSection.svelte'
|
||||||
import Select from '$lib/components/ui/Select.svelte'
|
import Select from '$lib/components/ui/Select.svelte'
|
||||||
import WeaponKeySelect from '$lib/components/sidebar/edit/WeaponKeySelect.svelte'
|
import WeaponKeySelect from '$lib/components/sidebar/edit/WeaponKeySelect.svelte'
|
||||||
|
|
@ -31,7 +32,7 @@
|
||||||
type?: Awakening
|
type?: Awakening
|
||||||
level: number
|
level: number
|
||||||
} | null
|
} | null
|
||||||
axSkills: SimpleAxSkill[]
|
axSkills: AugmentSkill[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WeaponEditUpdates {
|
export interface WeaponEditUpdates {
|
||||||
|
|
@ -46,9 +47,9 @@
|
||||||
id: string
|
id: string
|
||||||
level: number
|
level: number
|
||||||
} | null
|
} | null
|
||||||
axModifier1?: number
|
axModifier1Id?: string
|
||||||
axStrength1?: number
|
axStrength1?: number
|
||||||
axModifier2?: number
|
axModifier2Id?: string
|
||||||
axStrength2?: number
|
axStrength2?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,14 +73,7 @@
|
||||||
let weaponKey3 = $state<string | undefined>(currentValues.weaponKey3Id)
|
let weaponKey3 = $state<string | undefined>(currentValues.weaponKey3Id)
|
||||||
let selectedAwakening = $state<Awakening | undefined>(currentValues.awakening?.type)
|
let selectedAwakening = $state<Awakening | undefined>(currentValues.awakening?.type)
|
||||||
let awakeningLevel = $state(currentValues.awakening?.level ?? 1)
|
let awakeningLevel = $state(currentValues.awakening?.level ?? 1)
|
||||||
let axSkills = $state<SimpleAxSkill[]>(
|
let axSkills = $state<AugmentSkill[]>(currentValues.axSkills ?? [])
|
||||||
currentValues.axSkills.length > 0
|
|
||||||
? currentValues.axSkills
|
|
||||||
: [
|
|
||||||
{ modifier: -1, strength: 0 },
|
|
||||||
{ modifier: -1, strength: 0 }
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
// Re-initialize when currentValues changes
|
// Re-initialize when currentValues changes
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
|
@ -91,13 +85,7 @@
|
||||||
weaponKey3 = currentValues.weaponKey3Id
|
weaponKey3 = currentValues.weaponKey3Id
|
||||||
selectedAwakening = currentValues.awakening?.type
|
selectedAwakening = currentValues.awakening?.type
|
||||||
awakeningLevel = currentValues.awakening?.level ?? 1
|
awakeningLevel = currentValues.awakening?.level ?? 1
|
||||||
axSkills =
|
axSkills = currentValues.axSkills ?? []
|
||||||
currentValues.axSkills.length > 0
|
|
||||||
? currentValues.axSkills
|
|
||||||
: [
|
|
||||||
{ modifier: -1, strength: 0 },
|
|
||||||
{ modifier: -1, strength: 0 }
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Derived conditions
|
// Derived conditions
|
||||||
|
|
@ -196,13 +184,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// AX Skills
|
// AX Skills
|
||||||
if (hasAxSkills && axSkills.length >= 2) {
|
if (hasAxSkills) {
|
||||||
if (axSkills[0] && axSkills[0].modifier >= 0) {
|
if (axSkills[0]?.modifier?.id) {
|
||||||
updates.axModifier1 = axSkills[0].modifier
|
updates.axModifier1Id = axSkills[0].modifier.id
|
||||||
updates.axStrength1 = axSkills[0].strength
|
updates.axStrength1 = axSkills[0].strength
|
||||||
}
|
}
|
||||||
if (axSkills[1] && axSkills[1].modifier >= 0) {
|
if (axSkills[1]?.modifier?.id) {
|
||||||
updates.axModifier2 = axSkills[1].modifier
|
updates.axModifier2Id = axSkills[1].modifier.id
|
||||||
updates.axStrength2 = axSkills[1].strength
|
updates.axStrength2 = axSkills[1].strength
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GridWeapon } from '$lib/types/api/party'
|
import type { GridWeapon } from '$lib/types/api/party'
|
||||||
import type { WeaponKey } from '$lib/api/adapters/entity.adapter'
|
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 DetailsSection from './details/DetailsSection.svelte'
|
||||||
import ItemHeader from './details/ItemHeader.svelte'
|
import ItemHeader from './details/ItemHeader.svelte'
|
||||||
import Select from '$lib/components/ui/Select.svelte'
|
import Select from '$lib/components/ui/Select.svelte'
|
||||||
|
|
@ -52,12 +53,7 @@
|
||||||
let awakeningLevel = $state(weapon.awakening?.level ?? 1)
|
let awakeningLevel = $state(weapon.awakening?.level ?? 1)
|
||||||
|
|
||||||
// AX skill state - initialize from existing AX skills
|
// AX skill state - initialize from existing AX skills
|
||||||
let axSkills = $state<SimpleAxSkill[]>(
|
let axSkills = $state<AugmentSkill[]>(weapon.ax ?? [])
|
||||||
weapon.ax ?? [
|
|
||||||
{ modifier: -1, strength: 0 },
|
|
||||||
{ modifier: -1, strength: 0 }
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
// Weapon data shortcuts
|
// Weapon data shortcuts
|
||||||
const weaponData = $derived(weapon.weapon)
|
const weaponData = $derived(weapon.weapon)
|
||||||
|
|
@ -125,9 +121,9 @@
|
||||||
weaponKey3Id?: string | null
|
weaponKey3Id?: string | null
|
||||||
awakeningId?: string | null
|
awakeningId?: string | null
|
||||||
awakeningLevel?: number
|
awakeningLevel?: number
|
||||||
axModifier1?: number | null
|
axModifier1Id?: string | null
|
||||||
axStrength1?: number | null
|
axStrength1?: number | null
|
||||||
axModifier2?: number | null
|
axModifier2Id?: string | null
|
||||||
axStrength2?: number | null
|
axStrength2?: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,26 +165,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AX skills - send modifier/strength pairs
|
// AX skills - send modifier IDs and strength values
|
||||||
if (hasAxSkills) {
|
if (hasAxSkills) {
|
||||||
const originalAx = weapon.ax ?? [
|
const originalAx = weapon.ax ?? []
|
||||||
{ modifier: -1, strength: 0 },
|
|
||||||
{ modifier: -1, strength: 0 }
|
|
||||||
]
|
|
||||||
|
|
||||||
const ax1 = axSkills[0]
|
const ax1 = axSkills[0]
|
||||||
const ax2 = axSkills[1]
|
const ax2 = axSkills[1]
|
||||||
const origAx1 = originalAx[0]
|
const origAx1 = originalAx[0]
|
||||||
const origAx2 = originalAx[1]
|
const origAx2 = originalAx[1]
|
||||||
|
|
||||||
if (ax1?.modifier !== origAx1?.modifier) {
|
if (ax1?.modifier?.id !== origAx1?.modifier?.id) {
|
||||||
updates.axModifier1 = ax1?.modifier ?? null
|
updates.axModifier1Id = ax1?.modifier?.id ?? null
|
||||||
}
|
}
|
||||||
if (ax1?.strength !== origAx1?.strength) {
|
if (ax1?.strength !== origAx1?.strength) {
|
||||||
updates.axStrength1 = ax1?.strength ?? null
|
updates.axStrength1 = ax1?.strength ?? null
|
||||||
}
|
}
|
||||||
if (ax2?.modifier !== origAx2?.modifier) {
|
if (ax2?.modifier?.id !== origAx2?.modifier?.id) {
|
||||||
updates.axModifier2 = ax2?.modifier ?? null
|
updates.axModifier2Id = ax2?.modifier?.id ?? null
|
||||||
}
|
}
|
||||||
if (ax2?.strength !== origAx2?.strength) {
|
if (ax2?.strength !== origAx2?.strength) {
|
||||||
updates.axStrength2 = ax2?.strength ?? null
|
updates.axStrength2 = ax2?.strength ?? null
|
||||||
|
|
@ -212,10 +205,7 @@
|
||||||
weaponKey3 = weapon.weaponKeys?.[2]?.id
|
weaponKey3 = weapon.weaponKeys?.[2]?.id
|
||||||
selectedAwakening = weapon.awakening?.type
|
selectedAwakening = weapon.awakening?.type
|
||||||
awakeningLevel = weapon.awakening?.level ?? 1
|
awakeningLevel = weapon.awakening?.level ?? 1
|
||||||
axSkills = weapon.ax ?? [
|
axSkills = weapon.ax ?? []
|
||||||
{ modifier: -1, strength: 0 },
|
|
||||||
{ modifier: -1, strength: 0 }
|
|
||||||
]
|
|
||||||
onCancel?.()
|
onCancel?.()
|
||||||
}
|
}
|
||||||
</script>
|
</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 { getRingStat, getEarringStat, getElementalizedEarringStat } from './masteryUtils'
|
||||||
import { isWeaponSeriesRef, type WeaponSeriesRef } from '$lib/types/api/weaponSeries'
|
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(
|
export function formatRingStat(
|
||||||
modifier: number,
|
modifier: number,
|
||||||
strength: number,
|
strength: number,
|
||||||
|
|
@ -46,9 +32,9 @@ export function formatEarringStat(
|
||||||
return `${statName} +${strength}${stat.suffix}`
|
return `${statName} +${strength}${stat.suffix}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatAxSkill(ax: SimpleAxSkill): string {
|
export function formatAxSkill(ax: AugmentSkill, locale: 'en' | 'ja' = 'en'): string {
|
||||||
const skillName = AX_SKILL_NAMES[ax.modifier] || `Unknown (${ax.modifier})`
|
const skillName = locale === 'ja' ? ax.modifier.nameJp : ax.modifier.nameEn
|
||||||
const suffix = ax.modifier <= 2 ? '' : '%'
|
const suffix = ax.modifier.suffix ?? ''
|
||||||
return `${skillName} +${ax.strength}${suffix}`
|
return `${skillName} +${ax.strength}${suffix}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Awakening, WeaponKey } from '$lib/types/api/entities'
|
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 { isWeaponSeriesRef, type WeaponSeriesRef } from '$lib/types/api/weaponSeries'
|
||||||
import { getBasePath } from '$lib/utils/images'
|
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
|
* 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 }> {
|
export function getAxSkillImages(ax?: AugmentSkill[]): Array<{ url: string; alt: string }> {
|
||||||
// TODO: Implement when ax data reference is available
|
if (!ax || ax.length === 0) return []
|
||||||
// This would need to map ax modifiers to actual ax skill data
|
|
||||||
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