fix skill lookup for slots 3-4 by matching skill group
This commit is contained in:
parent
3f13f16998
commit
7c93cf8aab
2 changed files with 22 additions and 12 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
calculateSkillDisplayValue,
|
calculateSkillDisplayValue,
|
||||||
|
getSkillGroupForSlot,
|
||||||
type ArtifactSkillInstance
|
type ArtifactSkillInstance
|
||||||
} from '$lib/types/api/artifact'
|
} from '$lib/types/api/artifact'
|
||||||
import { createQuery } from '@tanstack/svelte-query'
|
import { createQuery } from '@tanstack/svelte-query'
|
||||||
|
|
@ -18,19 +19,24 @@
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
skill: ArtifactSkillInstance
|
skill: ArtifactSkillInstance
|
||||||
|
/** Skill slot number (1-4) for skill group lookup */
|
||||||
|
skillSlot: number
|
||||||
/** Element for max value highlighting */
|
/** Element for max value highlighting */
|
||||||
element?: ElementType
|
element?: ElementType
|
||||||
}
|
}
|
||||||
|
|
||||||
const { skill, element }: Props = $props()
|
const { skill, skillSlot, element }: Props = $props()
|
||||||
|
|
||||||
// Query skills to get the full skill definition
|
// Query skills to get the full skill definition
|
||||||
const skillsQuery = createQuery(() => artifactQueries.skills())
|
const skillsQuery = createQuery(() => artifactQueries.skills())
|
||||||
|
|
||||||
// Find the skill definition
|
// Find the skill definition (must match both modifier and skill group)
|
||||||
const skillDef = $derived(
|
const skillDef = $derived.by(() => {
|
||||||
skillsQuery.data?.find((s) => s.modifier === skill.modifier)
|
const group = getSkillGroupForSlot(skillSlot)
|
||||||
|
return skillsQuery.data?.find(
|
||||||
|
(s) => s.modifier === skill.modifier && s.skillGroup === group
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const suffix = $derived(skillDef?.suffix?.en ?? '')
|
const suffix = $derived(skillDef?.suffix?.en ?? '')
|
||||||
const isNegative = $derived(skillDef?.polarity === 'negative')
|
const isNegative = $derived(skillDef?.polarity === 'negative')
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import type { CollectionArtifact, ArtifactSkillInstance } from '$lib/types/api/artifact'
|
import type { CollectionArtifact, ArtifactSkillInstance } from '$lib/types/api/artifact'
|
||||||
import { isQuirkArtifact } from '$lib/types/api/artifact'
|
import { isQuirkArtifact, getSkillGroupForSlot } from '$lib/types/api/artifact'
|
||||||
import { createQuery } from '@tanstack/svelte-query'
|
import { createQuery } from '@tanstack/svelte-query'
|
||||||
import { artifactQueries } from '$lib/api/queries/artifact.queries'
|
import { artifactQueries } from '$lib/api/queries/artifact.queries'
|
||||||
import { useDeleteCollectionArtifact } from '$lib/api/mutations/artifact.mutations'
|
import { useDeleteCollectionArtifact } from '$lib/api/mutations/artifact.mutations'
|
||||||
|
|
@ -59,9 +59,12 @@
|
||||||
// Query skill definitions to get names
|
// Query skill definitions to get names
|
||||||
const skillsQuery = createQuery(() => artifactQueries.skills())
|
const skillsQuery = createQuery(() => artifactQueries.skills())
|
||||||
|
|
||||||
// Get skill name by modifier
|
// Get skill name by modifier and slot (different slots use different skill groups)
|
||||||
function getSkillName(skill: ArtifactSkillInstance): string {
|
function getSkillName(skill: ArtifactSkillInstance, slot: number): string {
|
||||||
const skillDef = skillsQuery.data?.find((s) => s.modifier === skill.modifier)
|
const group = getSkillGroupForSlot(slot)
|
||||||
|
const skillDef = skillsQuery.data?.find(
|
||||||
|
(s) => s.modifier === skill.modifier && s.skillGroup === group
|
||||||
|
)
|
||||||
return skillDef?.name?.en ?? 'Unknown Skill'
|
return skillDef?.name?.en ?? 'Unknown Skill'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,10 +152,11 @@
|
||||||
|
|
||||||
{#if hasSkills}
|
{#if hasSkills}
|
||||||
<DetailsSection title="Skills">
|
<DetailsSection title="Skills">
|
||||||
{#each skills as skill}
|
{#each skills as skill, index}
|
||||||
|
{@const skillSlot = index + 1}
|
||||||
{#if skill}
|
{#if skill}
|
||||||
<DetailRow label={getSkillName(skill)}>
|
<DetailRow label={getSkillName(skill, skillSlot)}>
|
||||||
<ArtifactSkillDisplay {skill} element={elementType} />
|
<ArtifactSkillDisplay {skill} {skillSlot} element={elementType} />
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue