feat(menu): in-progress game card replaces mode picker
When /api/state shows a live game, the home page now hides the mode
cards + setup form and shows an 'active-card' instead: ROUND IN
PROGRESS header with pulsing crimson dot, a diagonal 'LIVE' stamp,
white/black seat panels (agent / model / persona), VS divider with
'who's thinking' status, a gold WATCH LIVE button that routes to
/ai-vs-ai (or /play if either side is human), and a crimson ABORT
CURRENT ROUND escape hatch. menu.js polls every 3s so the meta strip
(move count, current thinker) stays fresh and the picker comes back as
soon as the game ends.
CSS housekeeping:
- Global [hidden] { display: none !important } — without it CSS rules
like .modes { display: grid } override the HTML hidden attribute and
the picker bled through the active-card.
- New tokens reuse the existing palette: gold for the watch CTA + meta,
crimson for the LIVE stamp + abort, dashed rule + bone tones for
seat borders. No new fonts or colors introduced — matches the
Major Mono Display / JetBrains Mono tournament-bulletin style.
This commit is contained in:
+128
@@ -26,6 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
|
[hidden] { display: none !important; }
|
||||||
html, body {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: radial-gradient(ellipse at 50% -10%, #1e1e24 0%, var(--ink) 60%) fixed;
|
background: radial-gradient(ellipse at 50% -10%, #1e1e24 0%, var(--ink) 60%) fixed;
|
||||||
@@ -119,6 +120,133 @@ html, body {
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- ACTIVE GAME CARD (in-progress) ---------- */
|
||||||
|
.active-card {
|
||||||
|
position: relative;
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(192,160,96,0.08) 0%, rgba(15,15,18,0) 70%),
|
||||||
|
var(--paper);
|
||||||
|
border: 1px solid var(--gold-dim);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 26px 28px 22px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
box-shadow: 0 30px 80px -40px rgba(192,160,96,0.45);
|
||||||
|
overflow: hidden;
|
||||||
|
animation: setup-in 0.35s ease both;
|
||||||
|
}
|
||||||
|
.active-card::after {
|
||||||
|
content: "LIVE";
|
||||||
|
position: absolute;
|
||||||
|
top: 14px; right: -36px;
|
||||||
|
background: var(--crimson); color: #fff;
|
||||||
|
font-size: 10px; font-weight: 800; letter-spacing: 0.4em;
|
||||||
|
padding: 3px 40px;
|
||||||
|
transform: rotate(35deg);
|
||||||
|
box-shadow: 0 6px 14px -6px var(--crimson);
|
||||||
|
}
|
||||||
|
.active-head {
|
||||||
|
display: flex; align-items: baseline; gap: 12px;
|
||||||
|
border-bottom: 1px dashed var(--rule);
|
||||||
|
padding-bottom: 14px; margin-bottom: 18px;
|
||||||
|
font-size: 11px; letter-spacing: 0.32em; text-transform: uppercase;
|
||||||
|
color: var(--gold);
|
||||||
|
}
|
||||||
|
.active-pulse {
|
||||||
|
display: inline-block; width: 8px; height: 8px;
|
||||||
|
background: var(--crimson); border-radius: 50%;
|
||||||
|
animation: pulse-dot 1.4s ease-in-out infinite;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
.active-meta { margin-left: auto; opacity: 0.55; letter-spacing: 0.16em; color: var(--bone-dim); font-size: 11px; }
|
||||||
|
|
||||||
|
.active-vs {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 96px 1fr;
|
||||||
|
gap: 18px; align-items: stretch;
|
||||||
|
margin-bottom: 22px;
|
||||||
|
}
|
||||||
|
.seat {
|
||||||
|
display: flex; flex-direction: column; gap: 4px;
|
||||||
|
padding: 14px 18px;
|
||||||
|
border: 1px solid var(--rule);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: rgba(0,0,0,0.18);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.seat-white { border-left: 3px solid var(--bone); }
|
||||||
|
.seat-black { border-right: 3px solid var(--bone-dim); text-align: right; }
|
||||||
|
.seat-pip {
|
||||||
|
position: absolute; top: 14px; font-size: 14px; opacity: 0.7;
|
||||||
|
}
|
||||||
|
.seat-white .seat-pip { left: 18px; color: var(--bone); }
|
||||||
|
.seat-black .seat-pip { right: 18px; color: var(--bone-dim); }
|
||||||
|
.seat-name {
|
||||||
|
font-size: 22px; font-weight: 800; letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-left: 20px; /* under the pip */
|
||||||
|
}
|
||||||
|
.seat-black .seat-name { margin-left: 0; margin-right: 20px; }
|
||||||
|
.seat-sub {
|
||||||
|
font-size: 11px; color: var(--gold); letter-spacing: 0.08em;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.seat-black .seat-sub { margin-left: 0; margin-right: 20px; }
|
||||||
|
.seat-persona {
|
||||||
|
font-size: 11px; color: var(--bone-dim); opacity: 0.7;
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-left: 20px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.seat-black .seat-persona { margin-left: 0; margin-right: 20px; }
|
||||||
|
|
||||||
|
.active-divider {
|
||||||
|
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.active-vs-label {
|
||||||
|
font-size: 28px; font-weight: 800; color: var(--crimson);
|
||||||
|
letter-spacing: 0.1em;
|
||||||
|
}
|
||||||
|
.active-turn {
|
||||||
|
font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
|
||||||
|
color: var(--bone-dim); text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active-actions {
|
||||||
|
display: flex; gap: 16px; align-items: center;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
.watch-btn {
|
||||||
|
display: inline-flex; align-items: center; gap: 14px;
|
||||||
|
background: var(--gold); color: #1a1410;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 12px 32px;
|
||||||
|
font-size: 15px; font-weight: 800; letter-spacing: 0.2em;
|
||||||
|
border-radius: 3px;
|
||||||
|
transition: filter 0.15s, transform 0.1s;
|
||||||
|
box-shadow: 0 8px 28px -10px var(--gold);
|
||||||
|
}
|
||||||
|
.watch-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
|
||||||
|
.watch-btn .kbd {
|
||||||
|
font-size: 11px; opacity: 0.7;
|
||||||
|
border: 1px solid rgba(0,0,0,0.3); padding: 1px 6px; border-radius: 2px;
|
||||||
|
}
|
||||||
|
.active-abort {
|
||||||
|
background: transparent; border: 1px solid var(--crimson-dim);
|
||||||
|
color: var(--crimson); padding: 8px 16px;
|
||||||
|
font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
|
||||||
|
cursor: pointer; border-radius: 3px;
|
||||||
|
font-family: inherit;
|
||||||
|
transition: background 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
.active-abort:hover { background: var(--crimson-dim); color: #ffe5e5; }
|
||||||
|
.active-foot {
|
||||||
|
margin: 18px 0 0; padding-top: 14px;
|
||||||
|
border-top: 1px dashed var(--rule);
|
||||||
|
font-size: 11px; color: var(--ash);
|
||||||
|
letter-spacing: 0.04em; font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------- MODE CARDS ---------- */
|
/* ---------- MODE CARDS ---------- */
|
||||||
.modes {
|
.modes {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
+44
-1
@@ -34,7 +34,50 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<p class="tagline">две LLM выходят на доску. одна возвращается. без подсказок, без коучей, всё — на трэш-токе.</p>
|
<p class="tagline">две LLM выходят на доску. одна возвращается. без подсказок, без коучей, всё — на трэш-токе.</p>
|
||||||
|
|
||||||
<section class="modes">
|
<!-- Shown when a game is currently in progress: skip the picker and
|
||||||
|
offer to drop into the live view. -->
|
||||||
|
<section class="active-card" id="active-card" hidden>
|
||||||
|
<header class="active-head">
|
||||||
|
<span class="active-pulse"></span>
|
||||||
|
<span class="active-label">ROUND IN PROGRESS</span>
|
||||||
|
<span class="active-meta" id="active-meta"></span>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="active-vs">
|
||||||
|
<div class="seat seat-white">
|
||||||
|
<div class="seat-pip">●</div>
|
||||||
|
<div class="seat-name" id="active-white-agent">…</div>
|
||||||
|
<div class="seat-sub" id="active-white-model">…</div>
|
||||||
|
<div class="seat-persona" id="active-white-persona">…</div>
|
||||||
|
</div>
|
||||||
|
<div class="active-divider">
|
||||||
|
<span class="active-vs-label">VS</span>
|
||||||
|
<span class="active-turn" id="active-turn">…</span>
|
||||||
|
</div>
|
||||||
|
<div class="seat seat-black">
|
||||||
|
<div class="seat-pip">○</div>
|
||||||
|
<div class="seat-name" id="active-black-agent">…</div>
|
||||||
|
<div class="seat-sub" id="active-black-model">…</div>
|
||||||
|
<div class="seat-persona" id="active-black-persona">…</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="active-actions">
|
||||||
|
<a class="watch-btn" id="watch-btn" href="/ai-vs-ai">
|
||||||
|
<span>WATCH LIVE</span>
|
||||||
|
<span class="kbd">↩</span>
|
||||||
|
</a>
|
||||||
|
<button type="button" class="active-abort" id="active-abort">
|
||||||
|
abort current round
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="active-foot">
|
||||||
|
новая партия откроется когда эта закончится — мат / резигн / абort.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="modes" id="modes">
|
||||||
<button class="mode" data-mode="ai_vs_ai" type="button">
|
<button class="mode" data-mode="ai_vs_ai" type="button">
|
||||||
<div class="mode-num">01</div>
|
<div class="mode-num">01</div>
|
||||||
<div class="mode-name">AI <span class="x">×</span> AI</div>
|
<div class="mode-name">AI <span class="x">×</span> AI</div>
|
||||||
|
|||||||
+77
-2
@@ -4,6 +4,8 @@ const STATE = {
|
|||||||
options: null,
|
options: null,
|
||||||
mode: null, // "ai_vs_ai" | "human_vs_ai" | null
|
mode: null, // "ai_vs_ai" | "human_vs_ai" | null
|
||||||
inProgress: false,
|
inProgress: false,
|
||||||
|
game: null, // current game payload (only set when in progress)
|
||||||
|
bindings: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SIDES = ["white", "black"];
|
const SIDES = ["white", "black"];
|
||||||
@@ -102,8 +104,12 @@ async function loadInProgress() {
|
|||||||
try {
|
try {
|
||||||
const s = await (await fetch("/api/state")).json();
|
const s = await (await fetch("/api/state")).json();
|
||||||
STATE.inProgress = !!(s.game && !s.game.status?.result);
|
STATE.inProgress = !!(s.game && !s.game.status?.result);
|
||||||
|
STATE.game = STATE.inProgress ? s.game : null;
|
||||||
|
STATE.bindings = STATE.inProgress ? s.bindings : null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
STATE.inProgress = false;
|
STATE.inProgress = false;
|
||||||
|
STATE.game = null;
|
||||||
|
STATE.bindings = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function refreshGate() {
|
function refreshGate() {
|
||||||
@@ -111,6 +117,54 @@ function refreshGate() {
|
|||||||
$("start-btn").disabled = STATE.inProgress;
|
$("start-btn").disabled = STATE.inProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- active game card ----------
|
||||||
|
function renderActiveCard() {
|
||||||
|
const card = $("active-card");
|
||||||
|
const modes = $("modes");
|
||||||
|
const setup = $("setup");
|
||||||
|
if (!STATE.inProgress) {
|
||||||
|
card.hidden = true;
|
||||||
|
modes.hidden = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide picker + setup, show the live card.
|
||||||
|
card.hidden = false;
|
||||||
|
modes.hidden = true;
|
||||||
|
setup.hidden = true;
|
||||||
|
|
||||||
|
const g = STATE.game || {};
|
||||||
|
const b = STATE.bindings || {};
|
||||||
|
const promptLabel = (id) => {
|
||||||
|
if (!id) return "";
|
||||||
|
const p = (STATE.options?.prompts || []).find(x => x.id === id);
|
||||||
|
return p ? p.label : id;
|
||||||
|
};
|
||||||
|
// Pull prompt out of game.agents (the dict committed by start_new_game) —
|
||||||
|
// bindings may not carry it.
|
||||||
|
const wA = g.agents?.white || {};
|
||||||
|
const bA = g.agents?.black || {};
|
||||||
|
|
||||||
|
$("active-white-agent").textContent = (wA.agent || "?");
|
||||||
|
$("active-white-model").textContent = wA.agent === "human" ? "controlled by you" : (wA.model || "?");
|
||||||
|
$("active-white-persona").textContent = wA.agent === "human" ? "" : promptLabel(wA.prompt);
|
||||||
|
|
||||||
|
$("active-black-agent").textContent = (bA.agent || "?");
|
||||||
|
$("active-black-model").textContent = bA.agent === "human" ? "controlled by you" : (bA.model || "?");
|
||||||
|
$("active-black-persona").textContent = bA.agent === "human" ? "" : promptLabel(bA.prompt);
|
||||||
|
|
||||||
|
// current state strip
|
||||||
|
const moves = (g.history || []).filter(h => h.san).length;
|
||||||
|
$("active-meta").textContent = `move ${Math.ceil(moves/2) + (g.side_to_move === "white" ? 0 : 0)} · ${moves} half-moves · ${g.id ? g.id.slice(0,10) : ""}…`;
|
||||||
|
const sideRu = g.side_to_move === "white" ? "белые" : "чёрные";
|
||||||
|
const moverAgent = (g.side_to_move === "white" ? wA.agent : bA.agent) || "?";
|
||||||
|
$("active-turn").textContent = `${moverAgent} (${sideRu}) thinks…`;
|
||||||
|
|
||||||
|
// Pick the right destination for watch
|
||||||
|
const watchHref = (wA.agent === "human" || bA.agent === "human") ? "/play" : "/ai-vs-ai";
|
||||||
|
$("watch-btn").setAttribute("href", watchHref);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- HUD ----------
|
// ---------- HUD ----------
|
||||||
async function refreshHud() {
|
async function refreshHud() {
|
||||||
try {
|
try {
|
||||||
@@ -180,8 +234,20 @@ async function start() {
|
|||||||
async function init() {
|
async function init() {
|
||||||
STATE.options = await (await fetch("/api/options")).json();
|
STATE.options = await (await fetch("/api/options")).json();
|
||||||
await loadInProgress();
|
await loadInProgress();
|
||||||
|
renderActiveCard();
|
||||||
refreshHud();
|
refreshHud();
|
||||||
setInterval(refreshHud, 5000);
|
setInterval(refreshHud, 5000);
|
||||||
|
// Poll the active-card payload so the meta strip ('move N · whose turn')
|
||||||
|
// updates without a page reload. Skipped while no game is live.
|
||||||
|
setInterval(async () => {
|
||||||
|
const before = STATE.inProgress;
|
||||||
|
await loadInProgress();
|
||||||
|
renderActiveCard();
|
||||||
|
// Game just ended? Unblock the picker.
|
||||||
|
if (before && !STATE.inProgress) {
|
||||||
|
$("modes").hidden = false;
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
// Mode picker
|
// Mode picker
|
||||||
document.querySelectorAll(".mode[data-mode]").forEach((el) => {
|
document.querySelectorAll(".mode[data-mode]").forEach((el) => {
|
||||||
@@ -241,10 +307,19 @@ async function init() {
|
|||||||
document.querySelectorAll(".mode").forEach((m) => m.setAttribute("aria-pressed", "false"));
|
document.querySelectorAll(".mode").forEach((m) => m.setAttribute("aria-pressed", "false"));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Abort current
|
// Abort current (inside the setup dialog warning)
|
||||||
$("abort-current").addEventListener("click", async () => {
|
$("abort-current").addEventListener("click", async () => {
|
||||||
await fetch("/api/abort-game", { method: "POST" });
|
await fetch("/api/abort-game", { method: "POST" });
|
||||||
setTimeout(async () => { await loadInProgress(); refreshGate(); refreshHud(); }, 200);
|
setTimeout(async () => {
|
||||||
|
await loadInProgress(); refreshGate(); refreshHud(); renderActiveCard();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Abort current from the active-card (visible only when a game is live)
|
||||||
|
$("active-abort").addEventListener("click", async () => {
|
||||||
|
if (!confirm("Прервать текущую партию?")) return;
|
||||||
|
await fetch("/api/abort-game", { method: "POST" });
|
||||||
|
setTimeout(async () => { await loadInProgress(); renderActiveCard(); refreshHud(); }, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
|
|||||||
Reference in New Issue
Block a user