From ce39d0582c3fd6fd7409c8ead4f43f34edeffda9 Mon Sep 17 00:00:00 2001 From: adevopg Date: Mon, 13 Jul 2026 13:56:01 +0000 Subject: [PATCH] =?UTF-8?q?web-next:=20rango=20de=20cuenta=20din=C3=A1mico?= =?UTF-8?q?=20seg=C3=BAn=20PD=20en=20/account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La insignia de rango (antes fija a 1_Newbie/Nivel 1) ahora se calcula por los PD de la cuenta: 14 niveles (getAccountRank en lib/account.ts) con umbrales 0/100/200…/900/1000/5000/10000/>10000 → imágenes nw-ranks 1_Newbie…14_GrandMaster y título «Nivel N». Verificado end-to-end: dp=5500 → 12_Mentor «Nivel 12». Co-Authored-By: Claude Opus 4.8 (1M context) --- web-next/app/[locale]/account/page.tsx | 5 +++-- web-next/lib/account.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/web-next/app/[locale]/account/page.tsx b/web-next/app/[locale]/account/page.tsx index bbfb97e..b76326d 100644 --- a/web-next/app/[locale]/account/page.tsx +++ b/web-next/app/[locale]/account/page.tsx @@ -1,7 +1,7 @@ import { getTranslations, setRequestLocale } from 'next-intl/server' import { redirect } from '@/i18n/navigation' import { getSession } from '@/lib/session' -import { getAccountDashboard } from '@/lib/account' +import { getAccountDashboard, getAccountRank } from '@/lib/account' import { isAdmin } from '@/lib/admin' import { PageShell } from '@/components/PageShell' import { AccountTools } from '@/components/AccountTools' @@ -21,6 +21,7 @@ export default async function AccountPage({ params }: { params: Promise<{ locale const data = await getAccountDashboard(session) const admin = await isAdmin(session) + const rank = getAccountRank(data.dp) return ( @@ -47,7 +48,7 @@ export default async function AccountPage({ params }: { params: Promise<{ locale {t('accountState')}
{/* eslint-disable-next-line @next/next/no-img-element */} - rank + {`${t('level')}

{t('dp')}: {data.dp}

{t('vp')}: {data.vp}

{t('battlepayCredits')}: {data.battlepayCredits}

diff --git a/web-next/lib/account.ts b/web-next/lib/account.ts index 91314d9..0c610ef 100644 --- a/web-next/lib/account.ts +++ b/web-next/lib/account.ts @@ -3,6 +3,21 @@ import { db, DB } from './db' import type { SessionData } from './session' import { getZoneName, getClassCss, getCharacterImage, getRaceName, getClassName } from './character-info' +// Rango de la cuenta según los PD (14 niveles). Umbral = PD mínimos por nivel. +const RANK_FILES = [ + '1_Newbie', '2_Rookie', '3_Apprentice', '4_Explorer', '5_Contributor', '6_Enthusiast', + '7_Collaborator', '8_Regular', '9_RisingStar', '10_Proficient', '11_Experienced', + '12_Mentor', '13_Veteran', '14_GrandMaster', +] +const RANK_MIN = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 5000, 10000, 10001] + +/** Nivel de rango (1-14) e imagen según los PD (dp). */ +export function getAccountRank(dp: number): { level: number; image: string } { + let idx = 0 + for (let i = 0; i < RANK_MIN.length; i++) if (dp >= RANK_MIN[i]) idx = i + return { level: idx + 1, image: `/nw-themes/nw-ryu/nw-images/nw-ranks/${RANK_FILES[idx]}.svg` } +} + export interface Character { name: string level: number