import type { BgMatch } from '@/lib/armory' /** Nombre + color por BattlegroundTypeId (3.4.3 WotLK). */ const BG_TYPES: Record = { 1: { es: 'Valle de Alterac', en: 'Alterac Valley', color: '#4a90d9', icon: 'fas fa-mountain' }, 2: { es: 'Garganta Grito de Guerra', en: 'Warsong Gulch', color: '#2ecc71', icon: 'fas fa-flag' }, 3: { es: 'Cuenca de Arathi', en: 'Arathi Basin', color: '#e0a13a', icon: 'fas fa-tower-observation' }, 7: { es: 'Ojo de la Tormenta', en: 'Eye of the Storm', color: '#9b59b6', icon: 'fas fa-bolt' }, 9: { es: 'Costa de los Ancestros', en: 'Strand of the Ancients', color: '#c0703a', icon: 'fas fa-ship' }, 30: { es: 'Isla de la Conquista', en: 'Isle of Conquest', color: '#5dade2', icon: 'fas fa-anchor' }, 32: { es: 'Campo de batalla aleatorio', en: 'Random Battleground', color: '#888888', icon: 'fas fa-dice' }, } export type BgLabels = { history: string desc: string matches: string wins: string losses: string winRate: string result: string win: string loss: string kb: string hk: string deaths: string damage: string healing: string honor: string date: string none: string battleground: string } export function ArmoryBattlegrounds({ locale, rows, matches, wins, losses, winRate, labels, }: { locale: string rows: BgMatch[] matches: number wins: number losses: number winRate: number labels: BgLabels }) { const fmt = (n: number) => n.toLocaleString(locale) const fmtDate = (iso: string) => { const d = new Date(iso) if (Number.isNaN(d.getTime())) return '—' const day = d.toLocaleDateString(locale, { day: '2-digit', month: 'short', year: 'numeric' }) const time = d.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }) return ( {day} {time} ) } const bgOf = (type: number) => BG_TYPES[type] || { es: `BG #${type}`, en: `BG #${type}`, color: '#777', icon: 'fas fa-khanda' } return (
{labels.history}

{labels.desc}

{fmt(matches)} {labels.matches}
{fmt(wins)} {labels.wins}
{fmt(losses)} {labels.losses}
{winRate}% {labels.winRate}
{rows.length === 0 ? (

{labels.none}

) : (
{rows.map((m) => { const bg = bgOf(m.type) const name = locale === 'en' ? bg.en : bg.es return ( ) })}
{labels.battleground} {labels.result} {labels.kb} {labels.hk} {labels.deaths} {labels.damage} {labels.healing} {labels.honor} {labels.date}
{name} {m.won ? labels.win : labels.loss} {fmt(m.killingBlows)} {fmt(m.honorableKills)} {fmt(m.deaths)} {fmt(m.damage)} {fmt(m.healing)} {fmt(m.bonusHonor)} {fmtDate(m.date)}
)}
) }