'use client' import { useState } from 'react' import { ArmoryModel3D } from './ArmoryModel3D' import { WowheadRefresh } from './WowheadRefresh' import { slotLabel, PAPERDOLL_LEFT, PAPERDOLL_RIGHT, PAPERDOLL_WEAPONS } from '@/lib/wow-data' import { wowheadUrl, wowheadData, wowheadIcon } from '@/lib/wowhead' export type SheetItem = { slot: number entry: number name: string quality: number itemLevel: number inventoryType: number displayId: number | null transmogDisplayId: number | null ench: number gems: number[] icon: string | null } /** * Paperdoll interactivo de la ficha: iconos de equipo alrededor del modelo 3D, con * conmutador modelo/lista y toggles MH/OH para mostrar u ocultar las armas en el * modelo. Cliente porque maneja estado; los datos llegan ya resueltos del servidor. */ export function ArmoryPaperdoll({ race, gender, customizations, items, health, power, powerLabel, powerColor, locale, labels, }: { race: number gender: number customizations: { optionId: number; choiceId: number }[] items: SheetItem[] health: number power: number powerLabel: string powerColor: string locale: string labels: { loading: string; unavailable: string; health: string; itemLevel: string; model: string; list: string } }) { const [view, setView] = useState<'model' | 'list'>('model') const [mh, setMh] = useState(true) const [oh, setOh] = useState(true) const bySlot = new Map(items.map((i) => [i.slot, i])) const HIDDEN = new Set([1, 10, 11, 12, 13]) const viewerSlot = (s: number, inv: number): number => { if (s === 15) return 21 if (s === 16) return inv === 23 ? 23 : 22 if (s === 17) return inv === 15 || inv === 26 ? inv : 0 return inv } const modelEquip = items .filter((e) => !HIDDEN.has(e.slot)) .filter((e) => (e.slot === 15 ? mh : e.slot === 16 ? oh : true)) .map((e) => ({ slot: viewerSlot(e.slot, e.inventoryType), display: e.transmogDisplayId ?? e.displayId ?? 0 })) .filter((e) => e.slot > 0 && e.display > 0) const Tile = ({ slot }: { slot: number }) => { const it = bySlot.get(slot) const label = slotLabel(slot, locale) if (!it) return
return ( {it.icon ? ( ) : null} ) } const ListRow = ({ item }: { item: SheetItem }) => ( {item.icon ? ( ) : null} {item.name} {slotLabel(item.slot, locale)} {item.itemLevel ? {item.itemLevel} : null} ) return (
{view === 'model' ? (
{PAPERDOLL_LEFT.map((s) => ( ))}
{PAPERDOLL_WEAPONS.map((s) => ( ))}
{labels.health}: {health.toLocaleString(locale)} {powerLabel}: {power.toLocaleString(locale)}
{PAPERDOLL_RIGHT.map((s) => ( ))}
) : (
{[...PAPERDOLL_LEFT, ...PAPERDOLL_RIGHT, ...PAPERDOLL_WEAPONS] .map((s) => bySlot.get(s)) .filter((it): it is SheetItem => !!it) .map((it) => ( ))}
)}
) }