web-next: rango de cuenta dinámico según PD en /account
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 (
|
||||
<PageShell title={t('title')}>
|
||||
@@ -47,7 +48,7 @@ export default async function AccountPage({ params }: { params: Promise<{ locale
|
||||
<legend>{t('accountState')}</legend>
|
||||
<div className="separate">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src="/nw-themes/nw-ryu/nw-images/nw-ranks/1_Newbie.svg" className="nw-rank" alt="rank" title={`${t('level')} 1`} />
|
||||
<img src={rank.image} className="nw-rank" alt={`${t('level')} ${rank.level}`} title={`${t('level')} ${rank.level}`} />
|
||||
<p>{t('dp')}: <span>{data.dp}</span></p>
|
||||
<p>{t('vp')}: <span>{data.vp}</span></p>
|
||||
<p>{t('battlepayCredits')}: <span>{data.battlepayCredits}</span></p>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user