Files
gunshiz 3314b2a9c6
CI / verify (push) Successful in 40s
CI / build-and-deploy (push) Successful in 1m13s
feat: show level 90 base stats
2026-09-09 20:25:20 +07:00

12 lines
674 B
TypeScript

import type { CatalogBaseStat } from "./types";
export function formatBaseStat({ key, value }: CatalogBaseStat): string {
const normalizedKey = key.toLowerCase();
const rawLabel = key.endsWith("%") ? key.slice(0, -1) : key;
const label = ["hp", "atk", "def", "em", "er"].includes(normalizedKey) ? normalizedKey.toUpperCase() : rawLabel;
const numericValue = typeof value === "number" ? value : Number(value);
const formattedValue = Number.isFinite(numericValue) ? numericValue.toLocaleString("en-US", { maximumFractionDigits: 2 }) : value;
const suffix = key.endsWith("%") || normalizedKey === "er" ? "%" : "";
return `${label} ${formattedValue}${suffix}`;
}