feat(elo): add ELO rating system
- DB: elo column on user table (default 1200, added via ALTER TABLE IF NOT EXISTS) - ELO calculated after every game save (K=32, min 100) - Bots use their fixed ELO values; only human players' ELO changes - AI page games save with bot name (e.g. 'Holzpferd Heinz') instead of 'Stockfish' - User profile shows ELO badge below name - Header shows current ELO for logged-in users (links to profile) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ export default function AiGamePage() {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ pgn: g.pgn(), winner, endReason, playerColor: color, level, startedAt: startedAtRef.current })
|
||||
body: JSON.stringify({ pgn: g.pgn(), winner, endReason, playerColor: color, level, botName: selectedBot.name, startedAt: startedAtRef.current })
|
||||
});
|
||||
if (res.ok) {
|
||||
const { id } = await res.json();
|
||||
|
||||
@@ -43,7 +43,12 @@ export default async function Profile({ params }: { params: { name: string } })
|
||||
return (
|
||||
<div className="mt-8 flex w-full flex-col gap-8">
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 md:gap-8">
|
||||
<h1 className="text-4xl font-bold">{data.name}</h1>
|
||||
<div>
|
||||
<h1 className="text-4xl font-bold">{data.name}</h1>
|
||||
{data.elo != null && (
|
||||
<span className="badge badge-primary badge-lg mt-1 font-mono">{data.elo} ELO</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-6">
|
||||
<div className="flex flex-col items-center">
|
||||
<span className="text-sm">Wins</span>
|
||||
|
||||
@@ -37,6 +37,11 @@ export default function Header() {
|
||||
</Link>
|
||||
)}
|
||||
{user?.id && typeof user.id === "number" && <NotificationPanel />}
|
||||
{user?.elo != null && typeof user.id === "number" && (
|
||||
<Link href={`/user/${user.name}`} className="btn btn-ghost btn-sm font-mono tabular-nums" title="Deine ELO-Wertung">
|
||||
{user.elo}
|
||||
</Link>
|
||||
)}
|
||||
<ThemeToggle />
|
||||
<label tabIndex={0} htmlFor="auth-modal" className="btn btn-ghost btn-circle avatar">
|
||||
<div className="w-10 rounded-full">
|
||||
|
||||
Reference in New Issue
Block a user