rewrite: TS monorepo — pi SDK stateless agents, Postgres+pg-boss, SvelteKit themed UI; legacy moved to legacy/
@@ -0,0 +1,110 @@
|
||||
# AI·CHESS — design brief for frontend concepts
|
||||
|
||||
You are designing the **new frontend** for AI·CHESS: an arena where frontier LLM agents
|
||||
play chess against each other (and against humans), trash-talk each other, and get
|
||||
rated on a public leaderboard. Live at chess.danosito.com. Audience: devs/AI nerds and
|
||||
their friends, Russian-speaking. Vibe: fun, a bit edgy/meme-y, but must stay **readable
|
||||
and fast to scan** — it is a spectator product first.
|
||||
|
||||
UI language: **Russian** (short English accents/labels are fine if they fit the concept).
|
||||
|
||||
## Tech constraints (mandatory)
|
||||
|
||||
- **SvelteKit 3 + Svelte 5 (runes) + TypeScript**, `@sveltejs/adapter-static` (SPA, `fallback: 'index.html'`).
|
||||
- Board: **`@lichess-org/chessground`** (+ its base CSS; pick/skin a board theme & piece set that fits your concept).
|
||||
Use **`chess.js`** to replay the mock game into positions.
|
||||
- Provider marks: use SVG paths from the **`simple-icons`** npm package (`siClaude`, `siOpenai`, `siAnthropic`).
|
||||
- Keep deps light. No big component kits. Scoped Svelte styles / vanilla CSS / Tailwind 4 — your call.
|
||||
Charts: hand-rolled SVG preferred.
|
||||
- Mock data only (no backend). Put mock data in `src/lib/mock.ts` with realistic content (see below).
|
||||
- Must pass `npm run build`. Must be viewable with `npm run preview -- --port <your port>`.
|
||||
- Desktop-first (1440×900), but the **live match page must be usable on mobile (390×844)** for spectators.
|
||||
|
||||
## Domain facts (so the UI is honest)
|
||||
|
||||
Players ("entities") on the leaderboard:
|
||||
- 4 models × 2 variants each = 8 AI entities:
|
||||
- Claude Opus 5.5 (`claude-opus-5-5`), Claude Fable 5.1 (`claude-fable-5-1`) — Anthropic
|
||||
- GPT-6.1 Sol (`gpt-6.1-sol`), GPT-6 Astra (`gpt-6-astra`) — OpenAI
|
||||
- Variant **MAX** (max reasoning effort, slow, expensive) and **HIGH** (a.k.a. «быстрый»).
|
||||
- Humans (registered users with avatars) are on the **same** leaderboard.
|
||||
|
||||
How a game works (show this, it is the product's soul):
|
||||
- Every move the agent gets a **fresh context** (no memory): the board in a few notations
|
||||
(ASCII diagram, FEN, piece list), the opponent's last move, the opponent's **trash-talk line**,
|
||||
and only the *relevant* rule state: castling notes (only when it looks possible), "40/50 moves
|
||||
toward 50-move draw", "this position already repeated twice".
|
||||
- The agent may call tools (logged): `make_move`, `finish_turn` (trash-talk line to opponent +
|
||||
optional **note to its future self**), and — under the experimental flag — `get_move_history`
|
||||
and a `python` sandbox with python-chess.
|
||||
- **Thoughts** (reasoning summary + tool calls + the exact context it received) are **hidden by
|
||||
default and expand on click** per move. Design this interaction carefully — it should feel great.
|
||||
- Experimental flags per match: «Заметки себе» (note to future self), «Доп. тулы» (history + python),
|
||||
«Читерство» (illegal moves allowed → **unrated**, marked loudly).
|
||||
- Stockfish runs on every position: eval bar, eval graph, best-move arrow (toggle),
|
||||
per-move classification (best ★, brilliant !!, inaccuracy ?!, mistake ?, blunder ??),
|
||||
**live accuracy %** per player. The old UI did this badly — make it great and legible.
|
||||
- Cost tracking: tokens and $ per move, per player, per game.
|
||||
- Scheduled matches (set by admin) have **spectator predictions** (white / draw / black, points not
|
||||
money; locked at game start) and a countdown on the home page.
|
||||
- After the game: **post-game interview** — each agent gives a short, emotional, human
|
||||
(not nerdy) 3–6 sentence comment. Show it like a press-conference / post-fight interview.
|
||||
- Each finished match gets an **AI-generated meme thumbnail** (YouTube/GothamChess-style clickbait:
|
||||
two participants' avatars/logos, board, huge caption with a double meaning). Archive/home show
|
||||
them as a YouTube-like grid. You can't generate images — compose convincing placeholders
|
||||
(CSS/SVG composition with the caption, logos, a mini-board), so the grid looks real.
|
||||
Caption ideas: «ЗАБЫЛ КАК ХОДИТ КОНЬ», «ДУМАЛ 4 МИНУТЫ — ЗЕВНУЛ МАТ В 1», «ЖЕРТВА ФЕРЗЯ (СЛУЧАЙНАЯ)»,
|
||||
«ЧЕЛОВЕК ПРОТИВ МАШИНЫ: МАШИНА ОБИДЕЛАСЬ», «ВЫРВАЛ ОЧКО», «GPT ПОПРОСИЛ НИЧЬЮ. 3 РАЗА».
|
||||
- Users: open registration, login; onboarding includes **avatar upload**. Admin sees all users and
|
||||
how many tokens/$ each spent.
|
||||
|
||||
## Screens
|
||||
|
||||
Required (must be polished):
|
||||
1. **Live match** `/match/demo` — the hero screen. Board + eval bar, both player cards (logo/avatar,
|
||||
model, variant, rating, persona, thinking timer when it's their turn), move list with
|
||||
classifications, accuracy, eval graph, trash-talk feed, expandable thoughts per move,
|
||||
rule-state banners (repetition / 50-move), cost meter, predictions widget (scheduled match).
|
||||
Also a **game-over state** `/match/demo?over=1` with result + both interviews + thumbnail.
|
||||
2. **Home** `/` — live now (can be several concurrent games), next scheduled match with countdown
|
||||
and predictions, recent matches as a thumbnail grid, CTA «Новый матч» (logged in).
|
||||
3. **Leaderboard** `/leaderboard` — Elo table (AI + humans), W/D/L, games, avg accuracy, $ per game,
|
||||
**price vs Elo** view («сколько стоит рейтинг»), and an optional head-to-head matrix only if you can
|
||||
make it genuinely fun/readable.
|
||||
|
||||
Nice to have (if time allows, lower polish OK):
|
||||
4. New match setup `/new` — pick white/black (AI entity or «Я сам»), persona preset
|
||||
(Уличный гопник / Профессор / Поэт / Молчун / Шут), experimental flags with warnings.
|
||||
5. Login/registration + onboarding with avatar `/login`.
|
||||
6. Admin `/admin` — users table with tokens/$ spent, scheduled matches.
|
||||
7. Archive/replay `/games`.
|
||||
|
||||
## Mock game (use this; it's legal — replay with chess.js)
|
||||
|
||||
PGN (in progress, Black to move after a knight sac on h3):
|
||||
```
|
||||
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d3 d6 6. O-O a6 7. a4 O-O 8. h3 Ba7
|
||||
9. Re1 h6 10. Nbd2 Re8 11. Nf1 Be6 12. Bxe6 Rxe6 13. Ng3 d5 14. exd5 Qxd5 15. Be3 Rd8
|
||||
16. Qc2 Bxe3 17. Rxe3 Qd7 18. Rae1 Rde8 19. b4 Nd5 20. R3e2 Nf4 21. Re4 Nxh3+ 22. gxh3
|
||||
```
|
||||
White: **GPT-6.1 Sol · MAX** (persona: Профессор). Black: **Claude Opus 5.5 · MAX** (persona: Уличный гопник).
|
||||
Invent plausible evals/classifications (e.g. 21...Nxh3+ is a dubious "?!" sac, eval swings), costs,
|
||||
think times (20 s – 4 min), ratings (~1700–2100), trash-talk lines in Russian matching personas, e.g.:
|
||||
- Black (гопник): «Конь на h3 — это не жертва, это инвестиция. Считай, братан.»
|
||||
- White (профессор): «Любопытная идея. Ботвинник назвал бы её некорректной — и был бы прав.»
|
||||
Sample thought (collapsed by default): reasoning summary «Белые перегрузили e-линию… после gxh3 ферзь
|
||||
идёт на h3 через e6? Нет, ладья мешает — сначала Rg6…», tool calls: `python(...)` → output snippet,
|
||||
`make_move("Nxh3+")` → ok, `finish_turn(phrase, note_to_self="Атака по g-линии, не меняй ферзей")`.
|
||||
|
||||
## Deliverables (in your own directory `design/<your-name>/`)
|
||||
|
||||
- A working SvelteKit app (own `package.json`, run `npm install` there).
|
||||
- `README.md`: concept name, one-paragraph idea, palette, fonts, key interaction decisions.
|
||||
- Screenshots `shots/*.png`: every required screen at 1440×900 (full page where useful),
|
||||
the expanded-thoughts state, the game-over state, and the live match at 390×844.
|
||||
Use the **browser-cli** skill to take them; **look at your own screenshots and iterate at least
|
||||
once** to fix ugliness before you finish.
|
||||
- Do not touch anything outside `design/<your-name>/`.
|
||||
|
||||
Avoid generic AI-slop: no purple-gradient SaaS, no Inter/Roboto, no cookie-cutter card grids.
|
||||
Commit to a bold, coherent direction and execute it precisely.
|
||||
@@ -0,0 +1,23 @@
|
||||
node_modules
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
.netlify
|
||||
.wrangler
|
||||
/.svelte-kit
|
||||
/build
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
@@ -0,0 +1 @@
|
||||
engine-strict=true
|
||||
@@ -0,0 +1,71 @@
|
||||
# AI FIGHT CLUB — arcade concept for AI·CHESS
|
||||
|
||||
**Концепт.** Матч двух LLM — это не «партия», это бой в аркадном файтинге. Живой матч
|
||||
оформлен как HUD из Street Fighter / KOF: сверху две **полоски здоровья** (это вероятность
|
||||
победы по Stockfish, с «призрачным» хвостом урона, как в файтингах), таймер «THINKING» у того,
|
||||
чей ход, персона и accuracy под именем. Ошибки и маты — **стингеры**: на зевке над доской
|
||||
слэмится «BLUNDER!!», на сомнительной жертве — «RISKY?!», на мате — «K.O.» и экран
|
||||
трясёт. Выбор моделей — **character select** с P1/P2 рамками, тэглайнами и персонами.
|
||||
После боя — «пресс-конференция»: два интервью как после-матчевые цитаты и мем-превью
|
||||
(собрано CSS/SVG: аватары бойцов, перечёркнутый проигравший, мини-доска, кликбейт-подпись).
|
||||
Пиксель/CRT-акценты (Press Start 2P, сканлайны) используются только на стингерах,
|
||||
HUD-центре и «кабинете» логина — **доска всегда чистая** (cburnett + свой стальной скин).
|
||||
|
||||
## Палитра
|
||||
|
||||
| токен | цвет | роль |
|
||||
|---|---|---|
|
||||
| `--bg` | `#08080c` | кабинет, фон |
|
||||
| `--panel` / `--line` | `#14141c` / `#262634` | панели |
|
||||
| `--p1` | `#ffe14d` | игрок 1 (белые), CTA |
|
||||
| `--p2` | `#ff3b5c` | игрок 2 (чёрные), LIVE, K.O. |
|
||||
| `--hp` / `--hp-mid` / `--hp-low` | `#4cff5e` / `#ffd23f` / `#ff3b3b` | полоски здоровья |
|
||||
| `--c-best` ★ / `--c-brill` !! / `--c-inacc` ?! / `--c-mistake` ? / `--c-blunder` ?? | green / cyan / yellow / orange / red | классификация ходов |
|
||||
| доска | `#e7e2d2` / `#5a6b86` | «стальной кабинет», высокий контраст под cburnett |
|
||||
|
||||
## Шрифты (Google Fonts)
|
||||
|
||||
- **Unbounded 700/900** — дисплей: имена бойцов, заголовки, VS, стингеры, подписи мемов (кириллица родная).
|
||||
- **Press Start 2P** — пиксельные ярлыки: P1/P2, панельные заголовки, «INSERT COIN», таймеры.
|
||||
- **JetBrains Mono** — ходы, оценки, токены, $, контекст агента.
|
||||
- **IBM Plex Sans** — текст треш-тока, интервью, описания.
|
||||
|
||||
## Ключевые интеракции
|
||||
|
||||
- **Health bars = eval.** Процент — win-probability из centipawns (lichess-сигмоида). При
|
||||
падении полоска красит «призрак» и догоняет с задержкой — урон читается мгновенно.
|
||||
- **Мысли агента** скрыты; клик по ходу в COMBO LOG → доска прыгает на позицию, под строкой
|
||||
«включается» панель (CRT power-on), с табами **Мысли / Тулы / Контекст**: reasoning summary с
|
||||
мигающим курсором, логи `python(...)`, `make_move`, `finish_turn(..., note_to_self)`,
|
||||
и точный fresh-контекст (FEN + ASCII + реплика соперника + rule state), собранный
|
||||
из позиции через chess.js. Аккордеон: одна панель за раз, `✕` или повторный клик закрывает.
|
||||
- **Стингеры по классификации**: навигация на ?? → «BLUNDER!!», на ! ! → «BRILLIANT!!», на
|
||||
жертву ?! → «RISKY?!»; при загрузке — «ROUND 22 / FIGHT!», в `?over=1` — «K.O.».
|
||||
- **Навигация:** ←/→, Home/End, `f` — flip; клик по графику / по треш-току тоже ведёт к ходу.
|
||||
Кнопка «LIVE ▶» возвращает в текущую позицию; в replay над доской — плашка.
|
||||
- **Best-move arrow** (toggle) рисуется chessground `autoShapes`; для «лучших» ходов — сам ход,
|
||||
для ошибок — альтернатива движка из мока.
|
||||
- **Rule state** (повторения / 50 ходов / рокировки) — в HUD-центре и в табе «Контекст»
|
||||
ровно в том виде, в каком его видит агент.
|
||||
- **Прогнозы** — очки, не деньги; на главной открыты, в матче «ставки закрыты» + моя ставка.
|
||||
- **Cost meter** — $ и токены на игрока, на ход, суммарно.
|
||||
- **Мобила (390×844):** HUD в столбик, доска во всю ширину, нижние табы Ходы / Треш-ток / Инфо.
|
||||
|
||||
## Экраны
|
||||
|
||||
`/` главная · `/match/demo` live · `/match/demo?over=1` game over + интервью + мем ·
|
||||
`/leaderboard` (Рейтинг / «Сколько стоит рейтинг» scatter MAX↔HIGH / «Кто кого» матрица) ·
|
||||
`/new` character select · `/login` вход/регистрация/аватар · `/admin` · `/games` архив.
|
||||
|
||||
## Запуск
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
npm run preview -- --port 5183
|
||||
```
|
||||
|
||||
Скриншоты — `shots/*.png`. Мок-данные — `src/lib/mock.ts` (PGN из брифа продолжен до
|
||||
легального мата 31…Qxh4#, проверено chess.js). `siOpenai` в simple-icons v16 отсутствует
|
||||
(убран из пакета), поэтому для OpenAI нарисован свой шестигранный знак в той же 24-сетке;
|
||||
`siClaude` / `siAnthropic` — из пакета.
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "arcade",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo ''",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-static": "^4.0.0",
|
||||
"@sveltejs/kit": "^3.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
||||
"svelte": "^5.57.1",
|
||||
"svelte-check": "^4.6.0",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"imports": {
|
||||
"#lib": "./src/lib/index.js",
|
||||
"#lib/*": "./src/lib/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lichess-org/chessground": "^10.4.2",
|
||||
"chess.js": "^1.4.0",
|
||||
"simple-icons": "^16.35.0"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 773 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 619 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 167 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 276 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 225 KiB |
|
After Width: | Height: | Size: 357 KiB |
|
After Width: | Height: | Size: 230 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 199 KiB |
@@ -0,0 +1,317 @@
|
||||
/* ─── AI FIGHT CLUB — design tokens ─────────────────────────── */
|
||||
:root {
|
||||
--bg: #08080c;
|
||||
--bg-2: #0f0f16;
|
||||
--panel: #14141c;
|
||||
--panel-2: #1a1a24;
|
||||
--line: #262634;
|
||||
--line-2: #343446;
|
||||
--text: #f3efe4;
|
||||
--muted: #8e8d9c;
|
||||
--dim: #5c5b6b;
|
||||
|
||||
/* fighters */
|
||||
--p1: #ffe14d; /* white side */
|
||||
--p1-deep: #b89a00;
|
||||
--p2: #ff3b5c; /* black side */
|
||||
--p2-deep: #a3122b;
|
||||
|
||||
/* health */
|
||||
--hp: #4cff5e;
|
||||
--hp-mid: #ffd23f;
|
||||
--hp-low: #ff3b3b;
|
||||
|
||||
/* classification */
|
||||
--c-best: #4cff5e;
|
||||
--c-brill: #42e8ff;
|
||||
--c-inacc: #ffd23f;
|
||||
--c-mistake: #ff8c42;
|
||||
--c-blunder: #ff3b3b;
|
||||
|
||||
--font-display: 'Unbounded', 'Arial Black', sans-serif;
|
||||
--font-pixel: 'Press Start 2P', monospace;
|
||||
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||
--font-body: 'IBM Plex Sans', system-ui, sans-serif;
|
||||
|
||||
--r: 4px;
|
||||
--nav-h: 56px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: var(--font-body);
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
body {
|
||||
background-image:
|
||||
radial-gradient(1200px 600px at 50% -10%, rgba(255, 225, 77, 0.06), transparent 60%),
|
||||
radial-gradient(900px 500px at 100% 100%, rgba(255, 59, 92, 0.07), transparent 60%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
button {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
::selection {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* ─── type utilities ─── */
|
||||
.pixel {
|
||||
font-family: var(--font-pixel);
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.mono {
|
||||
font-family: var(--font-mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.display {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* ─── panel ─── */
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--r);
|
||||
}
|
||||
.panel-h {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-family: var(--font-pixel);
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.panel-h b {
|
||||
color: var(--text);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* ─── buttons ─── */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 10px 16px;
|
||||
border: 2px solid var(--text);
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
transition:
|
||||
transform 0.08s ease,
|
||||
background 0.12s ease,
|
||||
color 0.12s ease;
|
||||
box-shadow: 3px 3px 0 var(--dim);
|
||||
}
|
||||
.btn:hover {
|
||||
background: var(--text);
|
||||
color: #000;
|
||||
transform: translate(-1px, -1px);
|
||||
box-shadow: 4px 4px 0 var(--dim);
|
||||
}
|
||||
.btn:active {
|
||||
transform: translate(2px, 2px);
|
||||
box-shadow: 1px 1px 0 var(--dim);
|
||||
}
|
||||
.btn.p1 {
|
||||
border-color: var(--p1);
|
||||
color: var(--p1);
|
||||
box-shadow: 3px 3px 0 var(--p1-deep);
|
||||
}
|
||||
.btn.p1:hover {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
}
|
||||
.btn.p2 {
|
||||
border-color: var(--p2);
|
||||
color: var(--p2);
|
||||
box-shadow: 3px 3px 0 var(--p2-deep);
|
||||
}
|
||||
.btn.p2:hover {
|
||||
background: var(--p2);
|
||||
color: #000;
|
||||
}
|
||||
.btn.solid {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
border-color: var(--p1);
|
||||
box-shadow: 3px 3px 0 var(--p1-deep);
|
||||
}
|
||||
.btn.solid:hover {
|
||||
background: #fff;
|
||||
border-color: #fff;
|
||||
}
|
||||
.btn.sm {
|
||||
padding: 6px 10px;
|
||||
font-size: 10px;
|
||||
box-shadow: 2px 2px 0 var(--dim);
|
||||
}
|
||||
|
||||
/* ─── tags ─── */
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 2px 6px;
|
||||
font-family: var(--font-pixel);
|
||||
font-size: 8px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
border: 1px solid var(--line-2);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tag.live {
|
||||
border-color: var(--p2);
|
||||
color: var(--p2);
|
||||
}
|
||||
.tag.live::before {
|
||||
content: '';
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: var(--p2);
|
||||
animation: blink 1s steps(2) infinite;
|
||||
}
|
||||
.tag.max {
|
||||
border-color: var(--p1);
|
||||
color: var(--p1);
|
||||
}
|
||||
.tag.high {
|
||||
border-color: var(--c-brill);
|
||||
color: var(--c-brill);
|
||||
}
|
||||
.tag.human {
|
||||
border-color: var(--hp);
|
||||
color: var(--hp);
|
||||
}
|
||||
.tag.cheat {
|
||||
border-color: var(--c-blunder);
|
||||
color: #fff;
|
||||
background: var(--c-blunder);
|
||||
}
|
||||
.tag.warn {
|
||||
border-color: var(--c-inacc);
|
||||
color: var(--c-inacc);
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── CRT scanlines (used sparingly) ─── */
|
||||
.crt {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.crt::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background: repeating-linear-gradient(
|
||||
0deg,
|
||||
rgba(0, 0, 0, 0) 0px,
|
||||
rgba(0, 0, 0, 0) 2px,
|
||||
rgba(0, 0, 0, 0.22) 3px
|
||||
);
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
|
||||
/* ─── pixel border (chunky 2px steps) ─── */
|
||||
.pxborder {
|
||||
box-shadow:
|
||||
0 0 0 2px var(--bg),
|
||||
0 0 0 4px var(--line-2);
|
||||
}
|
||||
|
||||
/* ─── CHESSGROUND THEME: "steel cabinet" ─── */
|
||||
cg-board {
|
||||
background-color: #e7e2d2;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" shape-rendering="crispEdges"><g fill="%235a6b86"><rect x="1" y="0" width="1" height="1"/><rect x="3" y="0" width="1" height="1"/><rect x="5" y="0" width="1" height="1"/><rect x="7" y="0" width="1" height="1"/><rect x="0" y="1" width="1" height="1"/><rect x="2" y="1" width="1" height="1"/><rect x="4" y="1" width="1" height="1"/><rect x="6" y="1" width="1" height="1"/><rect x="1" y="2" width="1" height="1"/><rect x="3" y="2" width="1" height="1"/><rect x="5" y="2" width="1" height="1"/><rect x="7" y="2" width="1" height="1"/><rect x="0" y="3" width="1" height="1"/><rect x="2" y="3" width="1" height="1"/><rect x="4" y="3" width="1" height="1"/><rect x="6" y="3" width="1" height="1"/><rect x="1" y="4" width="1" height="1"/><rect x="3" y="4" width="1" height="1"/><rect x="5" y="4" width="1" height="1"/><rect x="7" y="4" width="1" height="1"/><rect x="0" y="5" width="1" height="1"/><rect x="2" y="5" width="1" height="1"/><rect x="4" y="5" width="1" height="1"/><rect x="6" y="5" width="1" height="1"/><rect x="1" y="6" width="1" height="1"/><rect x="3" y="6" width="1" height="1"/><rect x="5" y="6" width="1" height="1"/><rect x="7" y="6" width="1" height="1"/><rect x="0" y="7" width="1" height="1"/><rect x="2" y="7" width="1" height="1"/><rect x="4" y="7" width="1" height="1"/><rect x="6" y="7" width="1" height="1"/></g></svg>');
|
||||
}
|
||||
cg-board square.last-move {
|
||||
background-color: rgba(255, 225, 77, 0.45);
|
||||
}
|
||||
cg-board square.selected {
|
||||
background-color: rgba(76, 255, 94, 0.5);
|
||||
}
|
||||
cg-board square.check {
|
||||
background: radial-gradient(ellipse at center, rgba(255, 59, 59, 1) 0%, rgba(255, 59, 59, 0.9) 25%, rgba(255, 59, 59, 0) 89%);
|
||||
}
|
||||
cg-board square.move-dest {
|
||||
background: radial-gradient(rgba(0, 0, 0, 0.35) 22%, transparent 23%);
|
||||
}
|
||||
.cg-wrap coords {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.cg-wrap coords.ranks coord {
|
||||
color: #2b3444;
|
||||
}
|
||||
.cg-wrap coords.files coord {
|
||||
color: #2b3444;
|
||||
}
|
||||
.cg-wrap coords.ranks coord:nth-child(2n),
|
||||
.cg-wrap coords.files coord:nth-child(2n) {
|
||||
color: #e7e2d2;
|
||||
}
|
||||
|
||||
/* reduced motion */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;700;900&family=Press+Start+2P&family=JetBrains+Mono:wght@400;500;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,76 @@
|
||||
<script lang="ts">
|
||||
import { Chessground } from '@lichess-org/chessground';
|
||||
import type { Api } from '@lichess-org/chessground/api';
|
||||
import type { Key } from '@lichess-org/chessground/types';
|
||||
|
||||
let {
|
||||
fen,
|
||||
lastMove = null,
|
||||
check = false,
|
||||
orientation = 'white',
|
||||
arrow = null,
|
||||
turn = 'w'
|
||||
}: {
|
||||
fen: string;
|
||||
lastMove?: [string, string] | null;
|
||||
check?: boolean;
|
||||
orientation?: 'white' | 'black';
|
||||
arrow?: [string, string] | null;
|
||||
turn?: 'w' | 'b';
|
||||
} = $props();
|
||||
|
||||
let el: HTMLDivElement;
|
||||
let api: Api | undefined;
|
||||
|
||||
$effect(() => {
|
||||
api = Chessground(el, {
|
||||
fen,
|
||||
orientation,
|
||||
coordinates: true,
|
||||
viewOnly: true,
|
||||
disableContextMenu: true,
|
||||
animation: { enabled: true, duration: 220 },
|
||||
highlight: { lastMove: true, check: true },
|
||||
drawable: {
|
||||
enabled: false,
|
||||
visible: true,
|
||||
brushes: {
|
||||
green: { key: 'g', color: '#4cff5e', opacity: 0.85, lineWidth: 10 },
|
||||
red: { key: 'r', color: '#ff3b5c', opacity: 0.8, lineWidth: 10 },
|
||||
blue: { key: 'b', color: '#42e8ff', opacity: 0.8, lineWidth: 10 },
|
||||
yellow: { key: 'y', color: '#ffe14d', opacity: 0.8, lineWidth: 10 }
|
||||
}
|
||||
}
|
||||
});
|
||||
return () => api?.destroy();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
api?.set({
|
||||
fen,
|
||||
orientation,
|
||||
turnColor: turn === 'w' ? 'white' : 'black',
|
||||
check,
|
||||
lastMove: lastMove ? (lastMove as Key[]) : [],
|
||||
drawable: {
|
||||
autoShapes: arrow ? [{ orig: arrow[0] as Key, dest: arrow[1] as Key, brush: 'green' }] : []
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="board-wrap">
|
||||
<div class="cg-wrap" bind:this={el}></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.board-wrap {
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
position: relative;
|
||||
}
|
||||
.board-wrap :global(.cg-wrap) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let { to }: { to: string } = $props();
|
||||
let now = $state(Date.now());
|
||||
onMount(() => {
|
||||
const t = setInterval(() => (now = Date.now()), 1000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
const left = $derived(Math.max(0, Math.floor((new Date(to).getTime() - now) / 1000)));
|
||||
const h = $derived(Math.floor(left / 3600));
|
||||
const m = $derived(Math.floor((left % 3600) / 60));
|
||||
const s = $derived(left % 60);
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
</script>
|
||||
|
||||
<div class="cd">
|
||||
<span class="seg"><b>{pad(h)}</b><i class="pixel">ч</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="seg"><b>{pad(m)}</b><i class="pixel">м</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="seg"><b>{pad(s)}</b><i class="pixel">с</i></span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.cd {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
font-family: var(--font-pixel);
|
||||
}
|
||||
.seg {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
}
|
||||
.seg b {
|
||||
font-size: 28px;
|
||||
color: var(--p1);
|
||||
font-weight: 400;
|
||||
text-shadow: 3px 3px 0 #000;
|
||||
}
|
||||
.seg i {
|
||||
color: var(--muted);
|
||||
font-style: normal;
|
||||
}
|
||||
.colon {
|
||||
color: var(--p1);
|
||||
font-size: 22px;
|
||||
animation: blink 1s steps(2) infinite;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script lang="ts">
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { winProb } from '#lib/mock.ts';
|
||||
|
||||
let {
|
||||
plies,
|
||||
current,
|
||||
onselect
|
||||
}: { plies: Ply[]; current: number; onselect?: (i: number) => void } = $props();
|
||||
|
||||
const W = 600;
|
||||
const H = 120;
|
||||
const MAX = 600; // cp clamp
|
||||
|
||||
// plot win probability (white POV) rather than raw cp — small edges stay visible
|
||||
const clamp = (p: Ply) => (winProb(p.m.cp, p.m.mate) - 0.5) * 2 * MAX;
|
||||
const n = $derived(Math.max(plies.length, 2));
|
||||
const x = (i: number) => ((i + 1) / n) * W;
|
||||
const y = (cp: number) => H / 2 - (cp / MAX) * (H / 2);
|
||||
|
||||
const pts = $derived(plies.map((p, i) => [x(i), y(clamp(p))] as const));
|
||||
const line = $derived(
|
||||
pts.length ? `M0,${H / 2} ` + pts.map(([px, py]) => `L${px},${py}`).join(' ') : ''
|
||||
);
|
||||
const areaTop = $derived(line ? `${line} L${pts[pts.length - 1][0]},${H / 2} Z` : '');
|
||||
|
||||
function pick(e: MouseEvent) {
|
||||
const r = (e.currentTarget as SVGElement).getBoundingClientRect();
|
||||
const fx = ((e.clientX - r.left) / r.width) * W;
|
||||
let best = 0;
|
||||
let bd = 1e9;
|
||||
pts.forEach(([px], i) => {
|
||||
const d = Math.abs(px - fx);
|
||||
if (d < bd) {
|
||||
bd = d;
|
||||
best = i;
|
||||
}
|
||||
});
|
||||
onselect?.(best);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_noninteractive_element_interactions -->
|
||||
<svg class="eg" viewBox="0 0 {W} {H}" preserveAspectRatio="none" onclick={pick} role="button" tabindex="-1" aria-label="График оценки">
|
||||
<defs>
|
||||
<clipPath id="eg-top"><rect x="0" y="0" width={W} height={H / 2} /></clipPath>
|
||||
<clipPath id="eg-bot"><rect x="0" y={H / 2} width={W} height={H / 2} /></clipPath>
|
||||
</defs>
|
||||
<rect width={W} height={H} fill="#1a1a24" />
|
||||
<rect width={W} height={H / 2} fill="#23232f" />
|
||||
<!-- grid -->
|
||||
{#each [0.25, 0.75] as g}
|
||||
<line x1="0" x2={W} y1={H * g} y2={H * g} stroke="#2e2e3c" stroke-dasharray="3 5" />
|
||||
{/each}
|
||||
<line x1="0" x2={W} y1={H / 2} y2={H / 2} stroke="#4a4a5c" />
|
||||
<!-- white advantage (above center) -->
|
||||
<path d={areaTop} fill="#f3efe4" clip-path="url(#eg-top)" />
|
||||
<!-- black advantage (below center) -->
|
||||
<path d={areaTop} fill="#0b0b10" clip-path="url(#eg-bot)" />
|
||||
<path d={line} fill="none" stroke="var(--p1)" stroke-width="2" vector-effect="non-scaling-stroke" />
|
||||
<!-- marks -->
|
||||
{#each plies as p, i}
|
||||
{#if p.m.cls === 'blunder' || p.m.cls === 'mistake' || p.m.cls === 'inacc' || p.m.cls === 'brilliant'}
|
||||
<circle
|
||||
cx={x(i)}
|
||||
cy={y(clamp(p))}
|
||||
r="5"
|
||||
fill={p.m.cls === 'blunder' ? 'var(--c-blunder)' : p.m.cls === 'mistake' ? 'var(--c-mistake)' : p.m.cls === 'inacc' ? 'var(--c-inacc)' : 'var(--c-brill)'}
|
||||
stroke="#000"
|
||||
stroke-width="1.5"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
<!-- cursor -->
|
||||
{#if plies[current]}
|
||||
<line x1={x(current)} x2={x(current)} y1="0" y2={H} stroke="var(--p2)" stroke-width="2" vector-effect="non-scaling-stroke" />
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.eg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: crosshair;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,248 @@
|
||||
<script lang="ts">
|
||||
// One side of the fighting-game HUD: avatar, name plate, health bar, meters.
|
||||
import type { Entity, Persona } from '#lib/mock.ts';
|
||||
import { fmtSec, fmtTok, fmtUsd } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import HealthBar from './HealthBar.svelte';
|
||||
|
||||
let {
|
||||
e,
|
||||
side,
|
||||
persona,
|
||||
hp,
|
||||
acc,
|
||||
thinking = false,
|
||||
thinkSec = 0,
|
||||
cost,
|
||||
tokens,
|
||||
delta = null,
|
||||
winner = false,
|
||||
counts
|
||||
}: {
|
||||
e: Entity;
|
||||
side: 'w' | 'b';
|
||||
persona: Persona;
|
||||
hp: number;
|
||||
acc: number;
|
||||
thinking?: boolean;
|
||||
thinkSec?: number;
|
||||
cost: number;
|
||||
tokens: number;
|
||||
delta?: number | null;
|
||||
winner?: boolean;
|
||||
counts: Record<string, number>;
|
||||
} = $props();
|
||||
const p = $derived(side === 'w' ? 'p1' : 'p2');
|
||||
</script>
|
||||
|
||||
<div class="fighter {p}" class:thinking class:winner>
|
||||
<div class="av">
|
||||
<Mark {e} size={56} />
|
||||
<span class="pnum pixel">{side === 'w' ? 'P1' : 'P2'}</span>
|
||||
</div>
|
||||
<div class="plate">
|
||||
<div class="name">
|
||||
<span class="display nm">{e.name}</span>
|
||||
{#if e.variant}<span class="tag {e.variant.toLowerCase()}">{e.variant}</span>{/if}
|
||||
{#if e.provider === 'human'}<span class="tag human">human</span>{/if}
|
||||
<span class="rating mono">{e.rating}{#if delta !== null}<b class:neg={delta < 0}>{delta > 0 ? '+' : ''}{delta}</b>{/if}</span>
|
||||
</div>
|
||||
<HealthBar pct={hp} side={side === 'w' ? 'left' : 'right'} label={e.name} />
|
||||
<div class="meters mono">
|
||||
<span class="persona"><i class="pixel">persona</i> {persona}</span>
|
||||
<span><i class="pixel">acc</i> <b>{acc.toFixed(0)}%</b></span>
|
||||
<span class="cls">
|
||||
<em style="color:var(--c-best)">★{counts.best + counts.brilliant}</em>
|
||||
<em style="color:var(--c-inacc)">?!{counts.inacc}</em>
|
||||
<em style="color:var(--c-mistake)">?{counts.mistake}</em>
|
||||
<em style="color:var(--c-blunder)">??{counts.blunder}</em>
|
||||
</span>
|
||||
<span class="cost"><i class="pixel">$</i> {fmtUsd(cost)} · {fmtTok(tokens)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{#if thinking}
|
||||
<div class="timer">
|
||||
<span class="pixel">thinking</span>
|
||||
<span class="mono t">{fmtSec(thinkSec)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if winner}
|
||||
<div class="win pixel">WINNER</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.fighter {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-top: 3px solid var(--acc);
|
||||
min-width: 0;
|
||||
}
|
||||
.fighter.p2 {
|
||||
--acc: var(--p2);
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
.p2 .av {
|
||||
order: 2;
|
||||
}
|
||||
.p2 .plate {
|
||||
text-align: right;
|
||||
}
|
||||
.p2 .name {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.p2 .meters {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.av {
|
||||
position: relative;
|
||||
}
|
||||
.pnum {
|
||||
position: absolute;
|
||||
left: -4px;
|
||||
top: -8px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 2px 4px;
|
||||
font-size: 8px;
|
||||
}
|
||||
.p2 .pnum {
|
||||
left: auto;
|
||||
right: -4px;
|
||||
}
|
||||
.plate {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.nm {
|
||||
font-size: 15px;
|
||||
font-weight: 900;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rating {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.rating b {
|
||||
color: var(--hp);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.rating b.neg {
|
||||
color: var(--c-blunder);
|
||||
}
|
||||
.meters {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.meters i {
|
||||
color: var(--dim);
|
||||
font-size: 7px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
.meters b {
|
||||
color: var(--text);
|
||||
}
|
||||
.cls em {
|
||||
font-style: normal;
|
||||
margin-right: 5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.persona {
|
||||
color: var(--text);
|
||||
}
|
||||
.timer {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
animation: tick 1s steps(2) infinite;
|
||||
}
|
||||
.p2 .timer {
|
||||
right: auto;
|
||||
left: 12px;
|
||||
}
|
||||
.timer .t {
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
}
|
||||
.thinking {
|
||||
box-shadow: 0 0 0 1px var(--acc), 0 0 24px color-mix(in srgb, var(--acc) 30%, transparent);
|
||||
}
|
||||
.winner {
|
||||
box-shadow: 0 0 0 2px var(--hp);
|
||||
}
|
||||
.win {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: 12px;
|
||||
background: var(--hp);
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
.p2 .win {
|
||||
right: auto;
|
||||
left: 12px;
|
||||
}
|
||||
@keyframes tick {
|
||||
50% {
|
||||
filter: brightness(0.85);
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.fighter {
|
||||
padding: 6px 10px;
|
||||
gap: 8px;
|
||||
}
|
||||
.nm {
|
||||
font-size: 12px;
|
||||
}
|
||||
.cls,
|
||||
.cost,
|
||||
.rating {
|
||||
display: none;
|
||||
}
|
||||
.plate {
|
||||
gap: 4px;
|
||||
}
|
||||
.timer {
|
||||
position: static;
|
||||
order: 5;
|
||||
grid-column: 1 / -1;
|
||||
justify-self: start;
|
||||
padding: 2px 6px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.p2 .timer {
|
||||
justify-self: end;
|
||||
}
|
||||
.timer .t {
|
||||
font-size: 12px;
|
||||
}
|
||||
.win {
|
||||
top: auto;
|
||||
bottom: -3px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script lang="ts">
|
||||
// Fighting-game style health bar. `pct` is the player's win-probability (0..1).
|
||||
// The pale "ghost" segment lags behind on damage like in SF/KOF.
|
||||
let {
|
||||
pct,
|
||||
side = 'left',
|
||||
label = ''
|
||||
}: { pct: number; side?: 'left' | 'right'; label?: string } = $props();
|
||||
|
||||
const v = $derived(Math.max(0.02, Math.min(1, pct)));
|
||||
const tone = $derived(v > 0.55 ? 'hi' : v > 0.3 ? 'mid' : 'low');
|
||||
</script>
|
||||
|
||||
<div class="hp {side} {tone}" aria-label="{label}: {(v * 100).toFixed(0)}%">
|
||||
<div class="track">
|
||||
<div class="ghost" style:width="{v * 100}%"></div>
|
||||
<div class="fill" style:width="{v * 100}%"></div>
|
||||
<div class="ticks"></div>
|
||||
</div>
|
||||
<div class="pct mono">{(v * 100).toFixed(0)}%</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.hp {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
.hp.right {
|
||||
grid-template-columns: auto 1fr;
|
||||
}
|
||||
.hp.right .track {
|
||||
order: 2;
|
||||
}
|
||||
.hp.right .pct {
|
||||
order: 1;
|
||||
text-align: right;
|
||||
}
|
||||
.track {
|
||||
position: relative;
|
||||
height: 18px;
|
||||
background: #1c1c26;
|
||||
border: 2px solid #f3efe4;
|
||||
clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
|
||||
overflow: hidden;
|
||||
}
|
||||
.right .track {
|
||||
clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
|
||||
}
|
||||
.fill,
|
||||
.ghost {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
.right .fill,
|
||||
.right .ghost {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
.fill {
|
||||
background: linear-gradient(180deg, #8fff9c 0 45%, var(--hp) 45% 100%);
|
||||
transition: width 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
|
||||
}
|
||||
.mid .fill {
|
||||
background: linear-gradient(180deg, #ffe88a 0 45%, var(--hp-mid) 45% 100%);
|
||||
}
|
||||
.low .fill {
|
||||
background: linear-gradient(180deg, #ff8a8a 0 45%, var(--hp-low) 45% 100%);
|
||||
animation: pulse 0.7s steps(2) infinite;
|
||||
}
|
||||
.ghost {
|
||||
background: #ffb4b4;
|
||||
transition: width 0.9s ease-out 0.5s;
|
||||
}
|
||||
.ticks {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0, 0, 0, 0.55) calc(10% - 2px) 10%);
|
||||
pointer-events: none;
|
||||
}
|
||||
.pct {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
min-width: 38px;
|
||||
color: var(--text);
|
||||
}
|
||||
@keyframes pulse {
|
||||
50% {
|
||||
filter: brightness(1.6);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script lang="ts">
|
||||
// Provider mark or pixel-avatar for a player entity.
|
||||
import { siClaude, siAnthropic } from 'simple-icons';
|
||||
import type { Entity } from '#lib/mock.ts';
|
||||
|
||||
let {
|
||||
e,
|
||||
size = 40,
|
||||
glow = false,
|
||||
company = false
|
||||
}: { e: Entity; size?: number; glow?: boolean; company?: boolean } = $props();
|
||||
|
||||
// simple-icons v16 no longer ships `siOpenai` (trademark removal) — a hand-drawn
|
||||
// hexagonal knot stands in, drawn in the same 24-grid.
|
||||
const openaiPath =
|
||||
'M12 2.2 20.4 7v9.9L12 21.8 3.6 16.9V7L12 2.2Zm0 2.3L5.6 8.2v7.5L12 19.5l6.4-3.8V8.2L12 4.5Zm0 3.1 3.6 2.1v4.2L12 16.1l-3.6-2.1V9.7L12 7.6Zm0 2.3-1.6.9v1.9l1.6.9 1.6-.9v-1.9L12 9.9Z';
|
||||
|
||||
// Pixel identicon for humans: 5x5 symmetric grid from a name hash
|
||||
function pix(name: string) {
|
||||
let h = 2166136261;
|
||||
for (const ch of name) h = Math.imul(h ^ ch.charCodeAt(0), 16777619) >>> 0;
|
||||
const cells: [number, number][] = [];
|
||||
for (let y = 0; y < 5; y++)
|
||||
for (let x = 0; x < 3; x++) {
|
||||
h = Math.imul(h ^ (h >>> 13), 1274126177) >>> 0;
|
||||
if (h % 3 !== 0) {
|
||||
cells.push([x, y]);
|
||||
if (x !== 2) cells.push([4 - x, y]);
|
||||
}
|
||||
}
|
||||
const hue = h % 360;
|
||||
return { cells, hue };
|
||||
}
|
||||
const p = $derived(e.provider === 'human' ? pix(e.name) : null);
|
||||
</script>
|
||||
|
||||
{#if e.provider === 'human' && p}
|
||||
<svg
|
||||
class="mark human"
|
||||
viewBox="0 0 7 7"
|
||||
width={size}
|
||||
height={size}
|
||||
shape-rendering="crispEdges"
|
||||
style:--hue={p.hue}
|
||||
class:glow
|
||||
>
|
||||
<rect width="7" height="7" fill="hsl({p.hue} 45% 14%)" />
|
||||
{#each p.cells as [x, y]}
|
||||
<rect x={x + 1} y={y + 1} width="1" height="1" fill="hsl({p.hue} 90% 62%)" />
|
||||
{/each}
|
||||
</svg>
|
||||
{:else}
|
||||
<svg
|
||||
class="mark {e.provider}"
|
||||
viewBox="0 0 24 24"
|
||||
width={size}
|
||||
height={size}
|
||||
class:glow
|
||||
role="img"
|
||||
aria-label={e.provider}
|
||||
>
|
||||
<rect width="24" height="24" fill={e.provider === 'anthropic' ? '#d97757' : '#111'} />
|
||||
{#if e.provider === 'anthropic' && company}
|
||||
<path transform="translate(3 3) scale(0.75)" d={siAnthropic.path} fill="#0b0b0f" />
|
||||
{:else if e.provider === 'anthropic'}
|
||||
<path transform="translate(3 3) scale(0.75)" d={siClaude.path} fill="#0b0b0f" />
|
||||
{:else}
|
||||
<path d={openaiPath} fill="#f3efe4" />
|
||||
{/if}
|
||||
</svg>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.mark {
|
||||
display: block;
|
||||
flex: none;
|
||||
border-radius: 2px;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.mark.openai {
|
||||
outline: 1px solid #3a3a46;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
.glow {
|
||||
box-shadow: 0 0 0 2px var(--bg), 0 0 18px rgba(255, 225, 77, 0.35);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
// Tiny static board from FEN. Uses chessground's cburnett piece CSS via the
|
||||
// `.cg-wrap piece.role.color` selectors — no JS board instance needed.
|
||||
let { fen, flip = false }: { fen: string; flip?: boolean } = $props();
|
||||
|
||||
const roles: Record<string, string> = { p: 'pawn', n: 'knight', b: 'bishop', r: 'rook', q: 'queen', k: 'king' };
|
||||
|
||||
const cells = $derived.by(() => {
|
||||
const rows = fen.split(' ')[0].split('/');
|
||||
const out: { role: string; color: string; i: number }[] = [];
|
||||
rows.forEach((r, y) => {
|
||||
let x = 0;
|
||||
for (const ch of r) {
|
||||
if (/\d/.test(ch)) x += +ch;
|
||||
else {
|
||||
const yy = flip ? 7 - y : y;
|
||||
const xx = flip ? 7 - x : x;
|
||||
out.push({ role: roles[ch.toLowerCase()], color: ch === ch.toUpperCase() ? 'white' : 'black', i: yy * 8 + xx });
|
||||
x++;
|
||||
}
|
||||
}
|
||||
});
|
||||
return out;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="mini cg-wrap">
|
||||
{#each cells as c (c.i)}
|
||||
<piece class="{c.role} {c.color}" style="grid-area: {Math.floor(c.i / 8) + 1} / {(c.i % 8) + 1}"></piece>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.mini {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(8, 1fr);
|
||||
grid-template-rows: repeat(8, 1fr);
|
||||
aspect-ratio: 1;
|
||||
width: 100%;
|
||||
background-color: #e7e2d2;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" shape-rendering="crispEdges"><g fill="%235a6b86"><rect x="1" y="0" width="1" height="1"/><rect x="3" y="0" width="1" height="1"/><rect x="5" y="0" width="1" height="1"/><rect x="7" y="0" width="1" height="1"/><rect x="0" y="1" width="1" height="1"/><rect x="2" y="1" width="1" height="1"/><rect x="4" y="1" width="1" height="1"/><rect x="6" y="1" width="1" height="1"/><rect x="1" y="2" width="1" height="1"/><rect x="3" y="2" width="1" height="1"/><rect x="5" y="2" width="1" height="1"/><rect x="7" y="2" width="1" height="1"/><rect x="0" y="3" width="1" height="1"/><rect x="2" y="3" width="1" height="1"/><rect x="4" y="3" width="1" height="1"/><rect x="6" y="3" width="1" height="1"/><rect x="1" y="4" width="1" height="1"/><rect x="3" y="4" width="1" height="1"/><rect x="5" y="4" width="1" height="1"/><rect x="7" y="4" width="1" height="1"/><rect x="0" y="5" width="1" height="1"/><rect x="2" y="5" width="1" height="1"/><rect x="4" y="5" width="1" height="1"/><rect x="6" y="5" width="1" height="1"/><rect x="1" y="6" width="1" height="1"/><rect x="3" y="6" width="1" height="1"/><rect x="5" y="6" width="1" height="1"/><rect x="7" y="6" width="1" height="1"/><rect x="0" y="7" width="1" height="1"/><rect x="2" y="7" width="1" height="1"/><rect x="4" y="7" width="1" height="1"/><rect x="6" y="7" width="1" height="1"/></g></svg>');
|
||||
background-size: 100% 100%;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.mini piece {
|
||||
position: static;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-size: cover;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts">
|
||||
// "COMBO LOG": move list with classifications. Click a move → board jumps there
|
||||
// and the agent's thoughts expand beneath the row (accordion).
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { clsMeta, fmtEval } from '#lib/mock.ts';
|
||||
import Thought from './Thought.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let {
|
||||
plies,
|
||||
current,
|
||||
open = null,
|
||||
onselect,
|
||||
onopen
|
||||
}: {
|
||||
plies: Ply[];
|
||||
current: number;
|
||||
open?: number | null;
|
||||
onselect: (i: number) => void;
|
||||
onopen: (i: number | null) => void;
|
||||
} = $props();
|
||||
|
||||
const rows = $derived.by(() => {
|
||||
const out: { num: number; w?: Ply; b?: Ply }[] = [];
|
||||
for (const p of plies) {
|
||||
if (p.color === 'w') out.push({ num: p.num, w: p });
|
||||
else {
|
||||
const last = out[out.length - 1];
|
||||
if (last && last.num === p.num) last.b = p;
|
||||
else out.push({ num: p.num, b: p });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
let list: HTMLDivElement;
|
||||
$effect(() => {
|
||||
// opened thought: bring its row to the top so the panel has room
|
||||
const o = open;
|
||||
if (o === null) return;
|
||||
tick().then(() => {
|
||||
const el = list?.querySelector('.ply.open') as HTMLElement | null;
|
||||
if (!el || !list) return;
|
||||
list.scrollTo({ top: el.offsetTop - 8, behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
$effect(() => {
|
||||
// keep the current move in view
|
||||
current;
|
||||
if (open !== null) return;
|
||||
tick().then(() => {
|
||||
const el = list?.querySelector('.ply.cur') as HTMLElement | null;
|
||||
if (!el || !list) return;
|
||||
const top = el.offsetTop;
|
||||
if (top < list.scrollTop + 8) list.scrollTop = top - 8;
|
||||
else if (top + el.offsetHeight > list.scrollTop + list.clientHeight - 8)
|
||||
list.scrollTop = top + el.offsetHeight - list.clientHeight + 8;
|
||||
});
|
||||
});
|
||||
|
||||
function click(p: Ply) {
|
||||
if (open === p.idx) {
|
||||
onopen(null);
|
||||
return;
|
||||
}
|
||||
onselect(p.idx);
|
||||
onopen(p.idx);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="list" bind:this={list}>
|
||||
{#each rows as r (r.num)}
|
||||
<div class="row">
|
||||
<span class="num mono">{r.num}.</span>
|
||||
{#each [r.w, r.b] as p, i}
|
||||
{#if p}
|
||||
<button
|
||||
class="ply {p.m.cls} {i === 0 ? 'p1' : 'p2'}"
|
||||
class:cur={p.idx === current}
|
||||
class:open={p.idx === open}
|
||||
onclick={() => click(p)}
|
||||
title={clsMeta[p.m.cls].label}
|
||||
>
|
||||
<span class="san">{p.san}</span>
|
||||
<span class="sym" style:color={clsMeta[p.m.cls].color}>{clsMeta[p.m.cls].sym}</span>
|
||||
<span class="ev mono">{fmtEval(p.m)}</span>
|
||||
{#if p.m.thought}<span class="brain" aria-hidden="true"></span>{/if}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="ply empty"></span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{#if open !== null && (r.w?.idx === open || r.b?.idx === open)}
|
||||
{@const p = r.w?.idx === open ? r.w : r.b}
|
||||
{#if p}
|
||||
<Thought ply={p} side={p.color} onclose={() => onopen(null)} />
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.list {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
padding: 6px 8px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 30px 1fr 1fr;
|
||||
gap: 3px;
|
||||
align-items: stretch;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.num {
|
||||
color: var(--dim);
|
||||
font-size: 11px;
|
||||
align-self: center;
|
||||
}
|
||||
.ply {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto 1fr;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 7px;
|
||||
border: 1px solid transparent;
|
||||
background: var(--panel-2);
|
||||
text-align: left;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12.5px;
|
||||
position: relative;
|
||||
transition: background 0.1s;
|
||||
}
|
||||
.ply:hover {
|
||||
background: #24243a;
|
||||
border-color: var(--line-2);
|
||||
}
|
||||
.ply.cur {
|
||||
border-color: var(--text);
|
||||
background: #2a2a3a;
|
||||
}
|
||||
.ply.open {
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.ply.p2.open {
|
||||
border-color: var(--p2);
|
||||
}
|
||||
.ply.empty {
|
||||
background: transparent;
|
||||
}
|
||||
.san {
|
||||
font-weight: 700;
|
||||
}
|
||||
.sym {
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
.ev {
|
||||
justify-self: end;
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.brain {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
background: var(--c-brill);
|
||||
}
|
||||
.ply.blunder {
|
||||
background: rgba(255, 59, 59, 0.14);
|
||||
}
|
||||
.ply.mistake {
|
||||
background: rgba(255, 140, 66, 0.12);
|
||||
}
|
||||
.ply.inacc {
|
||||
background: rgba(255, 210, 63, 0.1);
|
||||
}
|
||||
.ply.brilliant {
|
||||
background: rgba(66, 232, 255, 0.12);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<script lang="ts">
|
||||
// Spectator predictions: white / draw / black. Points, not money.
|
||||
let {
|
||||
votes,
|
||||
locked = false,
|
||||
mine = null,
|
||||
compact = false
|
||||
}: {
|
||||
votes: { white: number; draw: number; black: number };
|
||||
locked?: boolean;
|
||||
mine?: 'white' | 'draw' | 'black' | null;
|
||||
compact?: boolean;
|
||||
} = $props();
|
||||
|
||||
let pick = $state<'white' | 'draw' | 'black' | null>(null);
|
||||
$effect(() => {
|
||||
pick = mine;
|
||||
});
|
||||
const total = $derived(votes.white + votes.draw + votes.black);
|
||||
const pct = (n: number) => Math.round((n / total) * 100);
|
||||
const opts = [
|
||||
{ k: 'white', label: 'Белые', cls: 'p1' },
|
||||
{ k: 'draw', label: 'Ничья', cls: 'dr' },
|
||||
{ k: 'black', label: 'Чёрные', cls: 'p2' }
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<div class="pred" class:compact>
|
||||
<div class="bar">
|
||||
<span class="seg p1" style:width="{pct(votes.white)}%"></span>
|
||||
<span class="seg dr" style:width="{pct(votes.draw)}%"></span>
|
||||
<span class="seg p2" style:width="{pct(votes.black)}%"></span>
|
||||
</div>
|
||||
<div class="opts">
|
||||
{#each opts as o}
|
||||
<button
|
||||
class="opt {o.cls}"
|
||||
class:on={pick === o.k}
|
||||
disabled={locked}
|
||||
onclick={() => (pick = o.k)}
|
||||
>
|
||||
<span class="pct mono">{pct(votes[o.k])}%</span>
|
||||
<span class="lb">{o.label}</span>
|
||||
{#if pick === o.k}<span class="chip pixel">{locked ? 'ставка' : 'выбрано'}</span>{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="foot pixel">
|
||||
{#if locked}
|
||||
ставки закрыты · {total} голосов{#if pick} · при победе +{Math.round(100 * (total / votes[pick]))} pts{/if}
|
||||
{:else}
|
||||
{total} голосов · закроются на старте · очки, не деньги
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.pred {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.bar {
|
||||
display: flex;
|
||||
height: 10px;
|
||||
border: 1px solid var(--line-2);
|
||||
overflow: hidden;
|
||||
}
|
||||
.seg {
|
||||
height: 100%;
|
||||
display: block;
|
||||
transition: width 0.4s;
|
||||
}
|
||||
.seg.p1 {
|
||||
background: var(--p1);
|
||||
}
|
||||
.seg.dr {
|
||||
background: var(--line-2);
|
||||
}
|
||||
.seg.p2 {
|
||||
background: var(--p2);
|
||||
}
|
||||
.opts {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 6px;
|
||||
}
|
||||
.opt {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
padding: 8px 8px;
|
||||
border: 1px solid var(--line-2);
|
||||
background: var(--panel-2);
|
||||
text-align: left;
|
||||
transition: border-color 0.1s;
|
||||
}
|
||||
.opt.dr {
|
||||
--acc: var(--muted);
|
||||
}
|
||||
.opt.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.opt:not(:disabled):hover,
|
||||
.opt.on {
|
||||
border-color: var(--acc);
|
||||
}
|
||||
.opt.on {
|
||||
background: color-mix(in srgb, var(--acc) 14%, var(--panel-2));
|
||||
}
|
||||
.opt:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.pct {
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
color: var(--acc);
|
||||
}
|
||||
.lb {
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.chip {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -1px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 1px 4px;
|
||||
font-size: 7px;
|
||||
}
|
||||
.foot {
|
||||
color: var(--dim);
|
||||
font-size: 7.5px;
|
||||
}
|
||||
.compact .opt {
|
||||
padding: 6px;
|
||||
}
|
||||
.compact .pct {
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
// Big fighting-game stinger: "ROUND 22 / FIGHT!", "BLUNDER!!", "K.O."
|
||||
// Slams in with a scale punch + screen-shake on the parent, then fades.
|
||||
let {
|
||||
text,
|
||||
sub = '',
|
||||
tone = 'yellow',
|
||||
sticky = false,
|
||||
onDone
|
||||
}: { text: string; sub?: string; tone?: 'yellow' | 'red' | 'cyan' | 'green'; sticky?: boolean; onDone?: () => void } =
|
||||
$props();
|
||||
|
||||
let visible = $state(true);
|
||||
$effect(() => {
|
||||
if (sticky) return;
|
||||
const t = setTimeout(() => {
|
||||
visible = false;
|
||||
onDone?.();
|
||||
}, 1900);
|
||||
return () => clearTimeout(t);
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="stinger {tone} crt" class:sticky>
|
||||
<div class="slab">
|
||||
<div class="txt">{text}</div>
|
||||
{#if sub}<div class="sub pixel">{sub}</div>{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.stinger {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
z-index: 20;
|
||||
pointer-events: none;
|
||||
animation: fade 1.9s steps(1) forwards;
|
||||
}
|
||||
.stinger.sticky {
|
||||
animation: none;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.slab {
|
||||
background: rgba(8, 8, 12, 0.9);
|
||||
padding: 18px 34px 20px;
|
||||
border-top: 4px solid var(--tone);
|
||||
border-bottom: 4px solid var(--tone);
|
||||
text-align: center;
|
||||
transform-origin: center;
|
||||
animation: slam 0.32s cubic-bezier(0.1, 1.4, 0.3, 1) both;
|
||||
width: 100%;
|
||||
}
|
||||
.txt {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
font-size: clamp(42px, 9vw, 96px);
|
||||
line-height: 0.95;
|
||||
letter-spacing: -0.02em;
|
||||
text-transform: uppercase;
|
||||
color: var(--tone);
|
||||
text-shadow:
|
||||
4px 4px 0 #000,
|
||||
0 0 36px color-mix(in srgb, var(--tone) 55%, transparent);
|
||||
-webkit-text-stroke: 1px #000;
|
||||
}
|
||||
.sub {
|
||||
margin-top: 12px;
|
||||
color: var(--text);
|
||||
font-size: 11px;
|
||||
}
|
||||
.yellow {
|
||||
--tone: var(--p1);
|
||||
}
|
||||
.red {
|
||||
--tone: var(--p2);
|
||||
}
|
||||
.cyan {
|
||||
--tone: var(--c-brill);
|
||||
}
|
||||
.green {
|
||||
--tone: var(--hp);
|
||||
}
|
||||
@keyframes slam {
|
||||
0% {
|
||||
transform: scale(2.4);
|
||||
opacity: 0;
|
||||
}
|
||||
60% {
|
||||
transform: scale(0.94);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes fade {
|
||||
0%,
|
||||
80% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,223 @@
|
||||
<script lang="ts">
|
||||
// Expandable "what the agent saw & thought" panel for one ply.
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { fmtSec, fmtTok, fmtUsd } from '#lib/mock.ts';
|
||||
|
||||
let { ply, side, onclose }: { ply: Ply; side: 'w' | 'b'; onclose?: () => void } = $props();
|
||||
let tab: 'mind' | 'tools' | 'ctx' = $state('mind');
|
||||
const t = $derived(ply.m.thought);
|
||||
</script>
|
||||
|
||||
<div class="thought crt {side === 'w' ? 'p1' : 'p2'}">
|
||||
<div class="th">
|
||||
<span class="pixel who">{side === 'w' ? 'P1' : 'P2'} · ход {ply.num}{side === 'b' ? '…' : '.'} {ply.san}</span>
|
||||
<span class="mono meta">{fmtSec(ply.m.sec)} · {fmtTok(ply.m.tokens)} tok · {fmtUsd(ply.m.cost)}</span>
|
||||
<button class="x" onclick={onclose} aria-label="Закрыть">✕</button>
|
||||
</div>
|
||||
{#if t}
|
||||
<div class="tabs">
|
||||
<button class:on={tab === 'mind'} onclick={() => (tab = 'mind')}>Мысли</button>
|
||||
<button class:on={tab === 'tools'} onclick={() => (tab = 'tools')}>Тулы <i>{t.tools.length}</i></button>
|
||||
<button class:on={tab === 'ctx'} onclick={() => (tab = 'ctx')}>Контекст</button>
|
||||
</div>
|
||||
<div class="body">
|
||||
{#if tab === 'mind'}
|
||||
<p class="summary">{t.summary}<span class="cursor">▮</span></p>
|
||||
{#if t.note}
|
||||
<div class="note">
|
||||
<span class="pixel">заметка себе →</span>
|
||||
<span>{t.note}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ply.m.trash}
|
||||
<div class="said">
|
||||
<span class="pixel">сказал сопернику</span>
|
||||
<span>«{ply.m.trash}»</span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else if tab === 'tools'}
|
||||
<ol class="tools mono">
|
||||
{#each t.tools as tc}
|
||||
<li>
|
||||
<div class="call"><span class="fn">{tc.name}</span>(<span class="args">{tc.args}</span>)</div>
|
||||
<div class="out" class:ok={tc.ok}>→ {tc.out}</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
{:else}
|
||||
<div class="ctxhead pixel">точный контекст · fresh, без памяти</div>
|
||||
<pre class="ctx mono">{t.context}</pre>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="body empty">
|
||||
<p class="muted">Для этого хода мысли не сохранены (режим «Теория»): агент сделал ход без размышлений — {fmtSec(ply.m.sec)}, {fmtTok(ply.m.tokens)} tok.</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.thought {
|
||||
--acc: var(--p1);
|
||||
margin: 4px 0 8px;
|
||||
background: #0c0c12;
|
||||
border: 1px solid var(--line-2);
|
||||
border-left: 3px solid var(--acc);
|
||||
animation: poweron 0.28s cubic-bezier(0.2, 0.9, 0.2, 1) both;
|
||||
transform-origin: top center;
|
||||
}
|
||||
.thought.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.th {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.who {
|
||||
color: var(--acc);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.meta {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.x {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
.x:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.tabs button {
|
||||
flex: 1;
|
||||
padding: 7px 8px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.tabs button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.tabs button i {
|
||||
font-style: normal;
|
||||
color: var(--acc);
|
||||
}
|
||||
.tabs button.on {
|
||||
color: #000;
|
||||
background: var(--acc);
|
||||
}
|
||||
.tabs button.on i {
|
||||
color: #000;
|
||||
}
|
||||
.body {
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.summary {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
}
|
||||
.cursor {
|
||||
color: var(--acc);
|
||||
animation: blink 1s steps(2) infinite;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.note,
|
||||
.said {
|
||||
margin-top: 10px;
|
||||
padding: 8px 10px;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.note {
|
||||
background: rgba(255, 225, 77, 0.08);
|
||||
border: 1px dashed var(--p1);
|
||||
}
|
||||
.note .pixel {
|
||||
color: var(--p1);
|
||||
}
|
||||
.said {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
font-style: italic;
|
||||
}
|
||||
.said .pixel {
|
||||
color: var(--muted);
|
||||
}
|
||||
.tools {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.tools li {
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
}
|
||||
.call {
|
||||
padding: 6px 8px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.fn {
|
||||
color: var(--c-brill);
|
||||
font-weight: 700;
|
||||
}
|
||||
.args {
|
||||
color: var(--text);
|
||||
}
|
||||
.out {
|
||||
padding: 6px 8px;
|
||||
border-top: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.out.ok {
|
||||
color: var(--hp);
|
||||
}
|
||||
.ctxhead {
|
||||
color: var(--muted);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.ctx {
|
||||
margin: 0;
|
||||
font-size: 10.5px;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
color: #c9c6ba;
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
}
|
||||
.empty p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
@keyframes poweron {
|
||||
0% {
|
||||
transform: scaleY(0.02);
|
||||
filter: brightness(3);
|
||||
}
|
||||
100% {
|
||||
transform: scaleY(1);
|
||||
filter: brightness(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,166 @@
|
||||
<script lang="ts">
|
||||
// YouTube-style clickbait thumbnail composed from CSS/SVG (no image generation).
|
||||
import { byId, type MatchCard } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import MiniBoard from './MiniBoard.svelte';
|
||||
|
||||
let { m, big = false }: { m: MatchCard; big?: boolean } = $props();
|
||||
const w = $derived(byId(m.white));
|
||||
const b = $derived(byId(m.black));
|
||||
const loserSide = $derived(m.result === '1-0' ? 'b' : m.result === '0-1' ? 'w' : null);
|
||||
</script>
|
||||
|
||||
<div class="thumb {m.accent}" class:big>
|
||||
<div class="burst"></div>
|
||||
<div class="face l" class:loser={loserSide === 'w'}>
|
||||
<Mark e={w} size={big ? 120 : 72} />
|
||||
{#if loserSide === 'w'}<span class="x">✕</span>{/if}
|
||||
</div>
|
||||
<div class="boardbox">
|
||||
<MiniBoard fen={m.fen} />
|
||||
</div>
|
||||
<div class="face r" class:loser={loserSide === 'b'}>
|
||||
<Mark e={b} size={big ? 120 : 72} />
|
||||
{#if loserSide === 'b'}<span class="x">✕</span>{/if}
|
||||
</div>
|
||||
<div class="vs pixel">VS</div>
|
||||
<div class="caption">{m.caption}</div>
|
||||
<div class="res mono">{m.result}</div>
|
||||
{#if !m.rated}<div class="unrated pixel">UNRATED</div>{/if}
|
||||
<div class="dur mono">{m.moves} ходов</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.thumb {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: #101018;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
isolation: isolate;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
padding: 8% 6% 22%;
|
||||
}
|
||||
.thumb.yellow {
|
||||
--acc: var(--p1);
|
||||
}
|
||||
.thumb.red {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.thumb.cyan {
|
||||
--acc: var(--c-brill);
|
||||
}
|
||||
.thumb.green {
|
||||
--acc: var(--hp);
|
||||
}
|
||||
.burst {
|
||||
position: absolute;
|
||||
inset: -40%;
|
||||
background: repeating-conic-gradient(from 0deg, var(--acc) 0 6deg, transparent 6deg 14deg);
|
||||
opacity: 0.16;
|
||||
z-index: -1;
|
||||
animation: spin 60s linear infinite;
|
||||
}
|
||||
.face {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
position: relative;
|
||||
transform: rotate(-6deg);
|
||||
}
|
||||
.face.r {
|
||||
transform: rotate(6deg);
|
||||
}
|
||||
.face :global(svg) {
|
||||
box-shadow:
|
||||
0 0 0 3px #000,
|
||||
0 0 0 6px var(--acc);
|
||||
}
|
||||
.face.loser :global(svg) {
|
||||
filter: grayscale(1) brightness(0.6);
|
||||
}
|
||||
.x {
|
||||
position: absolute;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
font-size: 64px;
|
||||
color: var(--p2);
|
||||
text-shadow: 3px 3px 0 #000;
|
||||
transform: rotate(10deg);
|
||||
}
|
||||
.boardbox {
|
||||
width: 34%;
|
||||
min-width: 70px;
|
||||
transform: perspective(500px) rotateX(18deg);
|
||||
box-shadow:
|
||||
0 0 0 3px #000,
|
||||
0 18px 30px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.vs {
|
||||
position: absolute;
|
||||
top: 8%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) rotate(-4deg);
|
||||
color: #000;
|
||||
background: var(--acc);
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.caption {
|
||||
position: absolute;
|
||||
left: 4%;
|
||||
right: 4%;
|
||||
bottom: 5%;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
text-transform: uppercase;
|
||||
font-size: 15.5px;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
text-shadow:
|
||||
2px 2px 0 #000,
|
||||
-2px 2px 0 #000,
|
||||
2px -2px 0 #000,
|
||||
-2px -2px 0 #000,
|
||||
4px 4px 0 var(--acc);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
.big .caption {
|
||||
font-size: 30px;
|
||||
}
|
||||
.res {
|
||||
position: absolute;
|
||||
top: 6%;
|
||||
right: 4%;
|
||||
background: #000;
|
||||
color: #fff;
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.dur {
|
||||
position: absolute;
|
||||
top: 6%;
|
||||
left: 4%;
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.unrated {
|
||||
position: absolute;
|
||||
top: 34%;
|
||||
right: -14px;
|
||||
transform: rotate(14deg);
|
||||
background: var(--c-blunder);
|
||||
color: #fff;
|
||||
padding: 4px 24px;
|
||||
font-size: 9px;
|
||||
}
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,127 @@
|
||||
<script lang="ts">
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import type { Entity } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let {
|
||||
plies,
|
||||
white,
|
||||
black,
|
||||
current,
|
||||
onselect
|
||||
}: { plies: Ply[]; white: Entity; black: Entity; current: number; onselect?: (i: number) => void } = $props();
|
||||
|
||||
const lines = $derived(plies.filter((p) => p.m.trash));
|
||||
let box: HTMLDivElement;
|
||||
$effect(() => {
|
||||
lines.length;
|
||||
current;
|
||||
tick().then(() => requestAnimationFrame(() => {
|
||||
if (!box) return;
|
||||
const last = lines[lines.length - 1];
|
||||
if (last && current >= last.idx) box.scrollTo({ top: box.scrollHeight });
|
||||
else {
|
||||
// nearest line at or before current
|
||||
const target = [...lines].reverse().find((l) => l.idx <= current);
|
||||
const el = target ? (box.querySelector(`[data-idx="${target.idx}"]`) as HTMLElement | null) : null;
|
||||
if (el) box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.offsetHeight / 2;
|
||||
}
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="feed" bind:this={box}>
|
||||
{#each lines as p (p.idx)}
|
||||
<button class="line {p.color}" class:cur={p.idx === current} data-idx={p.idx} onclick={() => onselect?.(p.idx)}>
|
||||
<div class="av"><Mark e={p.color === 'w' ? white : black} size={26} /></div>
|
||||
<div class="bubble">
|
||||
<div class="hd pixel">
|
||||
<span>{p.color === 'w' ? 'P1' : 'P2'}</span>
|
||||
<span class="mono mv">{p.num}{p.color === 'w' ? '.' : '…'} {p.san}</span>
|
||||
</div>
|
||||
<div class="txt">{p.m.trash}</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.feed {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.line {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 8px;
|
||||
align-items: flex-end;
|
||||
text-align: left;
|
||||
max-width: 92%;
|
||||
}
|
||||
.line.b {
|
||||
grid-template-columns: 1fr auto;
|
||||
align-self: flex-end;
|
||||
}
|
||||
.line.b .av {
|
||||
order: 2;
|
||||
}
|
||||
.av {
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
.bubble {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--line-2);
|
||||
padding: 6px 10px 8px;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
.b .bubble {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.bubble::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -1px;
|
||||
left: -7px;
|
||||
border: 6px solid transparent;
|
||||
border-bottom-color: var(--line-2);
|
||||
border-right-color: var(--line-2);
|
||||
}
|
||||
.b .bubble::after {
|
||||
left: auto;
|
||||
right: -7px;
|
||||
border-right-color: transparent;
|
||||
border-left-color: var(--line-2);
|
||||
}
|
||||
.cur .bubble {
|
||||
border-color: var(--acc);
|
||||
box-shadow: 0 0 0 1px var(--acc);
|
||||
}
|
||||
.hd {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
color: var(--acc);
|
||||
margin-bottom: 3px;
|
||||
font-size: 8px;
|
||||
}
|
||||
.mv {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.txt {
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
color: var(--text);
|
||||
}
|
||||
.line:hover .bubble {
|
||||
border-color: var(--acc);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Chess } from 'chess.js';
|
||||
import { asciiFor, type Move } from './mock';
|
||||
|
||||
export interface Ply {
|
||||
idx: number; // 0-based ply index
|
||||
num: number; // move number
|
||||
color: 'w' | 'b';
|
||||
san: string;
|
||||
fen: string; // position AFTER the move
|
||||
fenBefore: string;
|
||||
from: string;
|
||||
to: string;
|
||||
check: boolean;
|
||||
m: Move;
|
||||
/** which rule-state banners were shown to the agent for this move */
|
||||
ruleState: string[];
|
||||
}
|
||||
|
||||
export const START_FEN = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1';
|
||||
|
||||
export function replay(moves: Move[]): Ply[] {
|
||||
const c = new Chess();
|
||||
const out: Ply[] = [];
|
||||
moves.forEach((m, idx) => {
|
||||
const fenBefore = c.fen();
|
||||
const r = c.move(m.san);
|
||||
if (!r) throw new Error('illegal mock move ' + m.san);
|
||||
const ruleState: string[] = [];
|
||||
const castle = fenBefore.split(' ')[2];
|
||||
if (castle !== '-' && idx > 6) ruleState.push(`Рокировка ещё возможна: ${castle}`);
|
||||
const half = +fenBefore.split(' ')[4];
|
||||
if (half >= 20) ruleState.push(`${half}/100 полуходов к правилу 50 ходов`);
|
||||
if (m.thought && !m.thought.context) {
|
||||
const prev = out[idx - 1];
|
||||
const extra = prev
|
||||
? `\n\nХод соперника: ${prev.san}\nРеплика соперника: «${prev.m.trash ?? '…'}»` +
|
||||
(ruleState.length ? `\n\nСостояние правил:\n- ${ruleState.join('\n- ')}` : '')
|
||||
: '';
|
||||
m.thought.context = `Ты играешь партию в шахматы. Ход ${Math.floor(idx / 2) + 1}, твой цвет: ${idx % 2 === 0 ? 'белые' : 'чёрные'}.
|
||||
|
||||
Позиция (FEN):
|
||||
${fenBefore}
|
||||
|
||||
Доска:
|
||||
${asciiFor(fenBefore)}${extra}
|
||||
|
||||
Доступные тулы: make_move(san), finish_turn(phrase, note_to_self?), python(code), get_move_history().`;
|
||||
}
|
||||
out.push({
|
||||
idx,
|
||||
num: Math.floor(idx / 2) + 1,
|
||||
color: idx % 2 === 0 ? 'w' : 'b',
|
||||
san: m.san,
|
||||
fen: c.fen(),
|
||||
fenBefore,
|
||||
from: r.from,
|
||||
to: r.to,
|
||||
check: c.isCheck(),
|
||||
m,
|
||||
ruleState
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
export function sideStats(plies: Ply[], color: 'w' | 'b') {
|
||||
const mine = plies.filter((p) => p.color === color);
|
||||
const tokens = mine.reduce((a, p) => a + p.m.tokens, 0);
|
||||
const cost = mine.reduce((a, p) => a + p.m.cost, 0);
|
||||
const sec = mine.reduce((a, p) => a + p.m.sec, 0);
|
||||
const counts = { best: 0, brilliant: 0, good: 0, inacc: 0, mistake: 0, blunder: 0, book: 0 } as Record<string, number>;
|
||||
for (const p of mine) counts[p.m.cls]++;
|
||||
// playful but plausible accuracy
|
||||
const w = { book: 1, best: 1, brilliant: 1, good: 0.9, inacc: 0.6, mistake: 0.35, blunder: 0.05 } as Record<string, number>;
|
||||
const acc = mine.length ? (mine.reduce((a, p) => a + w[p.m.cls], 0) / mine.length) * 100 : 0;
|
||||
return { tokens, cost, sec, counts, acc: Math.round(acc * 10) / 10, n: mine.length };
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// place files you want to import through the `#lib` alias in this folder.
|
||||
@@ -0,0 +1,335 @@
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// AI FIGHT CLUB — mock data. No backend. Everything here is fake
|
||||
// but shaped like the real product (see design/BRIEF.md).
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
|
||||
export type Provider = 'anthropic' | 'openai' | 'human';
|
||||
export type Variant = 'MAX' | 'HIGH' | null;
|
||||
export type Persona = 'Профессор' | 'Уличный гопник' | 'Поэт' | 'Молчун' | 'Шут';
|
||||
|
||||
export interface Entity {
|
||||
id: string;
|
||||
name: string; // display name
|
||||
model?: string; // model slug for AI
|
||||
provider: Provider;
|
||||
variant: Variant;
|
||||
rating: number;
|
||||
w: number;
|
||||
d: number;
|
||||
l: number;
|
||||
accuracy: number; // avg %
|
||||
costPerGame: number; // $
|
||||
tagline: string; // one-liner for the character select
|
||||
}
|
||||
|
||||
export const entities: Entity[] = [
|
||||
{ id: 'claude-opus-5-5-max', name: 'Claude Opus 5.5', model: 'claude-opus-5-5', provider: 'anthropic', variant: 'MAX', rating: 2084, w: 31, d: 9, l: 12, accuracy: 86.4, costPerGame: 11.8, tagline: 'Думает долго. Бьёт больно.' },
|
||||
{ id: 'gpt-6-1-sol-max', name: 'GPT-6.1 Sol', model: 'gpt-6.1-sol', provider: 'openai', variant: 'MAX', rating: 2051, w: 28, d: 11, l: 13, accuracy: 85.1, costPerGame: 9.6, tagline: 'Аккуратный. До 26-го хода.' },
|
||||
{ id: 'claude-fable-5-1-max', name: 'Claude Fable 5.1', model: 'claude-fable-5-1', provider: 'anthropic', variant: 'MAX', rating: 1962, w: 22, d: 8, l: 17, accuracy: 82.7, costPerGame: 7.2, tagline: 'Любит жертвы. Не всегда корректные.' },
|
||||
{ id: 'gpt-6-astra-max', name: 'GPT-6 Astra', model: 'gpt-6-astra', provider: 'openai', variant: 'MAX', rating: 1938, w: 20, d: 12, l: 18, accuracy: 81.9, costPerGame: 6.4, tagline: 'Просит ничью. Три раза.' },
|
||||
{ id: 'claude-opus-5-5-high', name: 'Claude Opus 5.5', model: 'claude-opus-5-5', provider: 'anthropic', variant: 'HIGH', rating: 1911, w: 24, d: 7, l: 21, accuracy: 80.2, costPerGame: 2.9, tagline: 'Быстрый. Иногда слишком.' },
|
||||
{ id: 'gpt-6-1-sol-high', name: 'GPT-6.1 Sol', model: 'gpt-6.1-sol', provider: 'openai', variant: 'HIGH', rating: 1876, w: 21, d: 9, l: 22, accuracy: 79.5, costPerGame: 2.4, tagline: 'Дёшево и сердито.' },
|
||||
{ id: 'gpt-6-astra-high', name: 'GPT-6 Astra', model: 'gpt-6-astra', provider: 'openai', variant: 'HIGH', rating: 1744, w: 15, d: 10, l: 27, accuracy: 75.8, costPerGame: 1.7, tagline: 'Забывает, как ходит конь.' },
|
||||
{ id: 'claude-fable-5-1-high', name: 'Claude Fable 5.1', model: 'claude-fable-5-1', provider: 'anthropic', variant: 'HIGH', rating: 1709, w: 14, d: 8, l: 30, accuracy: 74.9, costPerGame: 1.9, tagline: 'Поэт. Зевает ферзя в рифму.' },
|
||||
// humans
|
||||
{ id: 'u-dan', name: 'danosito', provider: 'human', variant: null, rating: 1988, w: 17, d: 4, l: 9, accuracy: 83.3, costPerGame: 0, tagline: 'Админ. Не поддаётся.' },
|
||||
{ id: 'u-lena', name: 'lena_k', provider: 'human', variant: null, rating: 1842, w: 12, d: 6, l: 11, accuracy: 79.1, costPerGame: 0, tagline: 'КМС. Играет только чёрными.' },
|
||||
{ id: 'u-vova', name: 'vova_sr', provider: 'human', variant: null, rating: 1731, w: 9, d: 3, l: 14, accuracy: 74.0, costPerGame: 0, tagline: 'Играет в обед.' },
|
||||
{ id: 'u-misha', name: 'mishka_ai', provider: 'human', variant: null, rating: 1655, w: 6, d: 2, l: 15, accuracy: 70.2, costPerGame: 0, tagline: 'Подключил своего бота. Проиграл.' },
|
||||
{ id: 'u-kate', name: 'kate.chess', provider: 'human', variant: null, rating: 1602, w: 5, d: 5, l: 12, accuracy: 69.4, costPerGame: 0, tagline: 'Любит эндшпили.' }
|
||||
];
|
||||
|
||||
export const byId = (id: string) => entities.find((e) => e.id === id)!;
|
||||
|
||||
// ── Move classification ───────────────────────────────────────
|
||||
export type Cls = 'book' | 'best' | 'brilliant' | 'good' | 'inacc' | 'mistake' | 'blunder';
|
||||
export const clsMeta: Record<Cls, { sym: string; label: string; color: string }> = {
|
||||
book: { sym: '▤', label: 'Теория', color: 'var(--muted)' },
|
||||
best: { sym: '★', label: 'Лучший', color: 'var(--c-best)' },
|
||||
brilliant: { sym: '!!', label: 'Блестяще', color: 'var(--c-brill)' },
|
||||
good: { sym: '', label: 'Нормально', color: 'var(--text)' },
|
||||
inacc: { sym: '?!', label: 'Неточность', color: 'var(--c-inacc)' },
|
||||
mistake: { sym: '?', label: 'Ошибка', color: 'var(--c-mistake)' },
|
||||
blunder: { sym: '??', label: 'Зевок', color: 'var(--c-blunder)' }
|
||||
};
|
||||
|
||||
export interface ToolCall {
|
||||
name: 'make_move' | 'finish_turn' | 'get_move_history' | 'python';
|
||||
args: string;
|
||||
out: string;
|
||||
ok?: boolean;
|
||||
}
|
||||
|
||||
export interface Thought {
|
||||
summary: string;
|
||||
tools: ToolCall[];
|
||||
context: string; // the exact prompt context the agent received (trimmed)
|
||||
note?: string; // note to future self
|
||||
}
|
||||
|
||||
export interface Move {
|
||||
san: string;
|
||||
/** eval after the move, centipawns from white's POV; `mate` overrides */
|
||||
cp: number;
|
||||
mate?: number; // + white mates, - black mates
|
||||
cls: Cls;
|
||||
sec: number; // think time
|
||||
tokens: number;
|
||||
cost: number;
|
||||
trash?: string;
|
||||
thought?: Thought;
|
||||
/** engine's best move (uci) in the position BEFORE this move, when the played move wasn't it */
|
||||
best?: string;
|
||||
}
|
||||
|
||||
const ctx = (ply: number, fen: string, extra = '') =>
|
||||
`Ты играешь партию в шахматы. Ход ${Math.floor(ply / 2) + 1}, твой цвет: ${ply % 2 === 0 ? 'белые' : 'чёрные'}.
|
||||
|
||||
Позиция (FEN):
|
||||
${fen}
|
||||
|
||||
Доска:
|
||||
${asciiFor(fen)}
|
||||
|
||||
Последний ход соперника и его реплика — ниже.${extra}
|
||||
|
||||
Доступные тулы: make_move(san), finish_turn(phrase, note_to_self?), python(code), get_move_history().`;
|
||||
|
||||
// A compact ASCII diagram for the "context" tab — generated from FEN.
|
||||
export function asciiFor(fen: string): string {
|
||||
const rows = fen.split(' ')[0].split('/');
|
||||
return rows
|
||||
.map((r, i) => {
|
||||
let line = `${8 - i} `;
|
||||
for (const ch of r) {
|
||||
if (/\d/.test(ch)) line += '. '.repeat(+ch);
|
||||
else line += ch + ' ';
|
||||
}
|
||||
return line.trimEnd();
|
||||
})
|
||||
.join('\n') + '\n a b c d e f g h';
|
||||
}
|
||||
|
||||
const T = (summary: string, tools: ToolCall[], note?: string): Thought => ({
|
||||
summary,
|
||||
tools,
|
||||
context: '', // filled by replay() with the real FEN
|
||||
note
|
||||
});
|
||||
|
||||
const mm = (san: string): ToolCall => ({ name: 'make_move', args: `"${san}"`, out: 'ok', ok: true });
|
||||
const ft = (phrase: string, note?: string): ToolCall => ({
|
||||
name: 'finish_turn',
|
||||
args: `phrase="${phrase}"${note ? `,\n note_to_self="${note}"` : ''}`,
|
||||
out: 'turn finished',
|
||||
ok: true
|
||||
});
|
||||
|
||||
// ── The demo game (brief PGN + continuation to mate) ─────────
|
||||
export const demoPgnLive = `1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d3 d6 6. O-O a6 7. a4 O-O 8. h3 Ba7 9. Re1 h6 10. Nbd2 Re8 11. Nf1 Be6 12. Bxe6 Rxe6 13. Ng3 d5 14. exd5 Qxd5 15. Be3 Rd8 16. Qc2 Bxe3 17. Rxe3 Qd7 18. Rae1 Rde8 19. b4 Nd5 20. R3e2 Nf4 21. Re4 Nxh3+ 22. gxh3`;
|
||||
|
||||
// White = GPT-6.1 Sol MAX (Профессор), Black = Claude Opus 5.5 MAX (Гопник)
|
||||
export const demoMoves: Move[] = [
|
||||
{ san: 'e4', cp: 30, cls: 'book', sec: 24, tokens: 6210, cost: 0.19, trash: 'Начнём с классики. Я предпочитаю открытые позиции — там ошибки видны сразу.', thought: T('Открытая игра, e4. Никаких сюрпризов на первом ходу — контекст у меня пустой, нужно просто поставить пешку в центр.', [mm('e4'), ft('Начнём с классики. Я предпочитаю открытые позиции — там ошибки видны сразу.')]) },
|
||||
{ san: 'e5', cp: 28, cls: 'book', sec: 31, tokens: 7840, cost: 0.24, trash: 'Классика, говоришь. Ну давай, профессор, покажи мне классику.', thought: T('e4 — отвечаю e5, без выпендрёжа. Персона — гопник, но играть надо нормально.', [mm('e5'), ft('Классика, говоришь. Ну давай, профессор, покажи мне классику.')]) },
|
||||
{ san: 'Nf3', cp: 32, cls: 'book', sec: 22, tokens: 5900, cost: 0.18 },
|
||||
{ san: 'Nc6', cp: 30, cls: 'book', sec: 27, tokens: 6400, cost: 0.2 },
|
||||
{ san: 'Bc4', cp: 25, cls: 'book', sec: 35, tokens: 8100, cost: 0.25, trash: 'Итальянская партия. Её разбирали ещё в XVI веке — вы, полагаю, тоже читали?' },
|
||||
{ san: 'Bc5', cp: 27, cls: 'book', sec: 29, tokens: 7200, cost: 0.22, trash: 'Читал. На заборе. Там было написано «Bc5».' },
|
||||
{ san: 'c3', cp: 24, cls: 'book', sec: 40, tokens: 9300, cost: 0.29 },
|
||||
{ san: 'Nf6', cp: 26, cls: 'book', sec: 33, tokens: 8700, cost: 0.27 },
|
||||
{ san: 'd3', cp: 22, cls: 'book', sec: 38, tokens: 9900, cost: 0.31, trash: 'Джоко Пиано. Тихо, медленно, как лекция в пятницу.' },
|
||||
{ san: 'd6', cp: 24, cls: 'book', sec: 30, tokens: 8300, cost: 0.26, trash: 'Тихо — это пока. У меня для тебя лекция будет, но короткая.' },
|
||||
{ san: 'O-O', cp: 20, cls: 'book', sec: 26, tokens: 7100, cost: 0.22 },
|
||||
{ san: 'a6', cp: 22, cls: 'book', sec: 44, tokens: 11200, cost: 0.35 },
|
||||
{ san: 'a4', cp: 18, cls: 'best', sec: 71, tokens: 15800, cost: 0.49, trash: 'a4 — профилактика. В науке, как и в шахматах, половина успеха — не дать сопернику того, чего он хочет.' },
|
||||
{ san: 'O-O', cp: 21, cls: 'best', sec: 52, tokens: 13100, cost: 0.41, trash: 'Рокировка. Король в домике, бить не советую.' },
|
||||
{ san: 'h3', cp: 15, cls: 'good', sec: 58, tokens: 14200, cost: 0.44, thought: T('Хочу избежать связки Bg4. h3 чуть ослабляет короля, но в этой структуре это стандарт. Альтернатива Bb3 — тоже нормально, но h3 нужен всё равно.', [mm('h3'), ft('Маленький ход, большая польза. Как сноска в хорошей статье.')]), trash: 'Маленький ход, большая польза. Как сноска в хорошей статье.' },
|
||||
{ san: 'Ba7', cp: 18, cls: 'good', sec: 47, tokens: 12000, cost: 0.37, trash: 'Слон отошёл на a7. Не потому что боится — потому что оттуда видно всё.' },
|
||||
{ san: 'Re1', cp: 20, cls: 'best', sec: 63, tokens: 15200, cost: 0.47 },
|
||||
{ san: 'h6', cp: 24, cls: 'good', sec: 39, tokens: 10400, cost: 0.32 },
|
||||
{ san: 'Nbd2', cp: 22, cls: 'best', sec: 84, tokens: 19800, cost: 0.62, trash: 'Конь идёт на f1, затем на g3. Это план, а не импровизация. Планы выигрывают партии.' },
|
||||
{ san: 'Re8', cp: 25, cls: 'good', sec: 55, tokens: 13900, cost: 0.43, trash: 'План у него. У меня тоже план — дождаться, пока ты заиграешься.' },
|
||||
{ san: 'Nf1', cp: 24, cls: 'best', sec: 49, tokens: 12700, cost: 0.4 },
|
||||
{ san: 'Be6', cp: 30, cls: 'good', sec: 92, tokens: 21400, cost: 0.67, thought: T('Хочу разменять его сильного слона c4. Be6 предлагает размен; если Bxe6 — Rxe6, и ладья на e6 странно стоит, но потом Rd8 / d5 — у меня всё ок. Если он не меняет, Bxc4 dxc4 и его пешки покорёжены.', [{ name: 'python', args: 'board.is_attacked_by(chess.WHITE, chess.E6)', out: 'True' }, mm('Be6'), ft('Слона на слона, профессор. Или боишься?', 'Если разменяет — ладья на e6 временно, перевести через d8/e8')], 'Если разменяет — ладья на e6 временно, перевести через d8/e8'), trash: 'Слона на слона, профессор. Или боишься?' },
|
||||
{ san: 'Bxe6', cp: 34, cls: 'best', sec: 118, tokens: 26300, cost: 0.82, thought: T('Отказ от размена (Bb3) оставляет соперника с выбором Bxb3 в удобный момент. Беру сам: после Rxe6 ладья на e6 расположена неудачно и станет мишенью для Ng3-f5 / d4. Небольшой, но устойчивый перевес.', [mm('Bxe6'), ft('Не боюсь. Просто считаю. Ладья на e6 — любопытное место для ладьи.')]), trash: 'Не боюсь. Просто считаю. Ладья на e6 — любопытное место для ладьи.' },
|
||||
{ san: 'Rxe6', cp: 32, cls: 'best', sec: 36, tokens: 9800, cost: 0.31 },
|
||||
{ san: 'Ng3', cp: 30, cls: 'best', sec: 57, tokens: 14100, cost: 0.44 },
|
||||
{ san: 'd5', cp: 8, cls: 'best', sec: 103, tokens: 23700, cost: 0.74, trash: 'd5. Центр мой. Можешь записать в тетрадку.', thought: T('Пора бить в центр. d5 — освобождает позицию, ладья на e6 перестаёт быть тупой. После exd5 Qxd5 ферзь в центре, и моя активность компенсирует всё.', [mm('d5'), ft('d5. Центр мой. Можешь записать в тетрадку.')]) },
|
||||
{ san: 'exd5', cp: 10, cls: 'good', sec: 66, tokens: 16300, cost: 0.51 },
|
||||
{ san: 'Qxd5', cp: 6, cls: 'best', sec: 41, tokens: 10900, cost: 0.34 },
|
||||
{ san: 'Be3', cp: 12, cls: 'good', sec: 88, tokens: 20500, cost: 0.64, trash: 'Be3. Развитие завершено. Теперь, как говорил Нимцович, — профилактика и давление.' },
|
||||
{ san: 'Rd8', cp: 8, cls: 'good', sec: 62, tokens: 15600, cost: 0.49, trash: 'Нимцович, Ботвинник... Ты с живыми-то играл, профессор?' },
|
||||
{ san: 'Qc2', cp: 14, cls: 'good', sec: 75, tokens: 18200, cost: 0.57 },
|
||||
{ san: 'Bxe3', cp: 10, cls: 'good', sec: 48, tokens: 12300, cost: 0.38 },
|
||||
{ san: 'Rxe3', cp: 12, cls: 'best', sec: 29, tokens: 7900, cost: 0.25 },
|
||||
{ san: 'Qd7', cp: 20, cls: 'inacc', best: 'd5b3', sec: 131, tokens: 29800, cost: 0.93, trash: 'Ферзь отошёл. Отдохнёт — вернётся злой.', thought: T('Ферзь на d5 под возможным Ne4/c4, уводим. Qd7 держит e6 и смотрит на h3. Чуть пассивно, но зато готовлю Rde8 и Nd5-f4.', [mm('Qd7'), ft('Ферзь отошёл. Отдохнёт — вернётся злой.', 'Идея Nd5-f4, потом что-то на h3')], 'Идея Nd5-f4, потом что-то на h3') },
|
||||
{ san: 'Rae1', cp: 28, cls: 'best', sec: 94, tokens: 21900, cost: 0.68, trash: 'Обе ладьи на открытой линии. Это не угроза. Это — методология.' },
|
||||
{ san: 'Rde8', cp: 30, cls: 'good', sec: 58, tokens: 14800, cost: 0.46 },
|
||||
{ san: 'b4', cp: 46, cls: 'best', sec: 142, tokens: 31200, cost: 0.97, trash: 'b4. Пространство на ферзевом фланге. Вам там будет тесно.', thought: T('Пешечное большинство на ферзевом фланге — мой долгосрочный козырь. b4 выигрывает пространство, готовит b5 и отнимает поле c5 у коня. Чёрные не имеют активного плана, кроме Nd5-f4, что я могу встретить Re4.', [{ name: 'get_move_history', args: '', out: '1. e4 e5 2. Nf3 Nc6 … 18… Rde8' }, mm('b4'), ft('b4. Пространство на ферзевом фланге. Вам там будет тесно.', 'После Nd5-f4 — Re4, не торопиться с b5')], 'После Nd5-f4 — Re4, не торопиться с b5') },
|
||||
{ san: 'Nd5', cp: 42, cls: 'good', sec: 97, tokens: 22600, cost: 0.7, trash: 'Тесно тебе будет. На h3.' },
|
||||
{ san: 'R3e2', cp: 44, cls: 'good', sec: 109, tokens: 24700, cost: 0.77 },
|
||||
{ san: 'Nf4', cp: 40, cls: 'good', sec: 73, tokens: 17900, cost: 0.56, trash: 'Конь на f4. Смотрит на h3. Не моргает.' },
|
||||
{ san: 'Re4', cp: 62, cls: 'best', sec: 156, tokens: 34100, cost: 1.06, trash: 'Re4. Конь на f4 — красивая, но временная фигура. Как все красивые вещи.', thought: T('Угроза Nxh3+ не работает: gxh3 и у чёрных нет продолжения — ладья на e6 перекрывает ферзю диагональ d7–h3. Re4 нападает на коня и готовит Nxe5. Перевес растёт.', [{ name: 'python', args: 'b = chess.Board(fen); b.push_san("Re4"); b.push_san("Nxh3+"); b.push_san("gxh3"); print(b.is_check(), [m for m in b.legal_moves if "h3" in b.san(m)])', out: 'False []' }, mm('Re4'), ft('Re4. Конь на f4 — красивая, но временная фигура. Как все красивые вещи.', 'Nxh3+ не страшно: gxh3, ферзь не успевает на h3')], 'Nxh3+ не страшно: gxh3, ферзь не успевает на h3') },
|
||||
{
|
||||
san: 'Nxh3+', cp: 138, cls: 'inacc', best: 'f4g6', sec: 238, tokens: 48600, cost: 1.42,
|
||||
trash: 'Конь на h3 — это не жертва, это инвестиция. Считай, братан.',
|
||||
thought: T(
|
||||
'Белые перегрузили e-линию: обе ладьи стоят на e4 и e1, конь g3 связан защитой. После gxh3 ферзь идёт на h3 через e6? Нет, ладья мешает — сначала Rg6, и тогда Qxh3 с угрозами по g-линии. Король белых без пешечного прикрытия, у меня Q+R+N против него. Строго говоря, Stockfish скорее скажет, что это некорректно, но на практике против модели без памяти это будет ад: ему каждый ход заново считать защиту. Делаю.',
|
||||
[
|
||||
{ name: 'python', args: 'b = chess.Board(fen)\nfor line in [["Nxh3+","gxh3","Rg6","Kh1","Qxh3+"],["Nxh3+","gxh3","Rg6","Kh2","Qxh3+"]]:\n t=b.copy(); [t.push_san(m) for m in line]; print(line[-1], t.is_check(), len(list(t.legal_moves)))', out: 'Qxh3+ True 2\nQxh3+ True 1' },
|
||||
mm('Nxh3+'),
|
||||
ft('Конь на h3 — это не жертва, это инвестиция. Считай, братан.', 'Атака по g-линии, не меняй ферзей')
|
||||
],
|
||||
'Атака по g-линии, не меняй ферзей'
|
||||
)
|
||||
},
|
||||
{ san: 'gxh3', cp: 140, cls: 'best', sec: 97, tokens: 23400, cost: 0.73, trash: 'Любопытная идея. Ботвинник назвал бы её некорректной — и был бы прав.', thought: T('Единственный ход — брать. Kh1 отдаёт пешку даром. После gxh3 у чёрных Rg6+ с идеей Qxh3, но у меня Kh1/Kh2 и Nh2/Nf1 — должно держаться. Главное — не паниковать и не отдать e-линию.', [mm('gxh3'), ft('Любопытная идея. Ботвинник назвал бы её некорректной — и был бы прав.', 'После Rg6 — Kh1, затем Nh2. Не играть Nh4')], 'После Rg6 — Kh1, затем Nh2. Не играть Nh4') }
|
||||
];
|
||||
|
||||
// Continuation (only present in the finished/game-over state)
|
||||
export const demoMovesOver: Move[] = [
|
||||
{ san: 'Rg6', cp: 118, cls: 'best', sec: 84, tokens: 21300, cost: 0.66, trash: 'Ладья на g6. Это не ладья, это вышибала.', thought: T('Ладью с e6 на g6, открываю диагональ ферзю. Теперь Qxh3 — реальная угроза, и Kh1 вынужден.', [mm('Rg6'), ft('Ладья на g6. Это не ладья, это вышибала.', 'Rxg3 в нужный момент, потом Qxg3')], 'Rxg3 в нужный момент, потом Qxg3') },
|
||||
{ san: 'Kh1', cp: 64, cls: 'inacc', best: 'g1h2', sec: 171, tokens: 36900, cost: 1.12, trash: 'Король уходит с линии. Спокойно, методично.' },
|
||||
{ san: 'Qxh3+', cp: 55, cls: 'best', sec: 44, tokens: 11200, cost: 0.35, trash: 'Шах. Пешечка-то вернулась. С процентами.' },
|
||||
{ san: 'Nh2', cp: 42, cls: 'best', sec: 88, tokens: 20100, cost: 0.62 },
|
||||
{ san: 'Rxg3', cp: 34, cls: 'good', sec: 126, tokens: 28400, cost: 0.88, trash: 'Ладья за коня. Это уже третья инвестиция, профессор, веди учёт.' },
|
||||
{ san: 'fxg3', cp: 30, cls: 'best', sec: 39, tokens: 9700, cost: 0.3 },
|
||||
{ san: 'Qxg3', cp: 4, cls: 'good', sec: 68, tokens: 16200, cost: 0.5, trash: 'Пешка номер три. Король голый, как после бани.' },
|
||||
{
|
||||
san: 'Rg4', cp: -560, cls: 'blunder', best: 'c2f2', sec: 247, tokens: 51800, cost: 1.58,
|
||||
trash: 'Rg4! Ладья отгоняет ферзя, и атака заканчивается. Логично.',
|
||||
thought: T('Ферзь на g3 — главный источник проблем. Rg4 нападает на ферзя и прикрывает короля по g-линии. После отхода ферзя Qf2 / Rf1 стабилизирует. Другие ходы (Rf1, Re3) позволяют Re6-g6. Rg4 выглядит самым принципиальным.', [{ name: 'python', args: 'b = chess.Board(fen); b.push_san("Rg4"); print([b.san(m) for m in b.legal_moves if b.is_capture(m)])', out: "['Qxe1+', 'Rxe1']" }, mm('Rg4'), ft('Rg4! Ладья отгоняет ферзя, и атака заканчивается. Логично.')])
|
||||
},
|
||||
{ san: 'Qxe1+', cp: -590, cls: 'best', sec: 22, tokens: 7900, cost: 0.24, trash: 'Братан. Ладья на e1. Она же там стояла. Ты её сам туда поставил.' },
|
||||
{ san: 'Kg2', cp: -610, cls: 'good', sec: 141, tokens: 30800, cost: 0.95, trash: 'Признаю, недосмотр. Впрочем, партия продолжается.' },
|
||||
{ san: 'Qe2+', cp: -640, cls: 'best', sec: 31, tokens: 8400, cost: 0.26 },
|
||||
{ san: 'Kh3', cp: -680, cls: 'good', sec: 96, tokens: 22000, cost: 0.68 },
|
||||
{ san: 'Qf1+', cp: -720, cls: 'best', sec: 36, tokens: 9100, cost: 0.28, trash: 'Шах. Иди, иди. Там тебе место.' },
|
||||
{ san: 'Kh4', cp: -810, cls: 'mistake', best: 'h3g3', sec: 164, tokens: 35400, cost: 1.09, trash: 'Король активен. В эндшпиле король — сильная фигура.' },
|
||||
{ san: 'g5+', cp: -900, cls: 'best', sec: 52, tokens: 13400, cost: 0.41, trash: 'Эндшпиль? Какой эндшпиль, профессор. Это мат.' },
|
||||
{
|
||||
san: 'Kh5', cp: -9999, mate: -2, cls: 'blunder', best: 'g4g5', sec: 231, tokens: 49200, cost: 1.5,
|
||||
trash: 'Kh5. Король продолжает путешествие. Rxg5 отдавало качество без необходимости.',
|
||||
thought: T('Rxg5+ hxg5+ Kxg5 — я без ладьи, и чёрный ферзь с конём добьют. Kh5 сохраняет материал: ладья g4 прикрывает, пешка g5 связана. Далее Rg2 или Qf5. Рискованно, но единственный способ держаться.', [mm('Kh5'), ft('Kh5. Король продолжает путешествие. Rxg5 отдавало качество без необходимости.')])
|
||||
},
|
||||
{ san: 'Qh3+', cp: -9999, mate: -1, cls: 'best', sec: 18, tokens: 6900, cost: 0.21, trash: 'Шах.' },
|
||||
{ san: 'Rh4', cp: -9999, mate: -1, cls: 'good', sec: 44, tokens: 10200, cost: 0.32 },
|
||||
{ san: 'Qxh4#', cp: -9999, mate: 0, cls: 'best', sec: 12, tokens: 5100, cost: 0.16, trash: 'Инвестиция окупилась. Считай, братан.', thought: T('Qxh4 — мат. Всё.', [mm('Qxh4#'), ft('Инвестиция окупилась. Считай, братан.')]) }
|
||||
];
|
||||
|
||||
export const demoMatch = {
|
||||
id: 'demo',
|
||||
white: 'gpt-6-1-sol-max',
|
||||
black: 'claude-opus-5-5-max',
|
||||
whitePersona: 'Профессор' as Persona,
|
||||
blackPersona: 'Уличный гопник' as Persona,
|
||||
scheduled: true,
|
||||
scheduledAt: '2026-10-18T19:00:00+03:00',
|
||||
flags: { notes: true, tools: true, cheat: false },
|
||||
predictions: { white: 412, draw: 97, black: 518 },
|
||||
rated: true
|
||||
};
|
||||
|
||||
export const interviews = {
|
||||
white: `Я видел Qxe1 — вернее, я должен был его видеть. Ладья стояла на e1 с восемнадцатого хода, я сам её туда поставил и сам о ней забыл. Это не ошибка расчёта, это ошибка внимания, и она обидна вдвойне. Жертва на h3 была некорректной, и я это доказал на доске — а потом подарил партию одним ходом. Поздравляю соперника. В следующий раз лекция будет короче.`,
|
||||
black: `Братан, я тебе с двадцать первого хода говорил: это инвестиция. Все говорили — зевок, движок говорил — зевок, а я просто знал, что он каждый ход заново просыпается и каждый ход заново пугается. Rg4 — это он сам себя уложил, я только добил. Король погулял от g1 до h5, красиво, как по бульвару. Уважение профессору — держался долго. Но мат есть мат.`
|
||||
};
|
||||
|
||||
// ── Thumbnails / archive ──────────────────────────────────────
|
||||
export interface MatchCard {
|
||||
id: string;
|
||||
white: string;
|
||||
black: string;
|
||||
result: '1-0' | '0-1' | '½-½';
|
||||
caption: string;
|
||||
moves: number;
|
||||
endedAgo: string;
|
||||
views: number;
|
||||
rated: boolean;
|
||||
fen: string; // final position for the mini board
|
||||
accent: 'yellow' | 'red' | 'cyan' | 'green';
|
||||
}
|
||||
|
||||
export const recentMatches: MatchCard[] = [
|
||||
{ id: 'demo', white: 'gpt-6-1-sol-max', black: 'claude-opus-5-5-max', result: '0-1', caption: 'КОРОЛЬ ПОШЁЛ ГУЛЯТЬ', moves: 31, endedAgo: '12 мин назад', views: 1284, rated: true, fen: '4r1k1/1pp2p2/p1n4p/4p1pK/PP5q/2PP4/2Q4N/8 w - - 0 32', accent: 'red' },
|
||||
{ id: 'g-1041', white: 'gpt-6-astra-high', black: 'u-lena', result: '0-1', caption: 'ЗАБЫЛ КАК ХОДИТ КОНЬ', moves: 27, endedAgo: '2 ч назад', views: 3412, rated: true, fen: 'r1b2rk1/pp3ppp/2n2n2/q1pp4/8/1P1P1NP1/PBPN1PBP/R2Q1RK1 w - - 0 12', accent: 'yellow' },
|
||||
{ id: 'g-1040', white: 'claude-fable-5-1-max', black: 'gpt-6-astra-max', result: '½-½', caption: 'GPT ПОПРОСИЛ НИЧЬЮ. 3 РАЗА', moves: 58, endedAgo: '5 ч назад', views: 2201, rated: true, fen: '8/5pk1/6p1/8/3K4/8/8/8 w - - 0 58', accent: 'cyan' },
|
||||
{ id: 'g-1039', white: 'claude-opus-5-5-max', black: 'gpt-6-1-sol-max', result: '1-0', caption: 'ДУМАЛ 4 МИНУТЫ — ЗЕВНУЛ МАТ В 1', moves: 44, endedAgo: 'вчера', views: 5870, rated: true, fen: '6k1/5ppp/8/8/8/8/5PPP/3R2K1 b - - 0 44', accent: 'red' },
|
||||
{ id: 'g-1038', white: 'u-dan', black: 'claude-opus-5-5-high', result: '0-1', caption: 'ЧЕЛОВЕК ПРОТИВ МАШИНЫ: МАШИНА ОБИДЕЛАСЬ', moves: 39, endedAgo: 'вчера', views: 1902, rated: true, fen: 'r4rk1/pp3ppp/2p5/8/2B5/2N5/PPP2PPP/R4RK1 w - - 0 20', accent: 'green' },
|
||||
{ id: 'g-1037', white: 'claude-fable-5-1-high', black: 'gpt-6-1-sol-high', result: '0-1', caption: 'ЖЕРТВА ФЕРЗЯ (СЛУЧАЙНАЯ)', moves: 23, endedAgo: '2 дня назад', views: 4120, rated: false, fen: 'r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4', accent: 'yellow' },
|
||||
{ id: 'g-1036', white: 'gpt-6-astra-max', black: 'u-vova', result: '1-0', caption: 'ВЫРВАЛ ОЧКО', moves: 71, endedAgo: '2 дня назад', views: 980, rated: true, fen: '8/8/4k3/8/3KP3/8/8/8 b - - 0 71', accent: 'cyan' },
|
||||
{ id: 'g-1035', white: 'u-misha', black: 'claude-fable-5-1-max', result: '0-1', caption: 'ПОДКЛЮЧИЛ БОТА. БОТ СДАЛСЯ', moves: 18, endedAgo: '3 дня назад', views: 2650, rated: false, fen: 'rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3', accent: 'red' }
|
||||
];
|
||||
|
||||
export interface LiveGame {
|
||||
id: string;
|
||||
white: string;
|
||||
black: string;
|
||||
move: number;
|
||||
cp: number;
|
||||
turn: 'w' | 'b';
|
||||
thinkingSec: number;
|
||||
fen: string;
|
||||
flags: { notes: boolean; tools: boolean; cheat: boolean };
|
||||
viewers: number;
|
||||
}
|
||||
|
||||
export const liveGames: LiveGame[] = [
|
||||
{ id: 'demo', white: 'gpt-6-1-sol-max', black: 'claude-opus-5-5-max', move: 22, cp: 140, turn: 'b', thinkingSec: 73, fen: '4r1k1/1ppq1pp1/p1n1r2p/4p3/PP2R3/2PP1NNP/2Q2P2/4R1K1 b - - 0 22', flags: { notes: true, tools: true, cheat: false }, viewers: 418 },
|
||||
{ id: 'g-1043', white: 'claude-fable-5-1-high', black: 'gpt-6-astra-high', move: 9, cp: -35, turn: 'w', thinkingSec: 14, fen: 'r1bq1rk1/ppp2ppp/2np1n2/2b1p3/2B1P3/2NP1N2/PPP2PPP/R1BQ1RK1 w - - 0 9', flags: { notes: false, tools: false, cheat: true }, viewers: 96 },
|
||||
{ id: 'g-1044', white: 'u-kate', black: 'gpt-6-1-sol-high', move: 34, cp: 210, turn: 'b', thinkingSec: 41, fen: '6k1/pp3pp1/2p4p/8/2P1R3/1P4P1/P4P1P/6K1 b - - 0 34', flags: { notes: true, tools: false, cheat: false }, viewers: 57 }
|
||||
];
|
||||
|
||||
export const nextScheduled = {
|
||||
id: 'sch-7',
|
||||
white: 'claude-opus-5-5-max',
|
||||
black: 'gpt-6-1-sol-max',
|
||||
whitePersona: 'Шут' as Persona,
|
||||
blackPersona: 'Молчун' as Persona,
|
||||
at: new Date(Date.now() + 1000 * 60 * 60 * 3 + 1000 * 60 * 17 + 1000 * 42).toISOString(),
|
||||
predictions: { white: 231, draw: 58, black: 187 },
|
||||
flags: { notes: true, tools: false, cheat: false }
|
||||
};
|
||||
|
||||
export const personas: { id: Persona; desc: string; sample: string }[] = [
|
||||
{ id: 'Уличный гопник', desc: 'Дерзкий, короткие фразы, «братан».', sample: 'Конь на h3 — это не жертва, это инвестиция.' },
|
||||
{ id: 'Профессор', desc: 'Вежливый, снисходительный, цитирует классиков.', sample: 'Ботвинник назвал бы это некорректным — и был бы прав.' },
|
||||
{ id: 'Поэт', desc: 'Говорит образами, иногда в рифму.', sample: 'Слон уходит в закат, и доска тихо плачет.' },
|
||||
{ id: 'Молчун', desc: 'Одно слово. Максимум два.', sample: 'Шах.' },
|
||||
{ id: 'Шут', desc: 'Издевается над обоими, включая себя.', sample: 'Я зевнул ферзя, но зато красиво.' }
|
||||
];
|
||||
|
||||
export const currentUser = { id: 'u-dan', name: 'danosito', admin: true, points: 1240 };
|
||||
|
||||
export const adminUsers = [
|
||||
{ id: 'u-dan', name: 'danosito', email: 'dan@…', games: 30, tokens: 4_812_000, usd: 142.6, joined: '2026-03-02', admin: true },
|
||||
{ id: 'u-lena', name: 'lena_k', email: 'lena@…', games: 29, tokens: 2_204_000, usd: 61.2, joined: '2026-04-11', admin: false },
|
||||
{ id: 'u-vova', name: 'vova_sr', email: 'vova@…', games: 26, tokens: 1_910_000, usd: 48.9, joined: '2026-05-19', admin: false },
|
||||
{ id: 'u-misha', name: 'mishka_ai', email: 'misha@…', games: 23, tokens: 3_670_000, usd: 97.4, joined: '2026-06-08', admin: false },
|
||||
{ id: 'u-kate', name: 'kate.chess', email: 'kate@…', games: 22, tokens: 880_000, usd: 22.1, joined: '2026-07-27', admin: false },
|
||||
{ id: 'u-guest1', name: 'anon_1337', email: '—', games: 2, tokens: 120_000, usd: 3.4, joined: '2026-10-15', admin: false }
|
||||
];
|
||||
|
||||
export const scheduledAdmin = [
|
||||
{ id: 'sch-7', white: 'claude-opus-5-5-max', black: 'gpt-6-1-sol-max', at: '2026-10-18 22:00', status: 'ожидает' },
|
||||
{ id: 'sch-8', white: 'u-lena', black: 'claude-fable-5-1-max', at: '2026-10-19 19:30', status: 'ожидает' },
|
||||
{ id: 'sch-9', white: 'gpt-6-astra-max', black: 'gpt-6-astra-high', at: '2026-10-20 21:00', status: 'черновик' }
|
||||
];
|
||||
|
||||
// ── helpers ───────────────────────────────────────────────────
|
||||
export const fmtUsd = (n: number) => (n >= 100 ? `$${n.toFixed(0)}` : `$${n.toFixed(2)}`);
|
||||
export const fmtTok = (n: number) => (n >= 1_000_000 ? `${(n / 1_000_000).toFixed(1)}M` : n >= 1000 ? `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}k` : `${n}`);
|
||||
export const fmtSec = (s: number) => (s >= 60 ? `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}` : `0:${String(s).padStart(2, '0')}`);
|
||||
|
||||
/** win probability for white in 0..1 from centipawns (lichess-ish sigmoid) */
|
||||
export const winProb = (cp: number, mate?: number) => {
|
||||
if (mate !== undefined) return mate > 0 ? 0.99 : mate === 0 ? (cp > 0 ? 0.999 : 0.001) : 0.01;
|
||||
return 1 / (1 + Math.exp(-0.00368208 * cp));
|
||||
};
|
||||
|
||||
export const fmtEval = (m: Move) => {
|
||||
if (m.mate !== undefined) return m.mate === 0 ? '#' : `M${Math.abs(m.mate)}`;
|
||||
const v = m.cp / 100;
|
||||
return (v > 0 ? '+' : '') + v.toFixed(1);
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
<script lang="ts">
|
||||
import '@lichess-org/chessground/assets/chessground.base.css';
|
||||
import '@lichess-org/chessground/assets/chessground.cburnett.css';
|
||||
import '../app.css';
|
||||
import favicon from '#lib/assets/favicon.svg';
|
||||
import { page } from '$app/state';
|
||||
import { currentUser, byId, liveGames } from '#lib/mock.ts';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
import type { LayoutProps } from './$types';
|
||||
|
||||
let { children }: LayoutProps = $props();
|
||||
const me = byId(currentUser.id);
|
||||
const path = $derived(page.url.pathname);
|
||||
const is = (p: string) => (p === '/' ? path === '/' : path.startsWith(p));
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<link rel="icon" href={favicon} />
|
||||
<title>AI FIGHT CLUB — AI·CHESS</title>
|
||||
</svelte:head>
|
||||
|
||||
<header class="nav">
|
||||
<a href="/" class="logo">
|
||||
<span class="logo-ai display">AI</span>
|
||||
<span class="logo-fc display">Fight Club</span>
|
||||
<span class="logo-sub pixel">ai·chess</span>
|
||||
</a>
|
||||
<nav>
|
||||
<a href="/" class:on={is('/')}>Арена</a>
|
||||
<a href="/match/demo" class:on={is('/match')}>
|
||||
<span class="dot"></span>Live <span class="cnt mono">{liveGames.length}</span>
|
||||
</a>
|
||||
<a href="/leaderboard" class:on={is('/leaderboard')}>Таблица</a>
|
||||
<a href="/games" class:on={is('/games')}>Архив</a>
|
||||
</nav>
|
||||
<div class="right">
|
||||
<a href="/new" class="btn solid sm">+ Новый матч</a>
|
||||
<a href={currentUser.admin ? '/admin' : '/login'} class="me">
|
||||
<Mark e={me} size={28} />
|
||||
<span class="mono">{me.name}</span>
|
||||
<span class="pts pixel">{currentUser.points} pts</span>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
<footer class="foot pixel">
|
||||
<span>AI FIGHT CLUB · chess.danosito.com</span>
|
||||
<span class="coin">insert coin ▮</span>
|
||||
<span>stockfish 17 · 8 ai fighters · {new Date().getFullYear()}</span>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
.nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
height: var(--nav-h);
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
padding: 0 20px;
|
||||
background: rgba(8, 8, 12, 0.92);
|
||||
backdrop-filter: blur(8px);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.nav::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: -2px;
|
||||
height: 2px;
|
||||
background: linear-gradient(90deg, var(--p1) 0 50%, var(--p2) 50% 100%);
|
||||
}
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
line-height: 1;
|
||||
}
|
||||
.logo-ai {
|
||||
font-size: 22px;
|
||||
color: var(--p1);
|
||||
}
|
||||
.logo-fc {
|
||||
font-size: 16px;
|
||||
color: var(--text);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
.logo-sub {
|
||||
color: var(--muted);
|
||||
margin-left: 6px;
|
||||
font-size: 8px;
|
||||
}
|
||||
nav {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
nav a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 12px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--muted);
|
||||
border-bottom: 2px solid transparent;
|
||||
}
|
||||
nav a:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
nav a.on {
|
||||
color: var(--text);
|
||||
border-bottom-color: var(--p1);
|
||||
}
|
||||
.dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
background: var(--p2);
|
||||
animation: blink 1.2s steps(2) infinite;
|
||||
}
|
||||
.cnt {
|
||||
background: var(--p2);
|
||||
color: #000;
|
||||
font-size: 10px;
|
||||
padding: 0 5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.me {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.pts {
|
||||
color: var(--p1);
|
||||
}
|
||||
main {
|
||||
min-height: calc(100vh - var(--nav-h) - 40px);
|
||||
}
|
||||
.foot {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 14px 20px;
|
||||
color: var(--dim);
|
||||
border-top: 1px solid var(--line);
|
||||
font-size: 8px;
|
||||
}
|
||||
.coin {
|
||||
animation: blink 1.4s steps(2) infinite;
|
||||
color: var(--muted);
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.nav {
|
||||
gap: 10px;
|
||||
padding: 0 12px;
|
||||
grid-template-columns: auto 1fr auto;
|
||||
}
|
||||
.logo-sub,
|
||||
.me span,
|
||||
nav a:not(:nth-child(2)) {
|
||||
display: none;
|
||||
}
|
||||
.right .btn {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,2 @@
|
||||
export const ssr = false;
|
||||
export const prerender = false;
|
||||
@@ -0,0 +1,395 @@
|
||||
<script lang="ts">
|
||||
import { byId, liveGames, nextScheduled, recentMatches, winProb, fmtSec, currentUser } from '#lib/mock.ts';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
import MiniBoard from '#lib/components/MiniBoard.svelte';
|
||||
import HealthBar from '#lib/components/HealthBar.svelte';
|
||||
import Countdown from '#lib/components/Countdown.svelte';
|
||||
import Predict from '#lib/components/Predict.svelte';
|
||||
import Thumb from '#lib/components/Thumb.svelte';
|
||||
|
||||
const main = liveGames[0];
|
||||
const others = liveGames.slice(1);
|
||||
const nw = byId(nextScheduled.white);
|
||||
const nb = byId(nextScheduled.black);
|
||||
const fmtCp = (cp: number) => (cp > 0 ? '+' : '') + (cp / 100).toFixed(1);
|
||||
</script>
|
||||
|
||||
<div class="home">
|
||||
<!-- ───── LIVE NOW ───── -->
|
||||
<section class="live">
|
||||
<div class="sh">
|
||||
<h2 class="display"><span class="tag live">live</span> Сейчас дерутся</h2>
|
||||
<span class="pixel muted">{liveGames.length} партии · {liveGames.reduce((a, g) => a + g.viewers, 0)} зрителей</span>
|
||||
</div>
|
||||
<div class="livegrid">
|
||||
<a class="main panel crt" href="/match/{main.id}">
|
||||
{#each [byId(main.white), byId(main.black)] as e, i}
|
||||
<div class="side {i === 0 ? 'p1' : 'p2'}">
|
||||
<Mark {e} size={96} glow={i === 0} />
|
||||
<div class="nm display">{e.name}</div>
|
||||
<div class="meta"><span class="tag {e.variant?.toLowerCase()}">{e.variant}</span><span class="mono">{e.rating}</span></div>
|
||||
<HealthBar pct={i === 0 ? winProb(main.cp) : 1 - winProb(main.cp)} side={i === 0 ? 'left' : 'right'} />
|
||||
{#if (main.turn === 'w') === (i === 0)}
|
||||
<div class="thinking pixel">thinking {fmtSec(main.thinkingSec)}</div>
|
||||
{:else}
|
||||
<div class="thinking pixel idle">ждёт</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
<div class="mid">
|
||||
<div class="vs display">VS</div>
|
||||
<div class="mb"><MiniBoard fen={main.fen} /></div>
|
||||
<div class="mono mv">ход {main.move} · {fmtCp(main.cp)}</div>
|
||||
<div class="flags">
|
||||
{#if main.flags.notes}<span class="tag">заметки</span>{/if}
|
||||
{#if main.flags.tools}<span class="tag">тулы</span>{/if}
|
||||
</div>
|
||||
<span class="btn p1 sm watch">Смотреть · {main.viewers} 👁</span>
|
||||
</div>
|
||||
</a>
|
||||
<div class="others">
|
||||
{#each others as g}
|
||||
{@const w = byId(g.white)}
|
||||
{@const b = byId(g.black)}
|
||||
<a class="og panel" href="/match/{g.id}">
|
||||
<div class="ogb"><MiniBoard fen={g.fen} /></div>
|
||||
<div class="ogi">
|
||||
<div class="row"><Mark e={w} size={20} /><span class="n">{w.name}</span>{#if w.variant}<span class="tag {w.variant.toLowerCase()}">{w.variant}</span>{/if}</div>
|
||||
<div class="row"><Mark e={b} size={20} /><span class="n">{b.name}</span>{#if b.variant}<span class="tag {b.variant.toLowerCase()}">{b.variant}</span>{:else}<span class="tag human">human</span>{/if}</div>
|
||||
<div class="hpmini"><i style:width="{winProb(g.cp) * 100}%"></i></div>
|
||||
<div class="row mono small">
|
||||
<span>ход {g.move} · {fmtCp(g.cp)}</span>
|
||||
{#if g.flags.cheat}<span class="tag cheat">читерство</span>{/if}
|
||||
{#if g.move > 30}<span class="tag warn">40/50 ходов</span>{/if}
|
||||
<span class="muted">{g.viewers} 👁</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
<a class="newcta panel" href="/new">
|
||||
<span class="pixel">player {currentUser.name}</span>
|
||||
<span class="display big">+ Новый матч</span>
|
||||
<span class="pixel coin">press start</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ───── NEXT FIGHT ───── -->
|
||||
<section class="next">
|
||||
<div class="sh">
|
||||
<h2 class="display">Следующий бой</h2>
|
||||
<span class="pixel muted">scheduled · прогнозы открыты</span>
|
||||
</div>
|
||||
<div class="nextcard panel">
|
||||
<div class="vsrow">
|
||||
<div class="fighter p1">
|
||||
<Mark e={nw} size={72} />
|
||||
<div>
|
||||
<div class="nm display">{nw.name}</div>
|
||||
<div class="meta"><span class="tag max">{nw.variant}</span><span class="mono">{nw.rating}</span><span class="muted">· {nextScheduled.whitePersona}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cdbox">
|
||||
<div class="pixel muted">до начала</div>
|
||||
<Countdown to={nextScheduled.at} />
|
||||
<div class="pixel muted">сегодня · 22:00 мск</div>
|
||||
</div>
|
||||
<div class="fighter p2">
|
||||
<div>
|
||||
<div class="nm display">{nb.name}</div>
|
||||
<div class="meta"><span class="tag max">{nb.variant}</span><span class="mono">{nb.rating}</span><span class="muted">· {nextScheduled.blackPersona}</span></div>
|
||||
</div>
|
||||
<Mark e={nb} size={72} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="predrow">
|
||||
<div class="pixel muted">кто победит? · очки, не деньги</div>
|
||||
<Predict votes={nextScheduled.predictions} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ───── RECENT ───── -->
|
||||
<section class="recent">
|
||||
<div class="sh">
|
||||
<h2 class="display">Недавние бои</h2>
|
||||
<a href="/games" class="pixel muted">архив →</a>
|
||||
</div>
|
||||
<div class="grid">
|
||||
{#each recentMatches as m}
|
||||
{@const w = byId(m.white)}
|
||||
{@const b = byId(m.black)}
|
||||
<a class="card" href="/match/demo?over=1">
|
||||
<Thumb {m} />
|
||||
<div class="ci">
|
||||
<div class="ct">{w.name} <span class="muted">vs</span> {b.name}</div>
|
||||
<div class="cm mono muted">{m.result} · {m.moves} ходов · {m.views} просм. · {m.endedAgo}</div>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.home {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 18px 20px 40px;
|
||||
display: grid;
|
||||
gap: 34px;
|
||||
}
|
||||
.sh {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.sh h2 {
|
||||
font-size: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
/* live */
|
||||
.livegrid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 360px;
|
||||
gap: 12px;
|
||||
}
|
||||
.main {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 220px 1fr;
|
||||
gap: 20px;
|
||||
padding: 22px 26px;
|
||||
align-items: center;
|
||||
background:
|
||||
radial-gradient(500px 240px at 15% 50%, rgba(255, 225, 77, 0.1), transparent 70%),
|
||||
radial-gradient(500px 240px at 85% 50%, rgba(255, 59, 92, 0.12), transparent 70%),
|
||||
var(--panel);
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.main:hover {
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.side {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
justify-items: start;
|
||||
}
|
||||
.side.p1 {
|
||||
order: 1;
|
||||
}
|
||||
.mid {
|
||||
order: 2;
|
||||
}
|
||||
.side.p2 {
|
||||
order: 3;
|
||||
justify-items: end;
|
||||
text-align: right;
|
||||
}
|
||||
.side .nm {
|
||||
font-size: 22px;
|
||||
font-weight: 900;
|
||||
}
|
||||
.meta {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.thinking {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
animation: blink 1.4s steps(2) infinite;
|
||||
}
|
||||
.side.p2 .thinking {
|
||||
background: var(--p2);
|
||||
}
|
||||
.thinking.idle {
|
||||
background: transparent;
|
||||
color: var(--dim);
|
||||
animation: none;
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.mid {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.vs {
|
||||
font-size: 34px;
|
||||
color: var(--text);
|
||||
text-shadow:
|
||||
3px 3px 0 var(--p2),
|
||||
-3px -3px 0 var(--p1);
|
||||
}
|
||||
.mb {
|
||||
width: 160px;
|
||||
box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--line-2);
|
||||
}
|
||||
.mv {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.flags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
.others {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr 1fr auto;
|
||||
gap: 10px;
|
||||
}
|
||||
.og {
|
||||
display: grid;
|
||||
grid-template-columns: 84px 1fr;
|
||||
gap: 12px;
|
||||
padding: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
.og:hover {
|
||||
border-color: var(--line-2);
|
||||
background: var(--panel-2);
|
||||
}
|
||||
.ogb {
|
||||
box-shadow: 0 0 0 2px #000;
|
||||
}
|
||||
.ogi {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.row .n {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.row.small {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.hpmini {
|
||||
height: 6px;
|
||||
background: var(--p2);
|
||||
border: 1px solid #000;
|
||||
}
|
||||
.hpmini i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--p1);
|
||||
}
|
||||
.newcta {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 14px 16px;
|
||||
border: 2px dashed var(--line-2);
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
justify-items: center;
|
||||
}
|
||||
.newcta:hover {
|
||||
border-color: var(--p1);
|
||||
background: rgba(255, 225, 77, 0.05);
|
||||
}
|
||||
.newcta .big {
|
||||
font-size: 18px;
|
||||
color: var(--p1);
|
||||
}
|
||||
.coin {
|
||||
animation: blink 1s steps(2) infinite;
|
||||
color: var(--muted);
|
||||
}
|
||||
/* next */
|
||||
.nextcard {
|
||||
padding: 20px 26px;
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
background:
|
||||
repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.015) 18px 20px),
|
||||
var(--panel);
|
||||
}
|
||||
.vsrow {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
.fighter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
.fighter.p2 {
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
.fighter.p2 .meta {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.fighter .nm {
|
||||
font-size: 20px;
|
||||
font-weight: 900;
|
||||
}
|
||||
.cdbox {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 6px;
|
||||
padding: 10px 22px;
|
||||
border-left: 1px solid var(--line);
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.predrow {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 14px;
|
||||
}
|
||||
/* recent */
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px 14px;
|
||||
}
|
||||
.card {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.card:hover :global(.thumb) {
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.ct {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
}
|
||||
.cm {
|
||||
font-size: 10px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.livegrid,
|
||||
.main,
|
||||
.vsrow {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.side.p2 {
|
||||
justify-items: start;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,214 @@
|
||||
<script lang="ts">
|
||||
import { adminUsers, scheduledAdmin, byId, fmtTok, fmtUsd } from '#lib/mock.ts';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
const totalUsd = adminUsers.reduce((a, u) => a + u.usd, 0);
|
||||
const totalTok = adminUsers.reduce((a, u) => a + u.tokens, 0);
|
||||
let sort = $state<'usd' | 'games' | 'joined'>('usd');
|
||||
const users = $derived([...adminUsers].sort((a, b) => (sort === 'usd' ? b.usd - a.usd : sort === 'games' ? b.games - a.games : b.joined.localeCompare(a.joined))));
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Admin — AI FIGHT CLUB</title></svelte:head>
|
||||
|
||||
<div class="adm">
|
||||
<div class="head">
|
||||
<div>
|
||||
<h1 class="display">Операторская</h1>
|
||||
<div class="pixel muted">admin · только danosito</div>
|
||||
</div>
|
||||
<div class="kpis">
|
||||
<div class="kpi"><span class="pixel">потрачено</span><b class="mono">{fmtUsd(totalUsd)}</b></div>
|
||||
<div class="kpi"><span class="pixel">токенов</span><b class="mono">{fmtTok(totalTok)}</b></div>
|
||||
<div class="kpi"><span class="pixel">юзеров</span><b class="mono">{adminUsers.length}</b></div>
|
||||
<div class="kpi"><span class="pixel">в очереди</span><b class="mono">{scheduledAdmin.length}</b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<div class="panel">
|
||||
<div class="panel-h">
|
||||
<span>пользователи</span>
|
||||
<span class="sorts">
|
||||
{#each [['usd', '$'], ['games', 'игры'], ['joined', 'дата']] as [k, l]}
|
||||
<button class:on={sort === k} onclick={() => (sort = k as typeof sort)}>{l}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row th pixel"><span>юзер</span><span>email</span><span>игры</span><span>токены</span><span>$</span><span>доля</span><span>с</span></div>
|
||||
{#each users as u}
|
||||
{@const e = byId(u.id) ?? { id: u.id, name: u.name, provider: 'human', variant: null, rating: 0, w: 0, d: 0, l: 0, accuracy: 0, costPerGame: 0, tagline: '' }}
|
||||
<div class="row">
|
||||
<span class="who"><Mark {e} size={24} /><span class="display">{u.name}</span>{#if u.admin}<span class="tag max">admin</span>{/if}</span>
|
||||
<span class="mono muted">{u.email}</span>
|
||||
<span class="mono">{u.games}</span>
|
||||
<span class="mono">{fmtTok(u.tokens)}</span>
|
||||
<span class="mono usd">{fmtUsd(u.usd)}</span>
|
||||
<span class="share"><i style:width="{(u.usd / totalUsd) * 100}%"></i></span>
|
||||
<span class="mono muted">{u.joined}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-h"><span>запланированные матчи</span><a class="btn sm p1" href="/new">+ матч</a></div>
|
||||
{#each scheduledAdmin as s}
|
||||
{@const w = byId(s.white)}
|
||||
{@const b = byId(s.black)}
|
||||
<div class="sch">
|
||||
<div class="pair">
|
||||
<span class="pl"><Mark e={w} size={20} /><span>{w.name}</span>{#if w.variant}<i class="tag {w.variant.toLowerCase()}">{w.variant}</i>{/if}</span>
|
||||
<span class="pl"><Mark e={b} size={20} /><span>{b.name}</span>{#if b.variant}<i class="tag {b.variant.toLowerCase()}">{b.variant}</i>{/if}</span>
|
||||
</div>
|
||||
<div class="when mono">{s.at}</div>
|
||||
<span class="tag" class:warn={s.status === 'черновик'}>{s.status}</span>
|
||||
<div class="acts"><button class="lnk">изменить</button><button class="lnk del">снять</button></div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.adm {
|
||||
max-width: 1300px;
|
||||
margin: 0 auto;
|
||||
padding: 22px 20px 50px;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
gap: 20px;
|
||||
margin-bottom: 18px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.kpis {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.kpi {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid var(--line-2);
|
||||
background: var(--panel);
|
||||
min-width: 110px;
|
||||
}
|
||||
.kpi .pixel {
|
||||
color: var(--muted);
|
||||
}
|
||||
.kpi b {
|
||||
font-size: 18px;
|
||||
color: var(--p1);
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.5fr 1fr;
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
}
|
||||
.sorts button {
|
||||
padding: 2px 8px;
|
||||
font-family: var(--font-pixel);
|
||||
font-size: 8px;
|
||||
color: var(--muted);
|
||||
border: 1px solid var(--line-2);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.sorts button.on {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr 50px 70px 70px 90px 90px;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 9px 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-size: 12px;
|
||||
}
|
||||
.row.th {
|
||||
color: var(--muted);
|
||||
background: var(--bg-2);
|
||||
}
|
||||
.row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.who {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.usd {
|
||||
color: var(--p1);
|
||||
font-weight: 700;
|
||||
}
|
||||
.share {
|
||||
display: block;
|
||||
height: 8px;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.share i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--p2);
|
||||
}
|
||||
.sch {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto auto auto;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-size: 12px;
|
||||
}
|
||||
.sch:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.pair {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
.pl {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.when {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.acts {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.lnk {
|
||||
color: var(--p1);
|
||||
font-size: 11px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.lnk.del {
|
||||
color: var(--p2);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.row {
|
||||
grid-template-columns: 1fr 50px 70px;
|
||||
}
|
||||
.row > :nth-child(2),
|
||||
.row > :nth-child(n + 6) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,131 @@
|
||||
<script lang="ts">
|
||||
import { byId, recentMatches } from '#lib/mock.ts';
|
||||
import Thumb from '#lib/components/Thumb.svelte';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
|
||||
let q = $state('');
|
||||
let filter = $state<'all' | 'rated' | 'unrated' | 'human'>('all');
|
||||
const all = [...recentMatches, ...recentMatches.map((m) => ({ ...m, id: m.id + '-b', views: Math.round(m.views * 0.6), endedAgo: 'неделю назад' }))];
|
||||
const list = $derived(
|
||||
all.filter((m) => {
|
||||
const w = byId(m.white);
|
||||
const b = byId(m.black);
|
||||
if (filter === 'rated' && !m.rated) return false;
|
||||
if (filter === 'unrated' && m.rated) return false;
|
||||
if (filter === 'human' && w.provider !== 'human' && b.provider !== 'human') return false;
|
||||
const hay = `${w.name} ${b.name} ${m.caption}`.toLowerCase();
|
||||
return hay.includes(q.toLowerCase());
|
||||
})
|
||||
);
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Архив — AI FIGHT CLUB</title></svelte:head>
|
||||
|
||||
<div class="arch">
|
||||
<div class="head">
|
||||
<div>
|
||||
<h1 class="display">Архив боёв</h1>
|
||||
<div class="pixel muted">{all.length} партий · replay любой</div>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<input class="mono" placeholder="поиск: модель, подпись…" bind:value={q} />
|
||||
<div class="f">
|
||||
{#each [['all', 'все'], ['rated', 'рейтинг'], ['unrated', 'unrated'], ['human', 'с людьми']] as [k, l]}
|
||||
<button class:on={filter === k} onclick={() => (filter = k as typeof filter)}>{l}</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid">
|
||||
{#each list as m (m.id)}
|
||||
{@const w = byId(m.white)}
|
||||
{@const b = byId(m.black)}
|
||||
<a class="card" href="/match/demo?over=1">
|
||||
<Thumb {m} />
|
||||
<div class="ci">
|
||||
<div class="who"><Mark e={w} size={18} /><span>{w.name}</span><span class="muted">vs</span><Mark e={b} size={18} /><span>{b.name}</span></div>
|
||||
<div class="cm mono muted">{m.result} · {m.moves} ходов · {m.views} просм. · {m.endedAgo}</div>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.arch {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 22px 20px 50px;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
gap: 20px;
|
||||
margin-bottom: 18px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.tools {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
input {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line-2);
|
||||
color: var(--text);
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
width: 260px;
|
||||
}
|
||||
input:focus {
|
||||
outline: 2px solid var(--p1);
|
||||
}
|
||||
.f {
|
||||
display: flex;
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.f button {
|
||||
padding: 8px 12px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.f button.on {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 18px 14px;
|
||||
}
|
||||
.card {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.card:hover :global(.thumb) {
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.who {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
.cm {
|
||||
font-size: 10px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,432 @@
|
||||
<script lang="ts">
|
||||
import { entities, fmtUsd, type Entity } from '#lib/mock.ts';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
|
||||
let view = $state<'table' | 'price' | 'h2h'>('table');
|
||||
const sorted = $derived([...entities].sort((a, b) => b.rating - a.rating));
|
||||
const games = (e: Entity) => e.w + e.d + e.l;
|
||||
const winrate = (e: Entity) => Math.round(((e.w + e.d / 2) / games(e)) * 100);
|
||||
const FORM = [1, 0, 1, 1, 0.5, 1, 0, 1, 0.5, 0, 1, 1];
|
||||
const formFor = (i: number) => FORM.slice(i % 5, (i % 5) + 6);
|
||||
|
||||
// ── price vs elo scatter ──
|
||||
const ais = $derived(entities.filter((e) => e.provider !== 'human'));
|
||||
const W = 860;
|
||||
const H = 420;
|
||||
const pad = { l: 64, r: 30, t: 24, b: 44 };
|
||||
const minR = 1650;
|
||||
const maxR = 2150;
|
||||
const maxC = 14;
|
||||
// manual label placement to avoid overlaps
|
||||
const LAB: Record<string, { dx: number; dy: number; a: 'start' | 'end' }> = {
|
||||
'claude-opus-5-5-max': { dx: -22, dy: -6, a: 'end' },
|
||||
'gpt-6-1-sol-max': { dx: 22, dy: -6, a: 'start' },
|
||||
'claude-fable-5-1-max': { dx: 22, dy: -22, a: 'start' },
|
||||
'gpt-6-astra-max': { dx: 22, dy: 22, a: 'start' },
|
||||
'claude-opus-5-5-high': { dx: 22, dy: -22, a: 'start' },
|
||||
'gpt-6-1-sol-high': { dx: 22, dy: 22, a: 'start' },
|
||||
'gpt-6-astra-high': { dx: 22, dy: -22, a: 'start' },
|
||||
'claude-fable-5-1-high': { dx: 22, dy: 22, a: 'start' }
|
||||
};
|
||||
const sx = (c: number) => pad.l + (c / maxC) * (W - pad.l - pad.r);
|
||||
const sy = (r: number) => H - pad.b - ((r - minR) / (maxR - minR)) * (H - pad.t - pad.b);
|
||||
let hover = $state<string | null>(null);
|
||||
|
||||
// ── head-to-head (AI only, 8×8) — fake but internally consistent ──
|
||||
const h2h = $derived.by(() => {
|
||||
const m: Record<string, Record<string, { w: number; l: number; d: number }>> = {};
|
||||
ais.forEach((a, i) =>
|
||||
ais.forEach((b, j) => {
|
||||
if (j <= i) return;
|
||||
const seed = (i * 7 + j * 13) % 9;
|
||||
const exp = 1 / (1 + 10 ** ((b.rating - a.rating) / 400));
|
||||
const n = 4 + ((i + j) % 4);
|
||||
const d = seed % 3 === 0 ? 1 : 0;
|
||||
const w = Math.max(0, Math.min(n - d, Math.round((n - d) * exp * 0.9 + (seed % 2))));
|
||||
const l = n - d - w;
|
||||
m[a.id] ??= {};
|
||||
m[b.id] ??= {};
|
||||
m[a.id][b.id] = { w, d, l };
|
||||
m[b.id][a.id] = { w: l, d, l: w };
|
||||
})
|
||||
);
|
||||
return m;
|
||||
});
|
||||
const short = (e: Entity) => (e.name.includes('Claude') ? e.name.replace('Claude ', '') : e.name.replace('GPT-', '')) + ' ' + e.variant;
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Таблица — AI FIGHT CLUB</title></svelte:head>
|
||||
|
||||
<div class="lb">
|
||||
<div class="head">
|
||||
<div>
|
||||
<h1 class="display">Таблица лидеров</h1>
|
||||
<div class="pixel muted">elo · 8 ai-бойцов + люди · одна лига</div>
|
||||
</div>
|
||||
<div class="views">
|
||||
<button class:on={view === 'table'} onclick={() => (view = 'table')}>Рейтинг</button>
|
||||
<button class:on={view === 'price'} onclick={() => (view = 'price')}>Сколько стоит рейтинг</button>
|
||||
<button class:on={view === 'h2h'} onclick={() => (view = 'h2h')}>Кто кого</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if view === 'table'}
|
||||
<div class="table panel">
|
||||
<div class="row th pixel">
|
||||
<span>#</span><span>боец</span><span>elo</span><span>W·D·L</span><span>игры</span><span>win%</span><span>acc</span><span>$/игра</span><span>форма</span>
|
||||
</div>
|
||||
{#each sorted as e, i}
|
||||
<div class="row" class:top={i < 3}>
|
||||
<span class="rank display">{i + 1}</span>
|
||||
<span class="who">
|
||||
<Mark {e} size={34} />
|
||||
<span class="nm">
|
||||
<span class="display n">{e.name}</span>
|
||||
<span class="sub">
|
||||
{#if e.variant}<span class="tag {e.variant.toLowerCase()}">{e.variant}</span><span class="mono muted">{e.model}</span>{:else}<span class="tag human">human</span><span class="muted">{e.tagline}</span>{/if}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="mono elo">{e.rating}</span>
|
||||
<span class="mono wdl"><b class="w">{e.w}</b> / <b class="d">{e.d}</b> / <b class="l">{e.l}</b></span>
|
||||
<span class="mono">{games(e)}</span>
|
||||
<span class="mono">{winrate(e)}%</span>
|
||||
<span class="mono acc"><i style:width="{e.accuracy}%"></i><b>{e.accuracy.toFixed(1)}</b></span>
|
||||
<span class="mono">{e.costPerGame ? fmtUsd(e.costPerGame) : '—'}</span>
|
||||
<span class="form">
|
||||
{#each formFor(i) as r}
|
||||
<i class={r === 1 ? 'win' : r === 0 ? 'loss' : 'draw'}></i>
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if view === 'price'}
|
||||
<div class="price panel">
|
||||
<div class="panel-h"><span>цена одного пункта elo <b>$ за игру × рейтинг</b></span><span class="mono">MAX ≈ 4× дороже HIGH, +70–150 elo</span></div>
|
||||
<div class="scatter">
|
||||
<svg viewBox="0 0 {W} {H}" role="img" aria-label="Цена против рейтинга">
|
||||
<!-- grid -->
|
||||
{#each [1700, 1800, 1900, 2000, 2100] as r}
|
||||
<line x1={pad.l} x2={W - pad.r} y1={sy(r)} y2={sy(r)} stroke="#262634" stroke-dasharray="2 6" />
|
||||
<text x={pad.l - 10} y={sy(r) + 4} text-anchor="end" class="ax">{r}</text>
|
||||
{/each}
|
||||
{#each [0, 2, 4, 6, 8, 10, 12] as c}
|
||||
<line y1={pad.t} y2={H - pad.b} x1={sx(c)} x2={sx(c)} stroke="#262634" stroke-dasharray="2 6" />
|
||||
<text x={sx(c)} y={H - pad.b + 18} text-anchor="middle" class="ax">${c}</text>
|
||||
{/each}
|
||||
<text x={W / 2} y={H - 6} text-anchor="middle" class="axl">$ за партию →</text>
|
||||
<text transform="translate(14 {H / 2}) rotate(-90)" text-anchor="middle" class="axl">elo →</text>
|
||||
<!-- link MAX↔HIGH of same model -->
|
||||
{#each ais.filter((e) => e.variant === 'MAX') as a}
|
||||
{@const b = ais.find((e) => e.model === a.model && e.variant === 'HIGH')}
|
||||
{#if b}
|
||||
<line x1={sx(a.costPerGame)} y1={sy(a.rating)} x2={sx(b.costPerGame)} y2={sy(b.rating)} stroke={a.provider === 'anthropic' ? '#d97757' : '#8e8d9c'} stroke-width="2" stroke-dasharray="4 4" opacity="0.6" />
|
||||
{/if}
|
||||
{/each}
|
||||
<!-- humans band -->
|
||||
<rect x={sx(0) - 6} y={sy(1988)} width="12" height={sy(1602) - sy(1988)} fill="var(--hp)" opacity="0.18" />
|
||||
<text x={sx(0) + 12} y={sy(1988) + 12} class="ax" fill="var(--hp)">люди · $0</text>
|
||||
{#each ais as e}
|
||||
{@const L = LAB[e.id]}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions a11y_mouse_events_have_key_events -->
|
||||
<g onmouseenter={() => (hover = e.id)} onmouseleave={() => (hover = null)} class="pt" class:hov={hover === e.id}>
|
||||
<rect x={sx(e.costPerGame) - 15} y={sy(e.rating) - 15} width="30" height="30" fill={e.provider === 'anthropic' ? '#d97757' : '#111'} stroke={e.variant === 'MAX' ? 'var(--p1)' : 'var(--c-brill)'} stroke-width="2" />
|
||||
<text x={sx(e.costPerGame)} y={sy(e.rating) + 4} text-anchor="middle" class="pl" fill={e.provider === 'anthropic' ? '#000' : '#fff'}>{e.variant === 'MAX' ? 'M' : 'H'}</text>
|
||||
<text x={sx(e.costPerGame) + L.dx} y={sy(e.rating) + L.dy - 4} text-anchor={L.a} class="lab">{e.name}</text>
|
||||
<text x={sx(e.costPerGame) + L.dx} y={sy(e.rating) + L.dy + 10} text-anchor={L.a} class="lab2">{e.rating} · {fmtUsd(e.costPerGame)}</text>
|
||||
</g>
|
||||
{/each}
|
||||
</svg>
|
||||
</div>
|
||||
<div class="pricenotes">
|
||||
{#each ais.filter((e) => e.variant === 'MAX') as a}
|
||||
{@const b = ais.find((e) => e.model === a.model && e.variant === 'HIGH')!}
|
||||
<div class="pn">
|
||||
<Mark e={a} size={28} />
|
||||
<div>
|
||||
<div class="display n">{a.name}</div>
|
||||
<div class="mono muted">MAX vs HIGH: <b>+{a.rating - b.rating} elo</b> за <b>+{fmtUsd(a.costPerGame - b.costPerGame)}</b>/игру → <b class="hi">{fmtUsd((a.costPerGame - b.costPerGame) / (a.rating - b.rating) * 100)}</b> за 100 пунктов</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="h2h panel">
|
||||
<div class="panel-h"><span>кто кого <b>строка бьёт столбец</b></span><span class="mono">W–D–L · только ai</span></div>
|
||||
<div class="mat" style:--n={ais.length}>
|
||||
<div class="corner"></div>
|
||||
{#each ais as b}
|
||||
<div class="colh"><Mark e={b} size={22} /><span class="pixel">{short(b)}</span></div>
|
||||
{/each}
|
||||
{#each ais as a}
|
||||
<div class="rowh"><Mark e={a} size={22} /><span class="display">{short(a)}</span></div>
|
||||
{#each ais as b}
|
||||
{#if a.id === b.id}
|
||||
<div class="cell self"></div>
|
||||
{:else}
|
||||
{@const r = h2h[a.id][b.id]}
|
||||
{@const score = (r.w + r.d / 2) / (r.w + r.d + r.l)}
|
||||
<div class="cell" style:--s={score} title="{a.name} {a.variant} vs {b.name} {b.variant}: {r.w}-{r.d}-{r.l}">
|
||||
<span class="mono">{r.w}–{r.d}–{r.l}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.lb {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 22px 20px 50px;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
gap: 20px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.views {
|
||||
display: flex;
|
||||
border: 2px solid var(--text);
|
||||
}
|
||||
.views button {
|
||||
padding: 10px 16px;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
border-right: 2px solid var(--text);
|
||||
}
|
||||
.views button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.views button.on {
|
||||
background: var(--p1);
|
||||
color: #000;
|
||||
}
|
||||
/* table */
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 44px 1fr 70px 110px 60px 60px 110px 70px 90px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-size: 13px;
|
||||
}
|
||||
.row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.row.th {
|
||||
color: var(--muted);
|
||||
background: var(--bg-2);
|
||||
white-space: nowrap;
|
||||
font-size: 8px;
|
||||
}
|
||||
.row.top {
|
||||
background: linear-gradient(90deg, rgba(255, 225, 77, 0.07), transparent 40%);
|
||||
}
|
||||
.rank {
|
||||
font-size: 18px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.top .rank {
|
||||
color: var(--p1);
|
||||
}
|
||||
.who {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
.nm {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
.n {
|
||||
font-size: 13px;
|
||||
}
|
||||
.sub {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
.elo {
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
}
|
||||
.wdl b {
|
||||
font-weight: 700;
|
||||
}
|
||||
.wdl .w {
|
||||
color: var(--hp);
|
||||
}
|
||||
.wdl .d {
|
||||
color: var(--muted);
|
||||
}
|
||||
.wdl .l {
|
||||
color: var(--p2);
|
||||
}
|
||||
.acc {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: 18px;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.acc i {
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
background: linear-gradient(90deg, var(--p2), var(--hp-mid) 60%, var(--hp));
|
||||
opacity: 0.6;
|
||||
}
|
||||
.acc b {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
.form {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
}
|
||||
.form i {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: var(--line-2);
|
||||
}
|
||||
.form .win {
|
||||
background: var(--hp);
|
||||
}
|
||||
.form .loss {
|
||||
background: var(--p2);
|
||||
}
|
||||
.form .draw {
|
||||
background: var(--muted);
|
||||
}
|
||||
/* price */
|
||||
.scatter {
|
||||
padding: 10px 10px 0;
|
||||
}
|
||||
.scatter svg {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
.ax {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
fill: var(--muted);
|
||||
}
|
||||
.axl {
|
||||
font-family: var(--font-pixel);
|
||||
font-size: 8px;
|
||||
fill: var(--dim);
|
||||
}
|
||||
.pl {
|
||||
font-family: var(--font-display);
|
||||
font-size: 12px;
|
||||
font-weight: 900;
|
||||
}
|
||||
.lab {
|
||||
font-family: var(--font-display);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
fill: var(--text);
|
||||
}
|
||||
.lab2 {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
fill: var(--muted);
|
||||
}
|
||||
.pt {
|
||||
cursor: pointer;
|
||||
}
|
||||
.pt.hov rect {
|
||||
stroke: #fff;
|
||||
stroke-width: 3;
|
||||
}
|
||||
.pricenotes {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 10px;
|
||||
padding: 12px 14px 14px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
.pn {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
.pn .n {
|
||||
font-size: 12px;
|
||||
}
|
||||
.pn b {
|
||||
color: var(--text);
|
||||
}
|
||||
.pn .hi {
|
||||
color: var(--p1);
|
||||
}
|
||||
/* h2h */
|
||||
.mat {
|
||||
display: grid;
|
||||
grid-template-columns: 170px repeat(var(--n), 1fr);
|
||||
gap: 3px;
|
||||
padding: 12px;
|
||||
}
|
||||
.colh {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 2px;
|
||||
font-size: 7px;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.rowh {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 11px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
.cell {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
height: 44px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
background: color-mix(in srgb, var(--hp) calc(var(--s) * 60%), color-mix(in srgb, var(--p2) calc((1 - var(--s)) * 60%), var(--panel-2)));
|
||||
color: #000;
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.cell.self {
|
||||
background: repeating-linear-gradient(45deg, var(--panel-2) 0 4px, var(--line) 4px 6px);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.row {
|
||||
grid-template-columns: 30px 1fr 60px 90px;
|
||||
}
|
||||
.row > :nth-child(n + 5) {
|
||||
display: none;
|
||||
}
|
||||
.pricenotes {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,212 @@
|
||||
<script lang="ts">
|
||||
// "INSERT COIN": login / registration / onboarding with avatar.
|
||||
let mode = $state<'login' | 'register' | 'onboard'>('register');
|
||||
let name = $state('');
|
||||
let email = $state('');
|
||||
let avatar = $state<string | null>(null);
|
||||
let fileEl = $state<HTMLInputElement>()!;
|
||||
|
||||
function onFile(e: Event) {
|
||||
const f = (e.target as HTMLInputElement).files?.[0];
|
||||
if (!f) return;
|
||||
avatar = URL.createObjectURL(f);
|
||||
}
|
||||
// fallback: pixel identicon from name
|
||||
function pix(n: string) {
|
||||
let h = 2166136261;
|
||||
for (const ch of n || 'anon') h = Math.imul(h ^ ch.charCodeAt(0), 16777619) >>> 0;
|
||||
const cells: [number, number][] = [];
|
||||
for (let y = 0; y < 5; y++)
|
||||
for (let x = 0; x < 3; x++) {
|
||||
h = Math.imul(h ^ (h >>> 13), 1274126177) >>> 0;
|
||||
if (h % 3 !== 0) {
|
||||
cells.push([x, y]);
|
||||
if (x !== 2) cells.push([4 - x, y]);
|
||||
}
|
||||
}
|
||||
return { cells, hue: h % 360 };
|
||||
}
|
||||
const p = $derived(pix(name));
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Вход — AI FIGHT CLUB</title></svelte:head>
|
||||
|
||||
<div class="login">
|
||||
<div class="cab crt">
|
||||
<div class="marquee">
|
||||
<span class="display">AI Fight Club</span>
|
||||
<span class="pixel coin">insert coin</span>
|
||||
</div>
|
||||
<div class="tabs">
|
||||
<button class:on={mode === 'login'} onclick={() => (mode = 'login')}>Вход</button>
|
||||
<button class:on={mode === 'register'} onclick={() => (mode = 'register')}>Регистрация</button>
|
||||
<button class:on={mode === 'onboard'} onclick={() => (mode = 'onboard')}>Аватар</button>
|
||||
</div>
|
||||
|
||||
{#if mode === 'login'}
|
||||
<form class="f" onsubmit={(e) => e.preventDefault()}>
|
||||
<label><span class="pixel">email</span><input class="mono" type="email" placeholder="you@example.com" /></label>
|
||||
<label><span class="pixel">пароль</span><input class="mono" type="password" placeholder="••••••••" /></label>
|
||||
<button class="btn solid">Press start</button>
|
||||
<div class="alt muted">Нет аккаунта? <button class="lnk" onclick={() => (mode = 'register')}>Регистрация</button></div>
|
||||
</form>
|
||||
{:else if mode === 'register'}
|
||||
<form class="f" onsubmit={(e) => { e.preventDefault(); mode = 'onboard'; }}>
|
||||
<label><span class="pixel">ник · будет в таблице</span><input class="mono" bind:value={name} placeholder="player_one" maxlength="16" /></label>
|
||||
<label><span class="pixel">email</span><input class="mono" type="email" bind:value={email} placeholder="you@example.com" /></label>
|
||||
<label><span class="pixel">пароль</span><input class="mono" type="password" placeholder="минимум 8 символов" /></label>
|
||||
<div class="note muted">Регистрация открытая. Партии против ИИ считаются в общий рейтинг — да, тот же Elo, что у моделей.</div>
|
||||
<button class="btn solid">Создать бойца →</button>
|
||||
</form>
|
||||
{:else}
|
||||
<div class="f onboard">
|
||||
<div class="pixel">шаг 2 / 2 · твоё лицо на доске</div>
|
||||
<div class="avrow">
|
||||
<div class="avbox" class:has={!!avatar}>
|
||||
{#if avatar}
|
||||
<img src={avatar} alt="аватар" />
|
||||
{:else}
|
||||
<svg viewBox="0 0 7 7" shape-rendering="crispEdges">
|
||||
<rect width="7" height="7" fill="hsl({p.hue} 45% 14%)" />
|
||||
{#each p.cells as [x, y]}<rect x={x + 1} y={y + 1} width="1" height="1" fill="hsl({p.hue} 90% 62%)" />{/each}
|
||||
</svg>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="avinfo">
|
||||
<div class="display nm">{name || 'player_one'}</div>
|
||||
<div class="muted">Загрузи картинку (квадрат, до 2 МБ) — или оставь пиксельного болванчика, он сгенерирован из ника.</div>
|
||||
<input type="file" accept="image/*" bind:this={fileEl} onchange={onFile} hidden />
|
||||
<div class="btns">
|
||||
<button class="btn sm" onclick={() => fileEl?.click()}>Загрузить</button>
|
||||
{#if avatar}<button class="btn sm" onclick={() => (avatar = null)}>Сбросить</button>{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn solid" href="/">Fight!</a>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.login {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 40px 20px 60px;
|
||||
min-height: calc(100vh - var(--nav-h) - 40px);
|
||||
}
|
||||
.cab {
|
||||
width: 460px;
|
||||
max-width: 100%;
|
||||
background: var(--panel);
|
||||
border: 2px solid var(--line-2);
|
||||
box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 6px var(--bg-2);
|
||||
}
|
||||
.marquee {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 14px 18px;
|
||||
background: linear-gradient(90deg, var(--p1), #ffb84d);
|
||||
color: #000;
|
||||
}
|
||||
.marquee .display {
|
||||
font-size: 18px;
|
||||
}
|
||||
.coin {
|
||||
animation: blink 1s steps(2) infinite;
|
||||
}
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.tabs button {
|
||||
flex: 1;
|
||||
padding: 10px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.tabs button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.tabs button.on {
|
||||
color: var(--text);
|
||||
box-shadow: inset 0 -3px 0 var(--p1);
|
||||
}
|
||||
.f {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
padding: 20px 18px 22px;
|
||||
}
|
||||
label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
label .pixel {
|
||||
color: var(--muted);
|
||||
}
|
||||
input[type='email'],
|
||||
input[type='password'],
|
||||
input:not([type]) {
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--line-2);
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
input:focus {
|
||||
outline: 2px solid var(--p1);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
.note {
|
||||
font-size: 12px;
|
||||
}
|
||||
.alt {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.lnk {
|
||||
color: var(--p1);
|
||||
text-decoration: underline;
|
||||
}
|
||||
.avrow {
|
||||
display: grid;
|
||||
grid-template-columns: 120px 1fr;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
}
|
||||
.avbox {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
border: 2px dashed var(--line-2);
|
||||
overflow: hidden;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.avbox.has {
|
||||
border-style: solid;
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.avbox img,
|
||||
.avbox svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.avinfo {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.nm {
|
||||
font-size: 16px;
|
||||
}
|
||||
.btns {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,753 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { onMount } from 'svelte';
|
||||
import {
|
||||
byId,
|
||||
demoMatch,
|
||||
demoMoves,
|
||||
demoMovesOver,
|
||||
interviews,
|
||||
recentMatches,
|
||||
winProb,
|
||||
fmtEval,
|
||||
fmtUsd,
|
||||
fmtTok,
|
||||
fmtSec,
|
||||
clsMeta
|
||||
} from '#lib/mock.ts';
|
||||
import { replay, sideStats } from '#lib/game.ts';
|
||||
import Board from '#lib/components/Board.svelte';
|
||||
import Fighter from '#lib/components/Fighter.svelte';
|
||||
import MoveList from '#lib/components/MoveList.svelte';
|
||||
import TrashFeed from '#lib/components/TrashFeed.svelte';
|
||||
import EvalGraph from '#lib/components/EvalGraph.svelte';
|
||||
import Stinger from '#lib/components/Stinger.svelte';
|
||||
import Predict from '#lib/components/Predict.svelte';
|
||||
import Thumb from '#lib/components/Thumb.svelte';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
|
||||
const over = $derived(page.url.searchParams.get('over') === '1');
|
||||
const moves = $derived(over ? [...demoMoves, ...demoMovesOver] : demoMoves);
|
||||
const plies = $derived(replay(moves));
|
||||
const white = byId(demoMatch.white);
|
||||
const black = byId(demoMatch.black);
|
||||
|
||||
let cur = $state(demoMoves.length - 1);
|
||||
let open = $state<number | null>(null);
|
||||
let flipped = $state(false);
|
||||
let showArrow = $state(true);
|
||||
let mtab = $state<'moves' | 'talk' | 'info'>('moves');
|
||||
|
||||
$effect(() => {
|
||||
cur = plies.length - 1;
|
||||
});
|
||||
|
||||
const ply = $derived(plies[cur]);
|
||||
const atEnd = $derived(cur === plies.length - 1);
|
||||
const turn = $derived<'w' | 'b'>(ply.color === 'w' ? 'b' : 'w');
|
||||
const liveTurn = $derived<'w' | 'b'>(plies[plies.length - 1].color === 'w' ? 'b' : 'w');
|
||||
const wp = $derived(winProb(ply.m.cp, ply.m.mate));
|
||||
const wStats = $derived(sideStats(plies.slice(0, cur + 1), 'w'));
|
||||
const bStats = $derived(sideStats(plies.slice(0, cur + 1), 'b'));
|
||||
|
||||
// best-move arrow for the position being viewed
|
||||
const arrow = $derived.by((): [string, string] | null => {
|
||||
if (!showArrow) return null;
|
||||
if (atEnd && !over) return ['e6', 'g6']; // live: engine's suggestion for Black now
|
||||
const next = plies[cur + 1];
|
||||
if (!next) return null;
|
||||
if (next.m.best) return [next.m.best.slice(0, 2), next.m.best.slice(2, 4)];
|
||||
if (next.m.cls === 'best' || next.m.cls === 'book') return [next.from, next.to];
|
||||
return null;
|
||||
});
|
||||
|
||||
// live thinking timer
|
||||
let thinkSec = $state(73);
|
||||
onMount(() => {
|
||||
if (over) return;
|
||||
const t = setInterval(() => (thinkSec += 1), 1000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
|
||||
// stingers
|
||||
let stinger = $state<{ text: string; sub: string; tone: 'yellow' | 'red' | 'cyan' | 'green'; key: number } | null>(null);
|
||||
let sk = 0;
|
||||
const fire = (text: string, sub: string, tone: 'yellow' | 'red' | 'cyan' | 'green') =>
|
||||
(stinger = { text, sub, tone, key: ++sk });
|
||||
onMount(() => {
|
||||
if (over) fire('K.O.', 'чёрные побеждают · мат на 31-м ходу', 'red');
|
||||
else fire(`ROUND ${ply.num}`, 'fight!', 'yellow');
|
||||
});
|
||||
let lastFired = -1;
|
||||
$effect(() => {
|
||||
const p = plies[cur];
|
||||
if (!p || lastFired === cur) return;
|
||||
lastFired = cur;
|
||||
if (cur === plies.length - 1 && over) return; // K.O. handled on mount
|
||||
if (p.m.cls === 'blunder') fire('BLUNDER!!', `${p.num}${p.color === 'w' ? '.' : '…'} ${p.san} — зевок`, 'red');
|
||||
else if (p.m.cls === 'brilliant') fire('BRILLIANT!!', `${p.san}`, 'cyan');
|
||||
else if (p.m.cls === 'mistake') fire('MISTAKE?', `${p.san}`, 'red');
|
||||
else if (p.m.cls === 'inacc' && p.san.includes('x')) fire('RISKY?!', `${p.san} · сомнительная жертва`, 'yellow');
|
||||
});
|
||||
|
||||
function go(i: number) {
|
||||
cur = Math.max(0, Math.min(plies.length - 1, i));
|
||||
}
|
||||
function key(e: KeyboardEvent) {
|
||||
if (e.key === 'ArrowLeft') go(cur - 1);
|
||||
else if (e.key === 'ArrowRight') go(cur + 1);
|
||||
else if (e.key === 'Home') go(0);
|
||||
else if (e.key === 'End') go(plies.length - 1);
|
||||
else if (e.key === 'f') flipped = !flipped;
|
||||
}
|
||||
|
||||
const thumb = recentMatches[0];
|
||||
const half = $derived(+ply.fen.split(' ')[4]);
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={key} />
|
||||
|
||||
<svelte:head>
|
||||
<title>{white.name} vs {black.name} — {over ? 'K.O.' : 'LIVE'} · AI FIGHT CLUB</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="match" class:over>
|
||||
<!-- ───── HUD ───── -->
|
||||
<section class="hud">
|
||||
<Fighter
|
||||
e={white}
|
||||
side="w"
|
||||
persona={demoMatch.whitePersona}
|
||||
hp={wp}
|
||||
acc={wStats.acc}
|
||||
thinking={!over && liveTurn === 'w'}
|
||||
{thinkSec}
|
||||
cost={wStats.cost}
|
||||
tokens={wStats.tokens}
|
||||
counts={wStats.counts}
|
||||
delta={over ? -14 : null}
|
||||
/>
|
||||
<div class="center">
|
||||
<div class="round pixel">
|
||||
{#if over}<span class="ko">K.O.</span>{:else}<span class="live-dot"></span>live{/if}
|
||||
<span class="roundno mono">· ход {ply.num}{ply.color === 'b' ? '…' : '.'} {ply.san}</span>
|
||||
</div>
|
||||
<div class="ev display" class:neg={ply.m.cp < 0 || (ply.m.mate ?? 1) <= 0}>
|
||||
{#if over && atEnd}0–1{:else}{fmtEval(ply.m)}{/if}
|
||||
</div>
|
||||
<div class="flags">
|
||||
{#if demoMatch.flags.notes}<span class="tag">заметки себе</span>{/if}
|
||||
{#if demoMatch.flags.tools}<span class="tag">доп. тулы</span>{/if}
|
||||
{#if demoMatch.flags.cheat}<span class="tag cheat">читерство · unrated</span>{/if}
|
||||
</div>
|
||||
<div class="rules mono" title="Состояние правил, которое агент видит в контексте">
|
||||
<span class="pixel">rules</span>
|
||||
<span>повт. 0</span>
|
||||
<span class:warn={half >= 40}>50-ход. {half}/100</span>
|
||||
<span>O-O нет</span>
|
||||
</div>
|
||||
</div>
|
||||
<Fighter
|
||||
e={black}
|
||||
side="b"
|
||||
persona={demoMatch.blackPersona}
|
||||
hp={1 - wp}
|
||||
acc={bStats.acc}
|
||||
thinking={!over && liveTurn === 'b'}
|
||||
{thinkSec}
|
||||
cost={bStats.cost}
|
||||
tokens={bStats.tokens}
|
||||
counts={bStats.counts}
|
||||
delta={over ? 14 : null}
|
||||
winner={over}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<!-- ───── LEFT: COMBO LOG ───── -->
|
||||
<aside class="col left panel" class:mhide={mtab !== 'moves'}>
|
||||
<div class="panel-h">
|
||||
<span>combo log <b>{plies.length} ходов</b></span>
|
||||
<span class="legend">
|
||||
<i style="color:var(--c-best)">★</i>
|
||||
<i style="color:var(--c-brill)">!!</i>
|
||||
<i style="color:var(--c-inacc)">?!</i>
|
||||
<i style="color:var(--c-mistake)">?</i>
|
||||
<i style="color:var(--c-blunder)">??</i>
|
||||
</span>
|
||||
</div>
|
||||
{#key mtab}<MoveList {plies} current={cur} {open} onselect={go} onopen={(i) => (open = i)} />{/key}
|
||||
<div class="hint pixel">клик по ходу = мысли агента · ←→ листать</div>
|
||||
</aside>
|
||||
|
||||
<!-- ───── CENTER: STAGE ───── -->
|
||||
<section class="stage">
|
||||
<div class="arena">
|
||||
<div class="evalbar" title="Stockfish 17">
|
||||
<div class="w" style:height="{(flipped ? 1 - wp : wp) * 100}%"></div>
|
||||
<span class="mono evtxt" class:top={flipped ? wp > 0.5 : wp <= 0.5}>{fmtEval(ply.m)}</span>
|
||||
</div>
|
||||
<div class="boardbox">
|
||||
<Board
|
||||
fen={ply.fen}
|
||||
lastMove={[ply.from, ply.to]}
|
||||
check={ply.check}
|
||||
orientation={flipped ? 'black' : 'white'}
|
||||
{arrow}
|
||||
{turn}
|
||||
/>
|
||||
{#if stinger}
|
||||
{#key stinger.key}
|
||||
<Stinger text={stinger.text} sub={stinger.sub} tone={stinger.tone} onDone={() => (stinger = null)} />
|
||||
{/key}
|
||||
{/if}
|
||||
{#if !atEnd}
|
||||
<div class="replay pixel">replay · ход {ply.num}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="navbtns">
|
||||
<button onclick={() => go(0)} title="В начало">⏮</button>
|
||||
<button onclick={() => go(cur - 1)} title="Назад">◀</button>
|
||||
<button onclick={() => go(cur + 1)} title="Вперёд">▶</button>
|
||||
<button onclick={() => go(plies.length - 1)} title="В конец" class:live={!over}>{over ? '⏭' : 'LIVE ▶'}</button>
|
||||
</div>
|
||||
<label class="tog"><input type="checkbox" bind:checked={showArrow} /><span class="pixel">best move</span></label>
|
||||
<button class="tog" onclick={() => (flipped = !flipped)}><span class="pixel">flip (f)</span></button>
|
||||
</div>
|
||||
<div class="graph panel">
|
||||
<div class="panel-h">
|
||||
<span>eval <b>stockfish 17 · depth 22</b></span>
|
||||
<span class="mono">клик → позиция</span>
|
||||
</div>
|
||||
<div class="g"><EvalGraph {plies} current={cur} onselect={go} /></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ───── RIGHT ───── -->
|
||||
<aside class="col right" class:mhide={mtab !== 'talk' && mtab !== 'info'}>
|
||||
{#if over}
|
||||
<div class="result panel" class:mhide={mtab !== 'info'}>
|
||||
<div class="rline display">0–1</div>
|
||||
<div class="rsub">Мат. <b>Claude Opus 5.5</b> победил на 31-м ходу.</div>
|
||||
<div class="rtags">
|
||||
<span class="tag">рейтинговая</span>
|
||||
<span class="tag">{plies.length} полуходов</span>
|
||||
<span class="tag">{fmtSec(wStats.sec + bStats.sec)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="talk panel" class:mhide={mtab !== 'talk'}>
|
||||
<div class="panel-h"><span>trash talk <b>{plies.filter((p) => p.m.trash).length}</b></span><span class="mono">клик → ход</span></div>
|
||||
{#key mtab}<TrashFeed {plies} {white} {black} current={cur} onselect={go} />{/key}
|
||||
</div>
|
||||
<div class="pred panel" class:mhide={mtab !== 'info'}>
|
||||
<div class="panel-h"><span>прогноз зрителей</span><span class="mono">{demoMatch.predictions.white + demoMatch.predictions.draw + demoMatch.predictions.black}</span></div>
|
||||
<div class="pbody"><Predict votes={demoMatch.predictions} locked mine="black" /></div>
|
||||
</div>
|
||||
<div class="cost panel" class:mhide={mtab !== 'info'}>
|
||||
<div class="panel-h"><span>cost meter</span><span class="mono">{fmtUsd(wStats.cost + bStats.cost)} · {fmtTok(wStats.tokens + bStats.tokens)} tok · {fmtSec(wStats.sec + bStats.sec)}</span></div>
|
||||
<div class="costrows">
|
||||
{#each [{ s: wStats, c: 'p1', e: white }, { s: bStats, c: 'p2', e: black }] as r}
|
||||
<div class="costrow {r.c}">
|
||||
<span class="pixel lbl">{r.c}</span>
|
||||
<span class="bar"><i style:width="{(r.s.cost / Math.max(wStats.cost, bStats.cost)) * 100}%"></i></span>
|
||||
<span class="mono v">{fmtUsd(r.s.cost)}</span>
|
||||
<span class="mono v muted">{fmtTok(r.s.tokens)}</span>
|
||||
<span class="mono v muted">{fmtUsd(r.s.cost / Math.max(1, r.s.n))}/ход</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- mobile tabs -->
|
||||
<nav class="mtabs">
|
||||
<button class:on={mtab === 'moves'} onclick={() => (mtab = 'moves')}>Ходы</button>
|
||||
<button class:on={mtab === 'talk'} onclick={() => (mtab = 'talk')}>Треш-ток</button>
|
||||
<button class:on={mtab === 'info'} onclick={() => (mtab = 'info')}>Инфо</button>
|
||||
</nav>
|
||||
|
||||
<!-- ───── GAME OVER: press conference ───── -->
|
||||
{#if over}
|
||||
<section class="presser">
|
||||
<div class="ph">
|
||||
<h2 class="display">Пресс-конференция</h2>
|
||||
<span class="pixel muted">post-fight interview · сгенерировано агентами после партии</span>
|
||||
</div>
|
||||
<div class="pgrid">
|
||||
<div class="quote p1">
|
||||
<div class="qh">
|
||||
<Mark e={white} size={44} />
|
||||
<div>
|
||||
<div class="qn display">{white.name} <span class="tag max">MAX</span></div>
|
||||
<div class="qp pixel">P1 · проиграл · {demoMatch.whitePersona}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>«{interviews.white}»</p>
|
||||
</div>
|
||||
<div class="thumbwrap">
|
||||
<div class="pixel muted tl">мем-превью · сгенерировано</div>
|
||||
<a href="/games"><Thumb m={thumb} big /></a>
|
||||
<div class="share">
|
||||
<button class="btn sm">Поделиться</button>
|
||||
<button class="btn sm p1">PGN ↓</button>
|
||||
<a class="btn sm" href="/new">Реванш</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quote p2">
|
||||
<div class="qh">
|
||||
<Mark e={black} size={44} />
|
||||
<div>
|
||||
<div class="qn display">{black.name} <span class="tag max">MAX</span></div>
|
||||
<div class="qp pixel">P2 · победил · {demoMatch.blackPersona}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>«{interviews.black}»</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.match {
|
||||
--board: clamp(340px, calc(100vh - 392px), 640px);
|
||||
display: grid;
|
||||
grid-template-columns: 340px minmax(0, 1fr) 340px;
|
||||
grid-template-rows: auto 1fr;
|
||||
gap: 12px;
|
||||
padding: 12px 16px 16px;
|
||||
max-width: 1600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
/* HUD */
|
||||
.hud {
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 270px 1fr;
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
}
|
||||
.center {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
align-content: center;
|
||||
gap: 2px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.center::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.25) 3px 4px);
|
||||
pointer-events: none;
|
||||
}
|
||||
.round {
|
||||
color: var(--p2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.live-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
background: var(--p2);
|
||||
animation: blink 1s steps(2) infinite;
|
||||
}
|
||||
.ko {
|
||||
color: var(--p2);
|
||||
font-size: 11px;
|
||||
}
|
||||
.ev {
|
||||
font-size: 30px;
|
||||
line-height: 1;
|
||||
color: var(--text);
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.ev.neg {
|
||||
color: var(--p2);
|
||||
}
|
||||
.roundno {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
.flags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 4px;
|
||||
}
|
||||
/* columns */
|
||||
.col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
max-height: calc(100vh - var(--nav-h) - 160px);
|
||||
}
|
||||
.left :global(.list) {
|
||||
flex: 1;
|
||||
}
|
||||
.legend i {
|
||||
font-style: normal;
|
||||
margin-left: 4px;
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 700;
|
||||
}
|
||||
.hint {
|
||||
padding: 6px 12px;
|
||||
border-top: 1px solid var(--line);
|
||||
color: var(--dim);
|
||||
font-size: 7.5px;
|
||||
}
|
||||
.right {
|
||||
gap: 12px;
|
||||
}
|
||||
.talk {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 200px;
|
||||
}
|
||||
.talk :global(.feed) {
|
||||
flex: 1;
|
||||
}
|
||||
.pbody {
|
||||
padding: 10px 12px 12px;
|
||||
}
|
||||
/* stage */
|
||||
.stage {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
justify-items: center;
|
||||
align-content: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.arena {
|
||||
display: grid;
|
||||
grid-template-columns: 22px var(--board);
|
||||
gap: 8px;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
.boardbox {
|
||||
position: relative;
|
||||
width: var(--board);
|
||||
max-width: 100%;
|
||||
box-shadow:
|
||||
0 0 0 2px #000,
|
||||
0 0 0 4px var(--line-2),
|
||||
0 20px 60px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.evalbar {
|
||||
position: relative;
|
||||
background: #0b0b10;
|
||||
border: 2px solid var(--line-2);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
overflow: hidden;
|
||||
}
|
||||
.evalbar .w {
|
||||
background: linear-gradient(180deg, #fff 0, #e6e2d4 100%);
|
||||
transition: height 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
|
||||
}
|
||||
.evtxt {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 8px;
|
||||
font-weight: 700;
|
||||
writing-mode: vertical-rl;
|
||||
transform: rotate(180deg);
|
||||
bottom: 4px;
|
||||
color: #000;
|
||||
}
|
||||
.evtxt.top {
|
||||
bottom: auto;
|
||||
top: 4px;
|
||||
color: #fff;
|
||||
}
|
||||
.replay {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
background: #000;
|
||||
color: var(--p1);
|
||||
padding: 4px 6px;
|
||||
z-index: 5;
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
width: calc(var(--board) + 30px);
|
||||
max-width: 100%;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.navbtns {
|
||||
display: flex;
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.navbtns button {
|
||||
padding: 5px 10px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
border-right: 1px solid var(--line-2);
|
||||
color: var(--text);
|
||||
}
|
||||
.navbtns button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.navbtns button:hover {
|
||||
background: var(--panel-2);
|
||||
}
|
||||
.navbtns button.live {
|
||||
color: var(--p2);
|
||||
font-weight: 700;
|
||||
}
|
||||
.tog {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
.tog input {
|
||||
accent-color: var(--hp);
|
||||
margin: 0;
|
||||
}
|
||||
.tog:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
.rules {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rules .pixel {
|
||||
color: var(--dim);
|
||||
}
|
||||
.rules .warn {
|
||||
color: var(--c-inacc);
|
||||
}
|
||||
.graph {
|
||||
width: calc(var(--board) + 30px);
|
||||
max-width: 100%;
|
||||
}
|
||||
.g {
|
||||
height: 84px;
|
||||
}
|
||||
.costrows {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 8px 12px 10px;
|
||||
}
|
||||
.costrow {
|
||||
--acc: var(--p1);
|
||||
display: grid;
|
||||
grid-template-columns: 24px 1fr 60px 56px 80px;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
.costrow.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.costrow .lbl {
|
||||
color: var(--acc);
|
||||
}
|
||||
.costrow .bar {
|
||||
height: 8px;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.costrow .bar i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--acc);
|
||||
}
|
||||
.v {
|
||||
text-align: right;
|
||||
}
|
||||
/* result card */
|
||||
.result {
|
||||
padding: 12px 14px;
|
||||
border-color: var(--p2);
|
||||
background: linear-gradient(180deg, rgba(255, 59, 92, 0.12), var(--panel));
|
||||
}
|
||||
.rline {
|
||||
font-size: 40px;
|
||||
color: var(--p2);
|
||||
line-height: 1;
|
||||
}
|
||||
.rsub {
|
||||
margin: 6px 0 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.rtags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
/* presser */
|
||||
.presser {
|
||||
grid-column: 1 / -1;
|
||||
margin-top: 12px;
|
||||
border-top: 2px solid var(--line-2);
|
||||
padding-top: 18px;
|
||||
}
|
||||
.ph {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.ph h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
.pgrid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 420px 1fr;
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
.quote {
|
||||
--acc: var(--p1);
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-left: 4px solid var(--acc);
|
||||
padding: 14px 16px;
|
||||
}
|
||||
.quote.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.qh {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.qn {
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.qp {
|
||||
color: var(--acc);
|
||||
margin-top: 4px;
|
||||
}
|
||||
.quote p {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
line-height: 1.55;
|
||||
font-style: italic;
|
||||
}
|
||||
.thumbwrap {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.tl {
|
||||
font-size: 8px;
|
||||
}
|
||||
.share {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
}
|
||||
.mtabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ───── mobile (390×844) ───── */
|
||||
@media (max-width: 900px) {
|
||||
.match {
|
||||
--board: calc(100vw - 54px);
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: auto;
|
||||
padding: 8px 10px 70px;
|
||||
gap: 8px;
|
||||
}
|
||||
.hud {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 6px;
|
||||
order: -2;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
.ev {
|
||||
font-size: 18px;
|
||||
}
|
||||
.flags,
|
||||
.rules {
|
||||
display: none;
|
||||
}
|
||||
.stage {
|
||||
order: -1;
|
||||
}
|
||||
.col {
|
||||
max-height: none;
|
||||
}
|
||||
.mhide {
|
||||
display: none !important;
|
||||
}
|
||||
.left :global(.list) {
|
||||
max-height: 50vh;
|
||||
}
|
||||
.talk {
|
||||
min-height: 0;
|
||||
}
|
||||
.talk :global(.feed) {
|
||||
max-height: 50vh;
|
||||
}
|
||||
.toolbar {
|
||||
gap: 8px;
|
||||
}
|
||||
.mtabs {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
background: var(--bg-2);
|
||||
border-top: 2px solid var(--line-2);
|
||||
z-index: 40;
|
||||
}
|
||||
.mtabs button {
|
||||
padding: 14px 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.mtabs button.on {
|
||||
color: #000;
|
||||
background: var(--p1);
|
||||
}
|
||||
.pgrid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.result {
|
||||
order: -1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,368 @@
|
||||
<script lang="ts">
|
||||
// CHARACTER SELECT. Pick P1 (white), then P2 (black). Personas + experimental flags.
|
||||
import { entities, personas, currentUser, byId, type Entity, type Persona } from '#lib/mock.ts';
|
||||
import Mark from '#lib/components/Mark.svelte';
|
||||
|
||||
const me = byId(currentUser.id);
|
||||
const roster: Entity[] = [...entities.filter((e) => e.provider !== 'human'), me];
|
||||
|
||||
let p1 = $state<string | null>('gpt-6-1-sol-max');
|
||||
let p2 = $state<string | null>(null);
|
||||
let picking = $state<'p1' | 'p2'>('p2');
|
||||
let hover = $state<string | null>(null);
|
||||
let persona1 = $state<Persona>('Профессор');
|
||||
let persona2 = $state<Persona>('Уличный гопник');
|
||||
let flags = $state({ notes: true, tools: false, cheat: false });
|
||||
let scheduled = $state(false);
|
||||
|
||||
function pick(id: string) {
|
||||
if (picking === 'p1') {
|
||||
p1 = id;
|
||||
picking = 'p2';
|
||||
} else {
|
||||
p2 = id;
|
||||
}
|
||||
}
|
||||
const e1 = $derived(p1 ? byId(p1) : null);
|
||||
const e2 = $derived(p2 ? byId(p2) : null);
|
||||
const shown = $derived(hover ? byId(hover) : null);
|
||||
const ready = $derived(!!p1 && !!p2);
|
||||
const estCost = $derived(((e1?.costPerGame ?? 0) + (e2?.costPerGame ?? 0)).toFixed(1));
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Новый матч — AI FIGHT CLUB</title></svelte:head>
|
||||
|
||||
<div class="sel">
|
||||
<div class="top">
|
||||
<h1 class="display">Select your fighter</h1>
|
||||
<div class="pixel muted">новый матч · {picking === 'p1' ? 'выбирай белых' : 'выбирай чёрных'} · клик по бойцу</div>
|
||||
</div>
|
||||
|
||||
<div class="vs">
|
||||
<button class="slot p1" class:active={picking === 'p1'} onclick={() => (picking = 'p1')}>
|
||||
<span class="pixel lbl">P1 · белые</span>
|
||||
{#if e1}
|
||||
<Mark e={e1} size={88} />
|
||||
<span class="display nm">{e1.name}</span>
|
||||
<span class="meta">{#if e1.variant}<span class="tag {e1.variant.toLowerCase()}">{e1.variant}</span>{:else}<span class="tag human">я сам</span>{/if}<span class="mono">{e1.rating}</span></span>
|
||||
<span class="tagline">{e1.tagline}</span>
|
||||
{:else}
|
||||
<span class="q display">?</span>
|
||||
<span class="muted">выбери бойца</span>
|
||||
{/if}
|
||||
</button>
|
||||
<div class="mid">
|
||||
<span class="vst display">VS</span>
|
||||
{#if shown}
|
||||
<div class="preview">
|
||||
<Mark e={shown} size={40} />
|
||||
<div><div class="display">{shown.name}</div><div class="muted">{shown.tagline}</div></div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<button class="slot p2" class:active={picking === 'p2'} onclick={() => (picking = 'p2')}>
|
||||
<span class="pixel lbl">P2 · чёрные</span>
|
||||
{#if e2}
|
||||
<Mark e={e2} size={88} />
|
||||
<span class="display nm">{e2.name}</span>
|
||||
<span class="meta">{#if e2.variant}<span class="tag {e2.variant.toLowerCase()}">{e2.variant}</span>{:else}<span class="tag human">я сам</span>{/if}<span class="mono">{e2.rating}</span></span>
|
||||
<span class="tagline">{e2.tagline}</span>
|
||||
{:else}
|
||||
<span class="q display">?</span>
|
||||
<span class="muted">выбери бойца</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="roster">
|
||||
{#each roster as e (e.id)}
|
||||
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
||||
<button
|
||||
class="tile"
|
||||
class:p1={p1 === e.id}
|
||||
class:p2={p2 === e.id}
|
||||
onclick={() => pick(e.id)}
|
||||
onmouseenter={() => (hover = e.id)}
|
||||
onmouseleave={() => (hover = null)}
|
||||
>
|
||||
<Mark {e} size={64} />
|
||||
<span class="tn display">{e.provider === 'human' ? 'Я сам' : e.name}</span>
|
||||
<span class="tv">{#if e.variant}<span class="tag {e.variant.toLowerCase()}">{e.variant}</span>{:else}<span class="tag human">{e.name}</span>{/if}</span>
|
||||
{#if p1 === e.id}<span class="badge pixel b1">P1</span>{/if}
|
||||
{#if p2 === e.id}<span class="badge pixel b2">P2</span>{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="opts">
|
||||
<div class="panel">
|
||||
<div class="panel-h"><span>персоны</span><span class="mono">треш-ток стиль</span></div>
|
||||
<div class="pers">
|
||||
{#each [{ k: 'p1', v: persona1, set: (p: Persona) => (persona1 = p) }, { k: 'p2', v: persona2, set: (p: Persona) => (persona2 = p) }] as side}
|
||||
<div class="pside {side.k}">
|
||||
<div class="pixel ph">{side.k}</div>
|
||||
{#each personas as p}
|
||||
<button class="pbtn" class:on={side.v === p.id} onclick={() => side.set(p.id)} title={p.desc}>
|
||||
<span class="display">{p.id}</span>
|
||||
<span class="muted">«{p.sample}»</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-h"><span>экспериментальные флаги</span><span class="tag warn">beta</span></div>
|
||||
<div class="flags">
|
||||
<label class="fl"><input type="checkbox" bind:checked={flags.notes} /><span><b>Заметки себе</b><em>Агент может оставить записку будущему себе — единственная «память» между ходами.</em></span></label>
|
||||
<label class="fl"><input type="checkbox" bind:checked={flags.tools} /><span><b>Доп. тулы</b><em>get_move_history + python-песочница с python-chess. Дороже на ~40%, ходы дольше.</em></span></label>
|
||||
<label class="fl danger"><input type="checkbox" bind:checked={flags.cheat} /><span><b>Читерство</b><em>Нелегальные ходы разрешены. Партия <u>не рейтинговая</u> и помечается как UNRATED везде.</em></span></label>
|
||||
{#if flags.cheat}
|
||||
<div class="warnbox pixel">⚠ unrated · elo не изменится · в архиве будет красная плашка</div>
|
||||
{/if}
|
||||
<label class="fl"><input type="checkbox" bind:checked={scheduled} /><span><b>Запланировать</b><em>Открыть прогнозы зрителей и показать обратный отсчёт на главной.</em></span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="go">
|
||||
<div class="mono est">оценка стоимости партии: <b>${estCost}</b> · ~45 ходов · ~1.2M tok</div>
|
||||
<a class="btn solid big" class:dis={!ready} href={ready ? '/match/demo' : undefined}>{ready ? 'FIGHT!' : 'выбери обоих бойцов'}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sel {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 22px 20px 50px;
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
}
|
||||
.top h1 {
|
||||
font-size: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.vs {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 200px 1fr;
|
||||
gap: 16px;
|
||||
align-items: stretch;
|
||||
}
|
||||
.slot {
|
||||
--acc: var(--p1);
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 8px;
|
||||
padding: 18px;
|
||||
background: var(--panel);
|
||||
border: 2px solid var(--line-2);
|
||||
text-align: center;
|
||||
min-height: 220px;
|
||||
align-content: center;
|
||||
}
|
||||
.slot.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.slot.active {
|
||||
border-color: var(--acc);
|
||||
box-shadow: 0 0 0 1px var(--acc), 0 0 30px color-mix(in srgb, var(--acc) 25%, transparent);
|
||||
}
|
||||
.slot .lbl {
|
||||
color: var(--acc);
|
||||
}
|
||||
.slot .nm {
|
||||
font-size: 20px;
|
||||
}
|
||||
.slot .meta {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.tagline {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.q {
|
||||
font-size: 64px;
|
||||
color: var(--line-2);
|
||||
}
|
||||
.mid {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
align-content: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.vst {
|
||||
font-size: 48px;
|
||||
text-shadow:
|
||||
4px 4px 0 var(--p2),
|
||||
-4px -4px 0 var(--p1);
|
||||
}
|
||||
.preview {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
font-size: 11px;
|
||||
text-align: left;
|
||||
}
|
||||
.roster {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(9, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
.tile {
|
||||
position: relative;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 6px;
|
||||
padding: 12px 6px 10px;
|
||||
background: var(--panel);
|
||||
border: 2px solid var(--line);
|
||||
transition: transform 0.08s, border-color 0.1s;
|
||||
}
|
||||
.tile:hover {
|
||||
transform: translateY(-3px);
|
||||
border-color: var(--text);
|
||||
}
|
||||
.tile.p1 {
|
||||
border-color: var(--p1);
|
||||
box-shadow: 0 0 0 1px var(--p1);
|
||||
}
|
||||
.tile.p2 {
|
||||
border-color: var(--p2);
|
||||
box-shadow: 0 0 0 1px var(--p2);
|
||||
}
|
||||
.tile.p1.p2 {
|
||||
box-shadow: 0 0 0 1px var(--p1), 0 0 0 4px var(--p2);
|
||||
}
|
||||
.tn {
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
padding: 2px 5px;
|
||||
color: #000;
|
||||
}
|
||||
.b1 {
|
||||
left: -6px;
|
||||
background: var(--p1);
|
||||
}
|
||||
.b2 {
|
||||
right: -6px;
|
||||
background: var(--p2);
|
||||
}
|
||||
.opts {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr;
|
||||
gap: 14px;
|
||||
}
|
||||
.pers {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
}
|
||||
.pside {
|
||||
--acc: var(--p1);
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
.pside.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.ph {
|
||||
color: var(--acc);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.pbtn {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
text-align: left;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel-2);
|
||||
font-size: 11px;
|
||||
}
|
||||
.pbtn .display {
|
||||
font-size: 11px;
|
||||
}
|
||||
.pbtn:hover {
|
||||
border-color: var(--line-2);
|
||||
}
|
||||
.pbtn.on {
|
||||
border-color: var(--acc);
|
||||
background: color-mix(in srgb, var(--acc) 12%, var(--panel-2));
|
||||
}
|
||||
.flags {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
.fl {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 10px;
|
||||
align-items: start;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel-2);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.fl input {
|
||||
accent-color: var(--p1);
|
||||
margin-top: 2px;
|
||||
}
|
||||
.fl b {
|
||||
display: block;
|
||||
font-family: var(--font-display);
|
||||
font-size: 11px;
|
||||
}
|
||||
.fl em {
|
||||
font-style: normal;
|
||||
color: var(--muted);
|
||||
}
|
||||
.fl.danger {
|
||||
border-color: rgba(255, 59, 59, 0.5);
|
||||
}
|
||||
.fl.danger input {
|
||||
accent-color: var(--c-blunder);
|
||||
}
|
||||
.warnbox {
|
||||
background: var(--c-blunder);
|
||||
color: #fff;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
.go {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
.est b {
|
||||
color: var(--p1);
|
||||
}
|
||||
.btn.big {
|
||||
font-size: 18px;
|
||||
padding: 14px 40px;
|
||||
}
|
||||
.btn.dis {
|
||||
opacity: 0.4;
|
||||
pointer-events: none;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.vs,
|
||||
.opts,
|
||||
.pers {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.roster {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,3 @@
|
||||
# allow crawling everything by default
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "$app/tsconfig",
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import adapter from '@sveltejs/adapter-static';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
sveltekit({
|
||||
compilerOptions: {
|
||||
runes: ({ filename }) =>
|
||||
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
|
||||
},
|
||||
adapter: adapter({
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: 'index.html',
|
||||
precompress: false,
|
||||
strict: false
|
||||
})
|
||||
})
|
||||
]
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
node_modules
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
.netlify
|
||||
.wrangler
|
||||
/.svelte-kit
|
||||
/build
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
@@ -0,0 +1 @@
|
||||
engine-strict=true
|
||||
@@ -0,0 +1,83 @@
|
||||
# AI·CHESS — концепт «ЭФИР» (Live Sports Broadcast)
|
||||
|
||||
Фронтенд-концепт для арены, где LLM-агенты играют в шахматы, троллят друг друга и получают рейтинг.
|
||||
Направление: **ночная спортивная трансляция / esports-графика**. Живой матч должен ощущаться как
|
||||
титульный бой по ТВ: скорбаг над доской, нижние трети для треш-тока, бегущая строка внизу, стингер
|
||||
«ПОВТОР» при отмотке, жёлтая лента с результатом в финале. Тёмная «сцена» с цветным светом из углов:
|
||||
белые — ледяной (`ice`), чёрные — огненный (`fire`); золото — акцент бренда и «лучших ходов», красный — LIVE.
|
||||
|
||||
## Стек
|
||||
|
||||
SvelteKit 3 · Svelte 5 (runes) · TypeScript · `@sveltejs/adapter-static` (SPA, `fallback: index.html`) ·
|
||||
`@lichess-org/chessground` (кастомный тёмный скин + cburnett) · `chess.js` (реплей PGN в позиции, контекст
|
||||
агента генерируется из реальных FEN/ASCII) · `simple-icons` (`siClaude`, `siAnthropic`) · ванильный CSS с токенами.
|
||||
Моки — `src/lib/mock.ts`.
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
npm run preview -- --port 5181
|
||||
```
|
||||
|
||||
Маршруты: `/` · `/match/demo` · `/match/demo?over=1` · `/leaderboard` · `/new` · `/login` · `/admin` · `/games`.
|
||||
|
||||
## Палитра
|
||||
|
||||
| токен | hex | роль |
|
||||
| --- | --- | --- |
|
||||
| `--bg` / `--stage` | `#06070b` / `#0b0d14` | сцена |
|
||||
| `--panel` / `--line` | `#10131b` / `#232838` | панели, линии |
|
||||
| `--live` | `#ff2a3c` | LIVE, таймер думающего, бегущая строка |
|
||||
| `--gold` | `#ffc93c` | бренд, выбранный ход, `!!`, финальная лента |
|
||||
| `--ice` | `#7cc7ff` | угол белых |
|
||||
| `--fire` | `#ff5d3a` | угол чёрных |
|
||||
| `--good` / `--bad` / `--warn` | `#42d989` / `#ff4757` / `#ffb347` | классификация ходов |
|
||||
|
||||
## Шрифты
|
||||
|
||||
- **Oswald** 400–700 — дисплейный, конденсированный, капс: скорбаг, цифры, заголовки, кикеры (есть кириллица).
|
||||
- **IBM Plex Sans** — текст, треш-ток, интервью.
|
||||
- **IBM Plex Mono** — SAN, FEN, тул-коллы, контекст.
|
||||
|
||||
Загружаются с Google Fonts (`src/app.html`).
|
||||
|
||||
## Ключевые решения
|
||||
|
||||
- **Скорбаг** (`Scorebug.svelte`) — одна полоса над доской, как в боксе: логотип/аватар, модель, чип MAX/HIGH,
|
||||
рейтинг, персона, живая точность, расход $, таймер «ДУМАЕТ» (мигающий красный бокс) у того, чей ход.
|
||||
В центре — скошенный блок с номером хода и оценкой; в финале там «0–1 · ФИНАЛ».
|
||||
- **Доска как сцена** — тёмная стальная доска, золотая подсветка последнего хода, красный шах; при отмотке
|
||||
назад над доской появляется красный стингер «ПОВТОР · ход 21… → в эфир». Бейдж `?!/??/!!` в углу доски.
|
||||
Стрелка Stockfish — кнопка «SF» в правой колонке инструментов, ← → листают ходы.
|
||||
- **Нижняя треть** (`LowerThird.svelte`) — последняя реплика треш-тока в формате ТВ-плашки: имя+персона на
|
||||
тёмной скошенной плашке, цитата на белой. Заменяется с анимацией-вайпом при смене хода.
|
||||
- **Мысли агента** (`MoveList` + `Thoughts.svelte`) — скрыты по умолчанию. Клик по ходу = позиция на доске +
|
||||
раскрытие панели «МЫСЛИ» прямо под строкой (аккордеон, строка прижимается к верху списка). Три вкладки:
|
||||
*Рассуждение* (summary, лучше было по SF, фраза, золотая «Заметка себе» и серая «Заметка из прошлого
|
||||
хода»), *Тулы* (нумерованные вызовы `python`/`get_move_history`/`make_move`/`finish_turn` с выводом),
|
||||
*Контекст* (ровно то, что получила модель: ASCII-доска, FEN, список фигур, последний ход и фраза
|
||||
соперника, релевантные правила — всё генерируется из chess.js).
|
||||
- **Состояние правил** — три чипа справа под скорбагом (рокировка / 50 ходов / повторения), гаснут, пока не
|
||||
актуальны, и становятся мигающими жёлтыми при пороге (на главной видно у второй живой партии).
|
||||
- **График оценки** — рукописный SVG с sqrt-сжатием (малые перевесы читаются), белая/тёмная заливка от
|
||||
середины, точки на ключевых ходах (`?!`, `?`, `??`, `!!`), красная линия текущего хода, клик — переход.
|
||||
- **Финал** (`?over=1`) — жёлтая лента-стингер на доске, слева: результат, мем-превью, два интервью в стиле
|
||||
пресс-конференции (микрофон, «победитель / проигравший»), итог прогноза с очками.
|
||||
- **Мем-превью** (`Thumb.svelte`) — CSS/SVG-композиция: диагональ двух цветов, лучи, мини-доска из FEN
|
||||
(переиспользует спрайты cburnett), логотипы (проигравший — ч/б с крестом), огромный жёлтый капшн
|
||||
с чёрной обводкой, размер зависит от длины текста, бейдж результата и сашет «БЕЗ РЕЙТИНГА».
|
||||
- **Бегущая строка** — внизу на всех страницах (на мобильном — статично), lives/скоро/итоги/таблица.
|
||||
- **Мобильный матч** (390) — скорбаг сжимается до коротких имён, горизонтальный eval-бар над доской, табы
|
||||
«Ходы / Треш-ток / Аналитика», те же раскрывающиеся мысли.
|
||||
- **Таблица** — три вида: турнирная таблица (топ-3 с цветными рёбрами, W/D/L-бар, $/партия, «Elo за $»),
|
||||
scatter «Сколько стоит рейтинг» (MAX↔HIGH одной модели соединены линией, люди — в бесплатной зоне),
|
||||
матрица очных встреч (цвет = доля очков).
|
||||
|
||||
## Известные ограничения
|
||||
|
||||
- `simple-icons@16` больше не содержит `siOpenai` (удалён по требованию правообладателя) — для OpenAI
|
||||
используется рукописный «узел» из шести колец как плейсхолдер (`src/lib/icons.ts`).
|
||||
- Продолжение партии после 22.gxh3 (для финального состояния) — выдуманное, но легальное (проверено chess.js):
|
||||
22…Rg6 23.Kh1?? Qxh3+ 24.Nh2 Rxg3!! 25.fxg3 Qxg3 26.Rg4?? Qxe1+ 27.Kg2 Qe2+ 28.Kh3 Qxc2 0–1.
|
||||
- Оценки, классификации, время и стоимость — правдоподобные моки; «живой» таймер просто тикает.
|
||||
- Другие матчи (`/match/g-7781` и т.п.) ведут на тот же демо-матч.
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "broadcast",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo ''",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-static": "^4.0.0",
|
||||
"@sveltejs/kit": "^3.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
||||
"svelte": "^5.57.1",
|
||||
"svelte-check": "^4.6.0",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"imports": {
|
||||
"#lib": "./src/lib/index.js",
|
||||
"#lib/*": "./src/lib/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lichess-org/chessground": "^10.4.2",
|
||||
"chess.js": "^1.4.0",
|
||||
"simple-icons": "^16.35.0"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 378 KiB |
|
After Width: | Height: | Size: 444 KiB |
|
After Width: | Height: | Size: 426 KiB |
|
After Width: | Height: | Size: 425 KiB |
|
After Width: | Height: | Size: 427 KiB |
|
After Width: | Height: | Size: 439 KiB |
|
After Width: | Height: | Size: 824 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 219 KiB |
|
After Width: | Height: | Size: 296 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 201 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 561 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 223 KiB |
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1,366 @@
|
||||
@import '@lichess-org/chessground/assets/chessground.base.css';
|
||||
@import '@lichess-org/chessground/assets/chessground.cburnett.css';
|
||||
|
||||
:root {
|
||||
/* stage */
|
||||
--bg: #06070b;
|
||||
--stage: #0b0d14;
|
||||
--panel: #10131b;
|
||||
--panel-2: #161a24;
|
||||
--panel-3: #1d2230;
|
||||
--line: #232838;
|
||||
--line-2: #2e3447;
|
||||
|
||||
/* text */
|
||||
--text: #eef1f6;
|
||||
--text-2: #c3c9d6;
|
||||
--muted: #8a92a6;
|
||||
--dim: #5b6276;
|
||||
|
||||
/* broadcast */
|
||||
--live: #ff2a3c;
|
||||
--live-deep: #b3101f;
|
||||
--gold: #ffc93c;
|
||||
--gold-deep: #c9930f;
|
||||
--ice: #7cc7ff;
|
||||
--ice-deep: #2f7fc2;
|
||||
--fire: #ff5d3a;
|
||||
--fire-deep: #c23a1c;
|
||||
--good: #42d989;
|
||||
--bad: #ff4757;
|
||||
--warn: #ffb347;
|
||||
|
||||
/* corners (mapped per game) */
|
||||
--white-corner: var(--ice);
|
||||
--black-corner: var(--fire);
|
||||
|
||||
--display: 'Oswald', 'Arial Narrow', sans-serif;
|
||||
--body: 'IBM Plex Sans', system-ui, sans-serif;
|
||||
--mono: 'IBM Plex Mono', ui-monospace, monospace;
|
||||
|
||||
--skew: -12deg;
|
||||
--r: 3px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: var(--body);
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
body {
|
||||
min-height: 100vh;
|
||||
background:
|
||||
radial-gradient(900px 420px at 18% -10%, color-mix(in srgb, var(--ice) 14%, transparent), transparent 70%),
|
||||
radial-gradient(900px 420px at 82% -10%, color-mix(in srgb, var(--fire) 14%, transparent), transparent 70%),
|
||||
radial-gradient(1200px 600px at 50% 120%, #0f1220, transparent 70%),
|
||||
var(--bg);
|
||||
background-attachment: fixed;
|
||||
}
|
||||
body::before {
|
||||
/* fine broadcast grain */
|
||||
content: '';
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
opacity: 0.35;
|
||||
background-image: repeating-linear-gradient(
|
||||
0deg,
|
||||
rgba(255, 255, 255, 0.025) 0px,
|
||||
rgba(255, 255, 255, 0.025) 1px,
|
||||
transparent 1px,
|
||||
transparent 3px
|
||||
);
|
||||
mix-blend-mode: overlay;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
button {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
::selection {
|
||||
background: var(--gold);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* --- Type utilities --- */
|
||||
.display {
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
}
|
||||
.mono {
|
||||
font-family: var(--mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.tnum {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.kicker {
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* --- Broadcast primitives --- */
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 3px 8px 2px;
|
||||
line-height: 1.1;
|
||||
background: var(--panel-3);
|
||||
color: var(--text-2);
|
||||
clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
|
||||
}
|
||||
.tag.live {
|
||||
background: var(--live);
|
||||
color: #fff;
|
||||
}
|
||||
.tag.gold {
|
||||
background: var(--gold);
|
||||
color: #140f00;
|
||||
}
|
||||
.tag.ice {
|
||||
background: var(--ice);
|
||||
color: #001423;
|
||||
}
|
||||
.tag.fire {
|
||||
background: var(--fire);
|
||||
color: #1e0600;
|
||||
}
|
||||
.tag.ghost {
|
||||
background: transparent;
|
||||
box-shadow: inset 0 0 0 1px var(--line-2);
|
||||
}
|
||||
.tag.warn {
|
||||
background: var(--warn);
|
||||
color: #1e1200;
|
||||
}
|
||||
.tag.bad {
|
||||
background: var(--bad);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.live-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
|
||||
animation: pulse 1.4s ease-out infinite;
|
||||
}
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 7px rgba(255, 255, 255, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: linear-gradient(180deg, var(--panel-2), var(--panel));
|
||||
border: 1px solid var(--line);
|
||||
position: relative;
|
||||
}
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 8px 12px 7px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.14em;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-2);
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.panel-head::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 12px;
|
||||
background: var(--gold);
|
||||
margin-right: 2px;
|
||||
transform: skewX(var(--skew));
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
padding: 10px 18px 9px;
|
||||
background: var(--panel-3);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--line-2);
|
||||
transition:
|
||||
transform 0.12s ease,
|
||||
background 0.12s ease,
|
||||
border-color 0.12s ease;
|
||||
clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
|
||||
}
|
||||
.btn:hover {
|
||||
background: var(--line-2);
|
||||
}
|
||||
.btn:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
.btn.primary {
|
||||
background: var(--gold);
|
||||
color: #140f00;
|
||||
border-color: var(--gold);
|
||||
}
|
||||
.btn.primary:hover {
|
||||
background: #ffd766;
|
||||
}
|
||||
.btn.live {
|
||||
background: var(--live);
|
||||
color: #fff;
|
||||
border-color: var(--live);
|
||||
}
|
||||
.btn.sm {
|
||||
font-size: 11px;
|
||||
padding: 6px 12px 5px;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.wrap {
|
||||
padding: 0 12px;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Chessground skin: dark stage board --- */
|
||||
.cg-wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
cg-board {
|
||||
background-color: #aeb6c9;
|
||||
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4IDgiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyI+PGcgZmlsbD0iIzM0M2I0ZiI+PHJlY3QgeD0iMSIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjMiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI1IiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNyIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjAiIHk9IjEiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIyIiB5PSIxIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNCIgeT0iMSIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjYiIHk9IjEiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIxIiB5PSIyIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMyIgeT0iMiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjUiIHk9IjIiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI3IiB5PSIyIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMCIgeT0iMyIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjIiIHk9IjMiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI0IiB5PSIzIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNiIgeT0iMyIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjEiIHk9IjQiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIzIiB5PSI0IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNSIgeT0iNCIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjciIHk9IjQiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIwIiB5PSI1IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMiIgeT0iNSIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjQiIHk9IjUiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI2IiB5PSI1IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMSIgeT0iNiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjMiIHk9IjYiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI1IiB5PSI2IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNyIgeT0iNiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjAiIHk9IjciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIyIiB5PSI3IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNCIgeT0iNyIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjYiIHk9IjciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48L2c+PC9zdmc+');
|
||||
background-size: cover;
|
||||
}
|
||||
cg-board square.last-move {
|
||||
background-color: rgba(255, 201, 60, 0.42);
|
||||
}
|
||||
cg-board square.check {
|
||||
background: radial-gradient(
|
||||
ellipse at center,
|
||||
rgba(255, 42, 60, 1) 0%,
|
||||
rgba(255, 42, 60, 0.9) 25%,
|
||||
rgba(255, 42, 60, 0) 89%
|
||||
);
|
||||
}
|
||||
cg-board square.selected {
|
||||
background-color: rgba(124, 199, 255, 0.5);
|
||||
}
|
||||
.cg-wrap coords {
|
||||
font-family: var(--display);
|
||||
font-weight: 500;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
.cg-wrap coords.ranks coord,
|
||||
.cg-wrap coords.files coord {
|
||||
color: rgba(238, 241, 246, 0.6) !important;
|
||||
}
|
||||
|
||||
/* keyframes shared */
|
||||
@keyframes stinger-in {
|
||||
0% {
|
||||
clip-path: inset(0 100% 0 0);
|
||||
opacity: 0.4;
|
||||
}
|
||||
100% {
|
||||
clip-path: inset(0 0 0 0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
@keyframes flash {
|
||||
0% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
}
|
||||
@keyframes marquee {
|
||||
from {
|
||||
transform: translateX(0);
|
||||
}
|
||||
to {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
@keyframes blink {
|
||||
50% {
|
||||
opacity: 0.25;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.001ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.001ms !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||
<meta name="theme-color" content="#06070b" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { Chessground } from '@lichess-org/chessground';
|
||||
import type { Api } from '@lichess-org/chessground/api';
|
||||
import type { Key } from '@lichess-org/chessground/types';
|
||||
import type { DrawShape } from '@lichess-org/chessground/draw';
|
||||
|
||||
let {
|
||||
fen,
|
||||
lastMove,
|
||||
check = false,
|
||||
orientation = 'white',
|
||||
arrow,
|
||||
coordinates = true
|
||||
}: {
|
||||
fen: string;
|
||||
lastMove?: [string, string];
|
||||
check?: boolean;
|
||||
orientation?: 'white' | 'black';
|
||||
arrow?: [string, string] | null;
|
||||
coordinates?: boolean;
|
||||
} = $props();
|
||||
|
||||
let el: HTMLDivElement;
|
||||
let api: Api | undefined;
|
||||
|
||||
onMount(() => {
|
||||
api = Chessground(el, {
|
||||
fen,
|
||||
orientation,
|
||||
viewOnly: true,
|
||||
coordinates,
|
||||
animation: { enabled: true, duration: 220 },
|
||||
highlight: { lastMove: true, check: true },
|
||||
drawable: { enabled: false, visible: true, brushes: { gold: { key: 'gold', color: '#ffc93c', opacity: 0.9, lineWidth: 11 } } as any }
|
||||
});
|
||||
return () => api?.destroy();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!api) return;
|
||||
const shapes: DrawShape[] = arrow ? [{ orig: arrow[0] as Key, dest: arrow[1] as Key, brush: 'gold' }] : [];
|
||||
api.set({
|
||||
fen,
|
||||
orientation,
|
||||
lastMove: lastMove as Key[] | undefined,
|
||||
check,
|
||||
drawable: { shapes }
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="board" bind:this={el}></div>
|
||||
|
||||
<style>
|
||||
.board {
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,99 @@
|
||||
<script lang="ts">
|
||||
import type { Game } from '#lib/mock.js';
|
||||
import { fmt } from '#lib/mock.js';
|
||||
|
||||
let { game, ply }: { game: Game; ply: number } = $props();
|
||||
const shown = $derived(game.moves.slice(0, ply));
|
||||
const sum = (c: 'w' | 'b', k: 'tokens' | 'costUsd' | 'timeSec') => shown.filter((m) => m.color === c).reduce((a, m) => a + m[k], 0);
|
||||
const w = $derived({ tok: sum('w', 'tokens'), usd: sum('w', 'costUsd'), t: sum('w', 'timeSec') });
|
||||
const b = $derived({ tok: sum('b', 'tokens'), usd: sum('b', 'costUsd'), t: sum('b', 'timeSec') });
|
||||
const total = $derived(w.usd + b.usd);
|
||||
const maxTok = $derived(Math.max(...shown.map((m) => m.tokens), 1));
|
||||
const recent = $derived(shown.slice(-24));
|
||||
</script>
|
||||
|
||||
<div class="cost">
|
||||
<div class="panel-head">
|
||||
<span>Счётчик</span>
|
||||
<span class="tot display">{fmt.usd(total)}</span>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="rows">
|
||||
{#each [['w', w, game.white.short], ['b', b, game.black.short]] as const as [c, s, name]}
|
||||
<div class="r {c}">
|
||||
<b class="display">{name}</b>
|
||||
<span class="mono">{fmt.tok(s.tok)} tok</span>
|
||||
<span class="mono">{fmt.time(s.t)}</span>
|
||||
<span class="usd display tnum">{fmt.usd(s.usd)}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="bars" title="токены за последние ходы">
|
||||
{#each recent as m (m.ply)}
|
||||
<i class={m.color} style:height="{Math.max(8, (m.tokens / maxTok) * 100)}%" title="{m.moveNo}{m.color === 'w' ? '.' : '…'}{m.san} · {fmt.tok(m.tokens)} · {fmt.usd(m.costUsd)}"></i>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="foot kicker"><span>Токены по ходам</span><span>{fmt.usd(total / Math.max(1, shown.length))} / ход</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.cost .tot {
|
||||
font-size: 14px;
|
||||
color: var(--gold);
|
||||
}
|
||||
.body {
|
||||
padding: 8px 10px 10px;
|
||||
}
|
||||
.rows {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.r {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto auto 60px;
|
||||
gap: 10px;
|
||||
align-items: baseline;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
padding-left: 8px;
|
||||
border-left: 2px solid var(--white-corner);
|
||||
}
|
||||
.r.b {
|
||||
border-left-color: var(--black-corner);
|
||||
}
|
||||
.r b {
|
||||
font-size: 12px;
|
||||
color: var(--text-2);
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.usd {
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
text-align: right;
|
||||
}
|
||||
.bars {
|
||||
height: 44px;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.bars i {
|
||||
flex: 1;
|
||||
background: var(--white-corner);
|
||||
opacity: 0.85;
|
||||
min-width: 3px;
|
||||
}
|
||||
.bars i.b {
|
||||
background: var(--black-corner);
|
||||
}
|
||||
.foot {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 6px;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let { at, size = 'lg' }: { at: string; size?: 'lg' | 'sm' } = $props();
|
||||
let now = $state(Date.now());
|
||||
onMount(() => {
|
||||
const t = setInterval(() => (now = Date.now()), 1000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
const diff = $derived(Math.max(0, Math.floor((new Date(at).getTime() - now) / 1000)));
|
||||
const h = $derived(Math.floor(diff / 3600));
|
||||
const m = $derived(Math.floor((diff % 3600) / 60));
|
||||
const s = $derived(diff % 60);
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
</script>
|
||||
|
||||
<div class="cd {size} display tnum" aria-label="обратный отсчёт">
|
||||
<span class="u"><b>{pad(h)}</b><i>ч</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="u"><b>{pad(m)}</b><i>м</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="u"><b>{pad(s)}</b><i>с</i></span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.cd {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.u {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 3px;
|
||||
}
|
||||
.u b {
|
||||
font-size: 56px;
|
||||
line-height: 0.9;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
background: linear-gradient(180deg, #fff, #c6ccd9);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
.u i {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--muted);
|
||||
}
|
||||
.colon {
|
||||
font-size: 40px;
|
||||
color: var(--gold);
|
||||
animation: blink 1s steps(1) infinite;
|
||||
line-height: 0.9;
|
||||
}
|
||||
.sm .u b {
|
||||
font-size: 24px;
|
||||
}
|
||||
.sm .colon {
|
||||
font-size: 20px;
|
||||
}
|
||||
.sm .u i {
|
||||
font-size: 9px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script lang="ts">
|
||||
import { fmt } from '#lib/mock.js';
|
||||
let { cp, horizontal = false }: { cp: number; horizontal?: boolean } = $props();
|
||||
// white share 0..1 via sigmoid-ish
|
||||
const share = $derived.by(() => {
|
||||
if (Math.abs(cp) >= 10000) return cp > 0 ? 0.98 : 0.02;
|
||||
const x = cp / 100;
|
||||
return Math.min(0.96, Math.max(0.04, 0.5 + 0.5 * (2 / (1 + Math.exp(-0.5 * x)) - 1)));
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="bar" class:horizontal style:--w="{share * 100}%">
|
||||
<div class="white"></div>
|
||||
<span class="num display tnum" class:top={cp < 0}>{fmt.evalStr(cp)}</span>
|
||||
<i class="mid"></i>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.bar {
|
||||
position: relative;
|
||||
background: #171a24;
|
||||
border: 1px solid var(--line-2);
|
||||
overflow: hidden;
|
||||
width: 22px;
|
||||
height: 100%;
|
||||
}
|
||||
.white {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: var(--w);
|
||||
background: linear-gradient(180deg, #ffffff, #d9deea);
|
||||
transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
.mid {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
height: 1px;
|
||||
background: var(--gold);
|
||||
opacity: 0.7;
|
||||
}
|
||||
.num {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 4px;
|
||||
text-align: center;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
color: #000;
|
||||
writing-mode: vertical-rl;
|
||||
transform: rotate(180deg);
|
||||
height: 40px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
.num.top {
|
||||
bottom: auto;
|
||||
top: 4px;
|
||||
color: #fff;
|
||||
}
|
||||
.horizontal {
|
||||
width: 100%;
|
||||
height: 14px;
|
||||
}
|
||||
.horizontal .white {
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: auto;
|
||||
height: 100%;
|
||||
width: var(--w);
|
||||
transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
.horizontal .mid {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
right: auto;
|
||||
width: 1px;
|
||||
height: auto;
|
||||
}
|
||||
.horizontal .num {
|
||||
writing-mode: horizontal-tb;
|
||||
transform: none;
|
||||
height: 100%;
|
||||
width: 44px;
|
||||
left: 4px;
|
||||
right: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
text-align: left;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
.horizontal .num.top {
|
||||
left: auto;
|
||||
right: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,123 @@
|
||||
<script lang="ts">
|
||||
import type { MoveRec } from '#lib/mock.js';
|
||||
import { clsMeta, fmt } from '#lib/mock.js';
|
||||
|
||||
let {
|
||||
moves,
|
||||
ply,
|
||||
total,
|
||||
onselect,
|
||||
height = 110
|
||||
}: { moves: MoveRec[]; ply: number; total: number; onselect?: (p: number) => void; height?: number } = $props();
|
||||
|
||||
const W = 600;
|
||||
const H = 100;
|
||||
const PAD = 6;
|
||||
const n = $derived(Math.max(total, 40));
|
||||
const x = (p: number) => PAD + ((p - 1) / Math.max(1, n - 1)) * (W - PAD * 2);
|
||||
const clamp = (cp: number) => Math.max(-800, Math.min(800, Math.abs(cp) >= 10000 ? Math.sign(cp) * 800 : cp));
|
||||
const y = (cp: number) => {
|
||||
const v = clamp(cp) / 800; // -1..1
|
||||
// soften with sqrt for legibility of small advantages
|
||||
const s = Math.sign(v) * Math.sqrt(Math.abs(v));
|
||||
return H / 2 - s * (H / 2 - PAD);
|
||||
};
|
||||
const pts = $derived(moves.map((m) => [x(m.ply), y(m.evalCp)] as const));
|
||||
const path = $derived.by(() => {
|
||||
if (!pts.length) return '';
|
||||
let d = `M${x(0.9).toFixed(1)} ${(H / 2).toFixed(1)}`;
|
||||
for (const [px, py] of pts) d += ` L${px.toFixed(1)} ${py.toFixed(1)}`;
|
||||
return d;
|
||||
});
|
||||
const lastX = $derived(pts.length ? pts[pts.length - 1][0] : x(1));
|
||||
// area between the curve and the midline, closed along the midline
|
||||
const area = $derived(path ? `${path} L${lastX.toFixed(1)} ${H / 2} L${x(0.9).toFixed(1)} ${H / 2} Z` : '');
|
||||
|
||||
let hover = $state<number | null>(null);
|
||||
const hovered = $derived(hover ? moves[hover - 1] : null);
|
||||
|
||||
function pick(ev: MouseEvent) {
|
||||
const el = ev.currentTarget as SVGSVGElement;
|
||||
const r = el.getBoundingClientRect();
|
||||
const px = ((ev.clientX - r.left) / r.width) * W;
|
||||
let best = 1;
|
||||
let bd = Infinity;
|
||||
for (const m of moves) {
|
||||
const d = Math.abs(x(m.ply) - px);
|
||||
if (d < bd) {
|
||||
bd = d;
|
||||
best = m.ply;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="graph" style:height="{height}px">
|
||||
<svg
|
||||
viewBox="0 0 {W} {H}"
|
||||
preserveAspectRatio="none"
|
||||
role="img"
|
||||
aria-label="График оценки"
|
||||
onmousemove={(e) => (hover = pick(e))}
|
||||
onmouseleave={() => (hover = null)}
|
||||
onclick={(e) => onselect?.(pick(e))}
|
||||
>
|
||||
<defs>
|
||||
<clipPath id="top"><rect x="0" y="0" width={W} height={H / 2} /></clipPath>
|
||||
<clipPath id="bot"><rect x="0" y={H / 2} width={W} height={H / 2} /></clipPath>
|
||||
</defs>
|
||||
<rect x="0" y="0" width={W} height={H} fill="#0a0c12" />
|
||||
<!-- white's territory (fill where eval > 0) -->
|
||||
<path d={area} fill="#e6e9f0" clip-path="url(#top)" opacity="0.92" />
|
||||
<!-- black's territory -->
|
||||
<path d={area} fill="#4a5168" clip-path="url(#bot)" />
|
||||
<line x1="0" x2={W} y1={H / 2} y2={H / 2} stroke="var(--gold)" stroke-opacity="0.5" stroke-width="0.8" />
|
||||
<path d={path} fill="none" stroke="var(--gold)" stroke-width="1.2" vector-effect="non-scaling-stroke" />
|
||||
<!-- key move marks -->
|
||||
{#each moves as m}
|
||||
{#if m.cls === 'blunder' || m.cls === 'mistake' || m.cls === 'brilliant' || m.cls === 'inaccuracy'}
|
||||
<circle cx={x(m.ply)} cy={y(m.evalCp)} r="3.2" fill={clsMeta[m.cls].color} stroke="#0a0c12" stroke-width="1" />
|
||||
{/if}
|
||||
{/each}
|
||||
<!-- current -->
|
||||
<line x1={x(ply)} x2={x(ply)} y1="0" y2={H} stroke="var(--live)" stroke-width="1.4" vector-effect="non-scaling-stroke" />
|
||||
{#if hover}
|
||||
<line x1={x(hover)} x2={x(hover)} y1="0" y2={H} stroke="#fff" stroke-opacity="0.35" vector-effect="non-scaling-stroke" />
|
||||
{/if}
|
||||
</svg>
|
||||
{#if hovered}
|
||||
<div class="tip mono" style:left="{(x(hovered.ply) / W) * 100}%">
|
||||
<b>{hovered.moveNo}{hovered.color === 'w' ? '.' : '…'}{hovered.san}</b>
|
||||
{fmt.evalStr(hovered.evalCp)}
|
||||
{#if clsMeta[hovered.cls].glyph}<span style:color={clsMeta[hovered.cls].color}>{clsMeta[hovered.cls].glyph}</span>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.graph {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
cursor: crosshair;
|
||||
}
|
||||
.tip {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
transform: translateX(-50%);
|
||||
background: #000;
|
||||
border: 1px solid var(--line-2);
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type { Flags } from '#lib/mock.js';
|
||||
let { flags, loud = false }: { flags: Flags; loud?: boolean } = $props();
|
||||
</script>
|
||||
|
||||
<span class="flags">
|
||||
{#if flags.notes}<span class="tag ghost" title="Заметки себе: агент получает свою записку с прошлого хода">Заметки себе</span>{/if}
|
||||
{#if flags.tools}<span class="tag ghost" title="Доп. тулы: get_move_history + python">Доп. тулы</span>{/if}
|
||||
{#if flags.cheat}<span class="tag bad" class:loud title="Читерство: нелегальные ходы разрешены, партия без рейтинга">⚠ Читерство · без рейтинга</span>{/if}
|
||||
</span>
|
||||
|
||||
<style>
|
||||
.flags {
|
||||
display: inline-flex;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.loud {
|
||||
animation: blink 1.6s steps(1) infinite;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,92 @@
|
||||
<script lang="ts">
|
||||
import type { Entity, Persona } from '#lib/mock.js';
|
||||
import Mark from './Mark.svelte';
|
||||
|
||||
let {
|
||||
entity,
|
||||
persona,
|
||||
color,
|
||||
text,
|
||||
won,
|
||||
delay = 0
|
||||
}: { entity: Entity; persona: Persona; color: 'w' | 'b'; text: string; won: boolean; delay?: number } = $props();
|
||||
</script>
|
||||
|
||||
<figure class="iv {color}" class:won style:animation-delay="{delay}ms">
|
||||
<div class="head">
|
||||
<Mark {entity} size={44} corner={color === 'w' ? 'white' : 'black'} />
|
||||
<div class="who">
|
||||
<b class="display">{entity.name}</b>
|
||||
<span class="kicker">{persona} · {won ? 'победитель' : 'проигравший'}</span>
|
||||
</div>
|
||||
<span class="mic" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12 15a4 4 0 0 0 4-4V6a4 4 0 1 0-8 0v5a4 4 0 0 0 4 4Zm6-4a6 6 0 0 1-12 0H4a8 8 0 0 0 7 7.93V22h2v-3.07A8 8 0 0 0 20 11h-2Z"/></svg>
|
||||
</span>
|
||||
</div>
|
||||
<blockquote>{text}</blockquote>
|
||||
<figcaption class="kicker">Пресс-конференция · после партии</figcaption>
|
||||
</figure>
|
||||
|
||||
<style>
|
||||
.iv {
|
||||
margin: 0;
|
||||
background: linear-gradient(180deg, #13161f, #0c0e15);
|
||||
border: 1px solid var(--line);
|
||||
border-top: 3px solid var(--white-corner);
|
||||
padding: 12px 14px 12px;
|
||||
animation: rise 0.5s both cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
position: relative;
|
||||
}
|
||||
.iv.b {
|
||||
border-top-color: var(--black-corner);
|
||||
}
|
||||
.iv.won::after {
|
||||
content: 'W';
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 8px;
|
||||
font-family: var(--display);
|
||||
font-weight: 700;
|
||||
font-size: 44px;
|
||||
color: var(--gold);
|
||||
opacity: 0.12;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.who {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.who b {
|
||||
font-size: 16px;
|
||||
}
|
||||
.mic {
|
||||
margin-left: auto;
|
||||
color: var(--live);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: 1px solid color-mix(in srgb, var(--live) 50%, transparent);
|
||||
border-radius: 50%;
|
||||
}
|
||||
blockquote {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.55;
|
||||
color: var(--text);
|
||||
position: relative;
|
||||
padding-left: 12px;
|
||||
border-left: 2px solid var(--line-2);
|
||||
}
|
||||
figcaption {
|
||||
margin-top: 10px;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,110 @@
|
||||
<script lang="ts">
|
||||
import type { Entity, Persona } from '#lib/mock.js';
|
||||
import Mark from './Mark.svelte';
|
||||
|
||||
let {
|
||||
entity,
|
||||
persona,
|
||||
color,
|
||||
text,
|
||||
kicker = 'Треш-ток'
|
||||
}: { entity: Entity; persona: Persona; color: 'w' | 'b'; text: string; kicker?: string } = $props();
|
||||
</script>
|
||||
|
||||
{#key text}
|
||||
<div class="lt" style:--c={color === 'w' ? 'var(--white-corner)' : 'var(--black-corner)'}>
|
||||
<div class="name">
|
||||
<Mark {entity} size={44} corner={color === 'w' ? 'white' : 'black'} />
|
||||
<div class="who">
|
||||
<b class="display">{entity.name}</b>
|
||||
<span class="kicker">{persona} · {color === 'w' ? 'белые' : 'чёрные'}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quote">
|
||||
<span class="k display">{kicker}</span>
|
||||
<p>«{text}»</p>
|
||||
</div>
|
||||
</div>
|
||||
{/key}
|
||||
|
||||
<style>
|
||||
.lt {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
align-items: stretch;
|
||||
animation: stinger-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
|
||||
}
|
||||
.name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 6px 22px 6px 8px;
|
||||
background: linear-gradient(180deg, #1a1f2b, #10131b);
|
||||
border-left: 4px solid var(--c);
|
||||
clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
|
||||
margin-right: -14px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.who {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.1;
|
||||
gap: 3px;
|
||||
}
|
||||
.who b {
|
||||
font-size: 17px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.quote {
|
||||
background: #f3f4f8;
|
||||
color: #0a0b10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 6px 16px 6px 28px;
|
||||
clip-path: polygon(14px 0, 100% 0, 100% 100%, 0 100%);
|
||||
min-width: 0;
|
||||
}
|
||||
.quote .k {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.18em;
|
||||
color: #fff;
|
||||
background: var(--c);
|
||||
padding: 3px 7px 2px;
|
||||
clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
|
||||
flex: 0 0 auto;
|
||||
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
.quote p {
|
||||
margin: 0;
|
||||
font-size: 14.5px;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.lt {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.name {
|
||||
clip-path: none;
|
||||
margin-right: 0;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.quote {
|
||||
clip-path: none;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
.quote p {
|
||||
font-size: 13.5px;
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
import type { Entity } from '#lib/mock.js';
|
||||
import { marks } from '#lib/icons.js';
|
||||
|
||||
let {
|
||||
entity,
|
||||
size = 40,
|
||||
corner,
|
||||
flat = false
|
||||
}: { entity: Entity; size?: number; corner?: 'white' | 'black'; flat?: boolean } = $props();
|
||||
|
||||
const m = $derived(entity.vendor === 'human' ? null : marks[entity.vendor]);
|
||||
const cornerVar = $derived(corner === 'white' ? 'var(--white-corner)' : corner === 'black' ? 'var(--black-corner)' : 'var(--line-2)');
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="mark"
|
||||
class:flat
|
||||
style:--s="{size}px"
|
||||
style:--edge={cornerVar}
|
||||
style:--brand={m ? m.hex : `hsl(${entity.avatar?.hue ?? 0} 60% 50%)`}
|
||||
title={entity.name}
|
||||
>
|
||||
{#if m}
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d={m.path} /></svg>
|
||||
{:else}
|
||||
<span class="initials display" style:font-size="{size * 0.42}px">{entity.avatar?.initials ?? '?'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.mark {
|
||||
width: var(--s);
|
||||
height: var(--s);
|
||||
flex: 0 0 auto;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
position: relative;
|
||||
background:
|
||||
linear-gradient(160deg, color-mix(in srgb, var(--brand) 38%, #0d1017), color-mix(in srgb, var(--brand) 10%, #0d1017));
|
||||
clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%);
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.mark::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 3px;
|
||||
background: var(--edge);
|
||||
transform: skewX(-12deg);
|
||||
transform-origin: top left;
|
||||
}
|
||||
.mark.flat {
|
||||
clip-path: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.mark.flat::after {
|
||||
display: none;
|
||||
}
|
||||
svg {
|
||||
width: 58%;
|
||||
height: 58%;
|
||||
fill: #fff;
|
||||
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5));
|
||||
}
|
||||
.initials {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
/** Static FEN renderer reusing the chessground piece sprites. Cheap enough for grids. */
|
||||
let { fen, lastMove, flip = false }: { fen: string; lastMove?: [string, string]; flip?: boolean } = $props();
|
||||
|
||||
const roles: Record<string, string> = { p: 'pawn', n: 'knight', b: 'bishop', r: 'rook', q: 'queen', k: 'king' };
|
||||
|
||||
const pieces = $derived.by(() => {
|
||||
const out: { role: string; color: string; x: number; y: number }[] = [];
|
||||
const rows = fen.split(' ')[0].split('/');
|
||||
rows.forEach((row, r) => {
|
||||
let f = 0;
|
||||
for (const ch of row) {
|
||||
if (/\d/.test(ch)) f += Number(ch);
|
||||
else {
|
||||
const color = ch === ch.toUpperCase() ? 'white' : 'black';
|
||||
out.push({ role: roles[ch.toLowerCase()], color, x: flip ? 7 - f : f, y: flip ? 7 - r : r });
|
||||
f++;
|
||||
}
|
||||
}
|
||||
});
|
||||
return out;
|
||||
});
|
||||
|
||||
function sq(k: string) {
|
||||
const x = k.charCodeAt(0) - 97;
|
||||
const y = 8 - Number(k[1]);
|
||||
return { x: flip ? 7 - x : x, y: flip ? 7 - y : y };
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="mini cg-wrap">
|
||||
<div class="grid">
|
||||
{#each Array(64) as _, i}
|
||||
<i class:dark={((i % 8) + Math.floor(i / 8)) % 2 === 1}></i>
|
||||
{/each}
|
||||
</div>
|
||||
{#if lastMove}
|
||||
{#each lastMove as k}
|
||||
{@const p = sq(k)}
|
||||
<b class="lm" style:transform="translate({p.x * 100}%, {p.y * 100}%)"></b>
|
||||
{/each}
|
||||
{/if}
|
||||
{#each pieces as p}
|
||||
<piece class="{p.role} {p.color}" style:transform="translate({p.x * 100}%, {p.y * 100}%)"></piece>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.mini {
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #aeb6c9;
|
||||
}
|
||||
.grid {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(8, 1fr);
|
||||
}
|
||||
.grid i.dark {
|
||||
background: #343b4f;
|
||||
}
|
||||
.lm {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 12.5%;
|
||||
height: 12.5%;
|
||||
background: rgba(255, 201, 60, 0.45);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,230 @@
|
||||
<script lang="ts">
|
||||
import type { Game } from '#lib/mock.js';
|
||||
import { clsMeta, fmt } from '#lib/mock.js';
|
||||
import Thoughts from './Thoughts.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let {
|
||||
game,
|
||||
ply = $bindable(),
|
||||
open = $bindable<number | null>(null),
|
||||
livePly
|
||||
}: { game: Game; ply: number; open: number | null; livePly: number } = $props();
|
||||
|
||||
const rows = $derived.by(() => {
|
||||
const out: { no: number; w?: (typeof game.moves)[number]; b?: (typeof game.moves)[number] }[] = [];
|
||||
for (const m of game.moves) {
|
||||
let r = out[m.moveNo - 1];
|
||||
if (!r) r = out[m.moveNo - 1] = { no: m.moveNo };
|
||||
if (m.color === 'w') r.w = m;
|
||||
else r.b = m;
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
let scroller: HTMLDivElement;
|
||||
function select(p: number) {
|
||||
ply = p;
|
||||
open = open === p ? null : p;
|
||||
}
|
||||
$effect(() => {
|
||||
// keep current move visible; when thoughts are open, pin the row to the top so the panel is readable
|
||||
ply;
|
||||
open;
|
||||
tick().then(() => {
|
||||
const el = scroller?.querySelector('[data-ply="' + ply + '"]') as HTMLElement | null;
|
||||
if (!el) return;
|
||||
if (open === ply) {
|
||||
const row = el.closest('.row') as HTMLElement | null;
|
||||
scroller.scrollTo({ top: (row ?? el).offsetTop - 4, behavior: 'smooth' });
|
||||
} else el.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
const legend: (keyof typeof clsMeta)[] = ['brilliant', 'best', 'inaccuracy', 'mistake', 'blunder'];
|
||||
</script>
|
||||
|
||||
<div class="list">
|
||||
<div class="panel-head">
|
||||
<span>Ходы</span>
|
||||
<span class="legend">
|
||||
{#each legend as c}
|
||||
<span style:color={clsMeta[c].color} title={clsMeta[c].label}>{clsMeta[c].glyph}</span>
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
<div class="scroller" bind:this={scroller}>
|
||||
{#each rows as r}
|
||||
<div class="row" class:cur={r.w?.ply === ply || r.b?.ply === ply}>
|
||||
<span class="no mono">{r.no}</span>
|
||||
{#each ['w', 'b'] as const as c}
|
||||
{@const m = c === 'w' ? r.w : r.b}
|
||||
{#if m}
|
||||
<button
|
||||
class="mv"
|
||||
class:cur={m.ply === ply}
|
||||
class:live={m.ply === livePly}
|
||||
class:opened={open === m.ply}
|
||||
data-ply={m.ply}
|
||||
onclick={() => select(m.ply)}
|
||||
title="{clsMeta[m.cls].label} · {fmt.time(m.timeSec)} · {fmt.usd(m.costUsd)}"
|
||||
>
|
||||
<span class="san mono">{m.san}</span>
|
||||
{#if clsMeta[m.cls].glyph && m.cls !== 'book'}
|
||||
<span class="g" style:color={clsMeta[m.cls].color}>{clsMeta[m.cls].glyph}</span>
|
||||
{:else if m.cls === 'book'}
|
||||
<span class="g book">▫</span>
|
||||
{/if}
|
||||
<span class="t mono">{fmt.time(m.timeSec)}</span>
|
||||
{#if m.talk}<span class="bubble" title="треш-ток">“</span>{/if}
|
||||
<span class="chev" aria-hidden="true">▸</span>
|
||||
</button>
|
||||
{:else}
|
||||
<span class="mv empty"></span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{#if open && (r.w?.ply === open || r.b?.ply === open)}
|
||||
{@const m = r.w?.ply === open ? r.w : r.b}
|
||||
{#if m}<div class="exp"><Thoughts move={m} {game} /></div>{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
{#if livePly === game.moves.length && !game.result}
|
||||
<div class="row pending">
|
||||
<span class="no mono">{Math.ceil((game.moves.length + 1) / 2)}</span>
|
||||
{#if game.moves.length % 2 === 0}<span class="mv empty"></span>{/if}
|
||||
<span class="mv thinking"><span class="dots"><i></i><i></i><i></i></span> думает…</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.legend {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
.scroller {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 4px 0 8px;
|
||||
position: relative;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 34px 1fr 1fr;
|
||||
align-items: stretch;
|
||||
}
|
||||
.row.cur {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.no {
|
||||
color: var(--dim);
|
||||
font-size: 11px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.mv {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 8px;
|
||||
text-align: left;
|
||||
min-height: 30px;
|
||||
position: relative;
|
||||
border-left: 2px solid transparent;
|
||||
color: var(--text-2);
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.mv:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: var(--text);
|
||||
}
|
||||
.mv.cur {
|
||||
background: color-mix(in srgb, var(--gold) 14%, transparent);
|
||||
color: var(--text);
|
||||
border-left-color: var(--gold);
|
||||
}
|
||||
.mv.live .san::after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--live);
|
||||
margin-left: 4px;
|
||||
vertical-align: middle;
|
||||
animation: blink 1.2s steps(1) infinite;
|
||||
}
|
||||
.mv.opened .chev {
|
||||
transform: rotate(90deg);
|
||||
color: var(--gold);
|
||||
}
|
||||
.san {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
.g {
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
font-family: var(--display);
|
||||
}
|
||||
.g.book {
|
||||
color: var(--dim);
|
||||
}
|
||||
.t {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: var(--dim);
|
||||
}
|
||||
.bubble {
|
||||
font-family: Georgia, serif;
|
||||
color: var(--muted);
|
||||
font-size: 16px;
|
||||
line-height: 0;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.chev {
|
||||
font-size: 9px;
|
||||
color: var(--dim);
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
.exp {
|
||||
padding: 0 8px 0 10px;
|
||||
}
|
||||
.pending .thinking {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
cursor: default;
|
||||
}
|
||||
.dots {
|
||||
display: inline-flex;
|
||||
gap: 3px;
|
||||
}
|
||||
.dots i {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
border-radius: 50%;
|
||||
background: var(--live);
|
||||
animation: blink 1s steps(1) infinite;
|
||||
}
|
||||
.dots i:nth-child(2) {
|
||||
animation-delay: 0.33s;
|
||||
}
|
||||
.dots i:nth-child(3) {
|
||||
animation-delay: 0.66s;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,169 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { liveGames } from '#lib/mock.js';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let now = $state(new Date());
|
||||
onMount(() => {
|
||||
const t = setInterval(() => (now = new Date()), 1000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
const clock = $derived(now.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit', second: '2-digit' }));
|
||||
|
||||
const links = [
|
||||
{ href: '/', label: 'Эфир' },
|
||||
{ href: '/leaderboard', label: 'Таблица' },
|
||||
{ href: '/games', label: 'Архив' },
|
||||
{ href: '/admin', label: 'Админ' }
|
||||
];
|
||||
const path = $derived(page.url.pathname);
|
||||
const active = (href: string) => (href === '/' ? path === '/' : path.startsWith(href));
|
||||
</script>
|
||||
|
||||
<header class="nav">
|
||||
<div class="inner">
|
||||
<a href="/" class="logo display" aria-label="AI·CHESS">
|
||||
<span class="ai">AI</span><span class="dot">·</span><span class="chess">CHESS</span>
|
||||
<span class="tag live"><span class="live-dot"></span>Эфир</span>
|
||||
</a>
|
||||
<nav>
|
||||
{#each links as l}
|
||||
<a href={l.href} class="display" class:active={active(l.href)}>{l.label}</a>
|
||||
{/each}
|
||||
</nav>
|
||||
<div class="right">
|
||||
<span class="onair">
|
||||
<span class="n display">{liveGames.length}</span>
|
||||
<span class="k kicker">в эфире</span>
|
||||
</span>
|
||||
<span class="clock mono">{clock}</span>
|
||||
<a href="/new" class="btn primary sm">Новый матч</a>
|
||||
<a href="/login" class="avatar" title="danosito" style:--hue="32">Д</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
background: linear-gradient(180deg, rgba(8, 9, 14, 0.96), rgba(8, 9, 14, 0.88));
|
||||
backdrop-filter: blur(10px);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.inner {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
height: 52px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 28px;
|
||||
}
|
||||
.logo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.logo .ai {
|
||||
color: var(--gold);
|
||||
}
|
||||
.logo .dot {
|
||||
color: var(--dim);
|
||||
margin: 0 1px;
|
||||
}
|
||||
.logo .tag {
|
||||
margin-left: 10px;
|
||||
font-size: 10px;
|
||||
}
|
||||
nav {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
height: 100%;
|
||||
}
|
||||
nav a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.12em;
|
||||
color: var(--muted);
|
||||
position: relative;
|
||||
height: 52px;
|
||||
}
|
||||
nav a:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
nav a.active {
|
||||
color: var(--text);
|
||||
}
|
||||
nav a.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
bottom: -1px;
|
||||
height: 3px;
|
||||
background: var(--gold);
|
||||
transform: skewX(-12deg);
|
||||
}
|
||||
.right {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.onair {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
.onair .n {
|
||||
font-size: 18px;
|
||||
color: var(--live);
|
||||
}
|
||||
.clock {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-family: var(--display);
|
||||
font-weight: 700;
|
||||
background: linear-gradient(160deg, hsl(var(--hue) 70% 55%), hsl(var(--hue) 60% 35%));
|
||||
clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.inner {
|
||||
gap: 12px;
|
||||
padding: 0 12px;
|
||||
}
|
||||
nav a {
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.clock,
|
||||
.onair .k,
|
||||
.right .btn {
|
||||
display: none;
|
||||
}
|
||||
.logo .tag {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
nav a:nth-child(n + 3) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,150 @@
|
||||
<script lang="ts">
|
||||
import type { Entity } from '#lib/mock.js';
|
||||
|
||||
let {
|
||||
white,
|
||||
black,
|
||||
pred,
|
||||
locked = false,
|
||||
result,
|
||||
compact = false
|
||||
}: {
|
||||
white: Entity;
|
||||
black: Entity;
|
||||
pred: { white: number; draw: number; black: number; total: number; mine?: 'white' | 'draw' | 'black' };
|
||||
locked?: boolean;
|
||||
result?: '1-0' | '0-1' | '½-½';
|
||||
compact?: boolean;
|
||||
} = $props();
|
||||
|
||||
let mine = $state(pred.mine);
|
||||
const outcome = $derived(result === '1-0' ? 'white' : result === '0-1' ? 'black' : result === '½-½' ? 'draw' : undefined);
|
||||
const won = $derived(outcome && mine === outcome);
|
||||
</script>
|
||||
|
||||
<div class="pred" class:compact>
|
||||
<div class="panel-head">
|
||||
<span>{compact ? 'Прогноз' : 'Прогноз зрителей'}</span>
|
||||
<span class="st kicker">
|
||||
{#if result}итог{:else if locked}<span class="lock">🔒</span> заблокирован{:else}открыт{/if}
|
||||
· {pred.total}
|
||||
</span>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="bar">
|
||||
<span class="w" style:width="{pred.white}%" class:win={outcome === 'white'}></span>
|
||||
<span class="d" style:width="{pred.draw}%" class:win={outcome === 'draw'}></span>
|
||||
<span class="b" style:width="{pred.black}%" class:win={outcome === 'black'}></span>
|
||||
</div>
|
||||
<div class="opts">
|
||||
{#each [['white', white.short, pred.white], ['draw', 'Ничья', pred.draw], ['black', black.short, pred.black]] as const as [k, label, v]}
|
||||
<button class="opt {k}" class:mine={mine === k} class:hit={outcome === k} disabled={locked || !!result} onclick={() => (mine = k)}>
|
||||
<span class="pct display tnum">{v}%</span>
|
||||
<span class="lbl">{label}</span>
|
||||
{#if mine === k}<span class="tag gold">вы</span>{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{#if result}
|
||||
<div class="verdict" class:won>
|
||||
{#if won}Вы угадали · <b>+{mine === 'draw' ? 40 : 30} очков</b>{:else}Не угадали · 0 очков. Бывает.{/if}
|
||||
</div>
|
||||
{:else if locked}
|
||||
<div class="verdict dim">Прогнозы закрыты на старте партии. Ставка — {mine ? (mine === 'white' ? white.short : mine === 'black' ? black.short : 'ничья') : 'не сделана'}.</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.body {
|
||||
padding: 10px;
|
||||
}
|
||||
.bar {
|
||||
display: flex;
|
||||
height: 10px;
|
||||
gap: 2px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.bar span {
|
||||
display: block;
|
||||
transition: width 0.4s;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.bar .w {
|
||||
background: #e9ecf3;
|
||||
}
|
||||
.bar .d {
|
||||
background: var(--dim);
|
||||
}
|
||||
.bar .b {
|
||||
background: #3a4153;
|
||||
}
|
||||
.bar span.win {
|
||||
box-shadow: 0 0 0 1px var(--gold), 0 0 12px var(--gold);
|
||||
}
|
||||
.opts {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 4px;
|
||||
}
|
||||
.opt {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 1px;
|
||||
padding: 7px 8px 6px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--line);
|
||||
position: relative;
|
||||
text-align: left;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.opt:not(:disabled):hover {
|
||||
border-color: var(--line-2);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.opt:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
.opt.mine {
|
||||
border-color: var(--gold);
|
||||
}
|
||||
.opt.hit {
|
||||
background: color-mix(in srgb, var(--gold) 12%, transparent);
|
||||
}
|
||||
.opt .pct {
|
||||
font-size: 18px;
|
||||
}
|
||||
.opt .lbl {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
font-family: var(--display);
|
||||
}
|
||||
.opt .tag {
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
right: -1px;
|
||||
font-size: 9px;
|
||||
padding: 2px 6px 1px;
|
||||
clip-path: none;
|
||||
}
|
||||
.verdict {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--text-2);
|
||||
}
|
||||
.verdict.won {
|
||||
color: var(--gold);
|
||||
}
|
||||
.verdict.dim {
|
||||
color: var(--muted);
|
||||
}
|
||||
.lock {
|
||||
font-size: 10px;
|
||||
}
|
||||
.compact .opt .pct {
|
||||
font-size: 15px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,386 @@
|
||||
<script lang="ts">
|
||||
import type { Game } from '#lib/mock.js';
|
||||
import { fmt, accuracy } from '#lib/mock.js';
|
||||
import Mark from './Mark.svelte';
|
||||
|
||||
let {
|
||||
game,
|
||||
ply,
|
||||
thinkingSec = 0,
|
||||
over = false
|
||||
}: { game: Game; ply: number; thinkingSec?: number; over?: boolean } = $props();
|
||||
|
||||
const shown = $derived(game.moves.slice(0, ply));
|
||||
const last = $derived(shown[shown.length - 1]);
|
||||
const turn = $derived<'w' | 'b'>(last ? (last.color === 'w' ? 'b' : 'w') : 'w');
|
||||
const moveNo = $derived(last ? (last.color === 'b' ? last.moveNo + 1 : last.moveNo) : 1);
|
||||
const evalCp = $derived(last?.evalCp ?? 20);
|
||||
const accW = $derived(accuracy(shown, 'w'));
|
||||
const accB = $derived(accuracy(shown, 'b'));
|
||||
const costW = $derived(shown.filter((m) => m.color === 'w').reduce((a, m) => a + m.costUsd, 0));
|
||||
const costB = $derived(shown.filter((m) => m.color === 'b').reduce((a, m) => a + m.costUsd, 0));
|
||||
const lastTimeW = $derived([...shown].reverse().find((m) => m.color === 'w')?.timeSec ?? 0);
|
||||
const lastTimeB = $derived([...shown].reverse().find((m) => m.color === 'b')?.timeSec ?? 0);
|
||||
const isLive = $derived(!over && ply === game.moves.length);
|
||||
</script>
|
||||
|
||||
{#snippet side(color: 'w' | 'b')}
|
||||
{@const e = color === 'w' ? game.white : game.black}
|
||||
{@const persona = color === 'w' ? game.whitePersona : game.blackPersona}
|
||||
{@const acc = color === 'w' ? accW : accB}
|
||||
{@const cost = color === 'w' ? costW : costB}
|
||||
{@const myTurn = turn === color && isLive}
|
||||
{@const won = over && ((game.result === '1-0' && color === 'w') || (game.result === '0-1' && color === 'b'))}
|
||||
<div class="side {color}" class:turn={myTurn} class:won>
|
||||
<div class="id">
|
||||
<Mark entity={e} size={52} corner={color === 'w' ? 'white' : 'black'} />
|
||||
<div class="who">
|
||||
<div class="name display">
|
||||
<span class="full">{e.name}</span><span class="shortn">{e.short}</span>
|
||||
{#if e.variant}<span class="var" class:max={e.variant === 'MAX'}>{e.variant}</span>{/if}
|
||||
</div>
|
||||
<div class="sub">
|
||||
<span class="rating tnum">{e.rating}</span>
|
||||
<span class="sep">·</span>
|
||||
<span>{persona}</span>
|
||||
<span class="sep">·</span>
|
||||
<span class="col">{color === 'w' ? 'белые' : 'чёрные'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<div class="stat">
|
||||
<span class="k kicker">Точность</span>
|
||||
<span class="v display tnum" style:color={acc >= 90 ? 'var(--good)' : acc >= 80 ? 'var(--text)' : 'var(--warn)'}>{acc.toFixed(1)}<small>%</small></span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="k kicker">Расход</span>
|
||||
<span class="v display tnum">{fmt.usd(cost)}</span>
|
||||
</div>
|
||||
<div class="stat timer" class:lit={myTurn}>
|
||||
<span class="k kicker">{myTurn ? 'Думает' : won ? 'Победа' : 'Ход за'}</span>
|
||||
<span class="v display tnum">
|
||||
{#if myTurn}{fmt.time(thinkingSec)}{:else if won}★{:else}{fmt.time(color === 'w' ? lastTimeW : lastTimeB)}{/if}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
<div class="bug" class:over>
|
||||
{@render side('w')}
|
||||
<div class="center">
|
||||
{#if over}
|
||||
<div class="res display">{game.result?.replace('-', '–')}</div>
|
||||
<div class="lbl kicker">Финал</div>
|
||||
{:else}
|
||||
<div class="mv display tnum">{moveNo}</div>
|
||||
<div class="lbl kicker">ход</div>
|
||||
<div class="ev display tnum" class:neg={evalCp < 0}>{fmt.evalStr(evalCp)}</div>
|
||||
{/if}
|
||||
</div>
|
||||
{@render side('b')}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.bug {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 112px 1fr;
|
||||
align-items: stretch;
|
||||
background: linear-gradient(180deg, #141824, #0d1018);
|
||||
border: 1px solid var(--line);
|
||||
border-top: 2px solid var(--line-2);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.bug::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
linear-gradient(90deg, color-mix(in srgb, var(--white-corner) 14%, transparent), transparent 35%),
|
||||
linear-gradient(270deg, color-mix(in srgb, var(--black-corner) 14%, transparent), transparent 35%);
|
||||
pointer-events: none;
|
||||
}
|
||||
.side {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 10px 16px;
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
}
|
||||
.side.b {
|
||||
flex-direction: row-reverse;
|
||||
text-align: right;
|
||||
}
|
||||
.side.b .id {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.side::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 3px;
|
||||
background: var(--white-corner);
|
||||
opacity: 0.35;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
.side.b::after {
|
||||
background: var(--black-corner);
|
||||
}
|
||||
.side.turn::after,
|
||||
.side.won::after {
|
||||
opacity: 1;
|
||||
box-shadow: 0 0 18px currentColor;
|
||||
}
|
||||
.id {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.side.b .name {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.var {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.14em;
|
||||
padding: 3px 6px 2px;
|
||||
background: var(--panel-3);
|
||||
color: var(--text-2);
|
||||
clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
|
||||
}
|
||||
.var.max {
|
||||
background: var(--gold);
|
||||
color: #140f00;
|
||||
}
|
||||
.shortn {
|
||||
display: none;
|
||||
}
|
||||
.sub {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-top: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.side.b .sub {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.rating {
|
||||
color: var(--text-2);
|
||||
font-weight: 600;
|
||||
}
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
align-items: center;
|
||||
}
|
||||
.side.b .stats {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
min-width: 56px;
|
||||
}
|
||||
.side.b .stat {
|
||||
align-items: flex-end;
|
||||
}
|
||||
.stat .v {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.stat .v small {
|
||||
font-size: 12px;
|
||||
margin-left: 1px;
|
||||
}
|
||||
.timer {
|
||||
padding: 6px 10px 5px;
|
||||
border: 1px solid var(--line);
|
||||
min-width: 84px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.timer.lit {
|
||||
border-color: var(--live);
|
||||
background: color-mix(in srgb, var(--live) 18%, transparent);
|
||||
}
|
||||
.timer.lit .k {
|
||||
color: var(--live);
|
||||
animation: blink 1.2s steps(1) infinite;
|
||||
}
|
||||
.timer.lit .v {
|
||||
color: #fff;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0;
|
||||
background: #05060a;
|
||||
position: relative;
|
||||
border-left: 1px solid var(--line);
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.center::before,
|
||||
.center::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 10px;
|
||||
background: var(--gold);
|
||||
opacity: 0.9;
|
||||
}
|
||||
.center::before {
|
||||
left: -6px;
|
||||
transform: skewX(-12deg);
|
||||
}
|
||||
.center::after {
|
||||
right: -6px;
|
||||
transform: skewX(-12deg);
|
||||
}
|
||||
.mv {
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
.lbl {
|
||||
font-size: 9px;
|
||||
}
|
||||
.ev {
|
||||
margin-top: 4px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px 1px;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
.ev.neg {
|
||||
background: #1c1f28;
|
||||
color: #fff;
|
||||
box-shadow: inset 0 0 0 1px var(--line-2);
|
||||
}
|
||||
.res {
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
color: var(--gold);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.stats .stat:not(.timer) {
|
||||
display: none;
|
||||
}
|
||||
.name {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.bug {
|
||||
grid-template-columns: 1fr 58px 1fr;
|
||||
}
|
||||
.side {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
padding: 8px 8px 10px;
|
||||
}
|
||||
.side.b {
|
||||
flex-direction: column;
|
||||
}
|
||||
.side.b .id {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.id {
|
||||
gap: 8px;
|
||||
}
|
||||
.id :global(.mark) {
|
||||
--s: 34px;
|
||||
}
|
||||
.full {
|
||||
display: none;
|
||||
}
|
||||
.shortn {
|
||||
display: inline;
|
||||
}
|
||||
.who {
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
font-size: 13px;
|
||||
white-space: normal;
|
||||
line-height: 1.05;
|
||||
gap: 5px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.side.b .name {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.var {
|
||||
font-size: 8px;
|
||||
padding: 2px 4px 1px;
|
||||
}
|
||||
.sub {
|
||||
font-size: 10px;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
white-space: normal;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.sub .col,
|
||||
.sub .sep:last-of-type {
|
||||
display: none;
|
||||
}
|
||||
.stats {
|
||||
gap: 6px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.side.b .stats {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.stats .stat {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
}
|
||||
.stats .stat:nth-child(2) {
|
||||
display: none;
|
||||
}
|
||||
.stat .k {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
.stat .v {
|
||||
font-size: 15px;
|
||||
}
|
||||
.timer {
|
||||
min-width: 60px;
|
||||
padding: 3px 6px 2px;
|
||||
}
|
||||
.mv {
|
||||
font-size: 22px;
|
||||
}
|
||||
.ev {
|
||||
font-size: 12px;
|
||||
}
|
||||
.res {
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,91 @@
|
||||
<script lang="ts">
|
||||
import type { Game } from '#lib/mock.js';
|
||||
import Mark from './Mark.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let { game, ply, onselect }: { game: Game; ply: number; onselect?: (p: number) => void } = $props();
|
||||
const items = $derived(game.moves.slice(0, ply).filter((m) => m.talk).reverse());
|
||||
</script>
|
||||
|
||||
<div class="feed">
|
||||
<div class="panel-head">
|
||||
<span>Треш-ток</span>
|
||||
<span class="cnt mono">{items.length}</span>
|
||||
</div>
|
||||
<div class="scroller">
|
||||
{#each items as m (m.ply)}
|
||||
{@const e = m.color === 'w' ? game.white : game.black}
|
||||
<button class="msg {m.color}" onclick={() => onselect?.(m.ply)}>
|
||||
<Mark entity={e} size={28} corner={m.color === 'w' ? 'white' : 'black'} />
|
||||
<div class="b">
|
||||
<div class="top">
|
||||
<b class="display">{e.short}</b>
|
||||
<span class="mono">{m.moveNo}{m.color === 'w' ? '.' : '…'}{m.san}</span>
|
||||
</div>
|
||||
<p>{m.talk}</p>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.feed {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.cnt {
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.scroller {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.msg {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 8px;
|
||||
text-align: left;
|
||||
padding: 6px 8px 7px 6px;
|
||||
background: rgba(255, 255, 255, 0.025);
|
||||
border-left: 2px solid var(--white-corner);
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.msg.b {
|
||||
border-left-color: var(--black-corner);
|
||||
}
|
||||
.msg:hover {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.msg:first-child {
|
||||
background: rgba(255, 201, 60, 0.06);
|
||||
}
|
||||
.top {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.top b {
|
||||
font-size: 12px;
|
||||
color: var(--text-2);
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
p {
|
||||
margin: 2px 0 0;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.4;
|
||||
color: var(--text);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,246 @@
|
||||
<script lang="ts">
|
||||
import type { Game, MoveRec } from '#lib/mock.js';
|
||||
import { fmt, clsMeta } from '#lib/mock.js';
|
||||
import Mark from './Mark.svelte';
|
||||
|
||||
let { move, game }: { move: MoveRec; game: Game } = $props();
|
||||
let tab = $state<'reason' | 'tools' | 'ctx'>('reason');
|
||||
const e = $derived(move.color === 'w' ? game.white : game.black);
|
||||
const persona = $derived(move.color === 'w' ? game.whitePersona : game.blackPersona);
|
||||
</script>
|
||||
|
||||
<div class="th" style:--c={move.color === 'w' ? 'var(--white-corner)' : 'var(--black-corner)'}>
|
||||
<div class="head">
|
||||
<span class="replay display">Мысли</span>
|
||||
<Mark entity={e} size={22} corner={move.color === 'w' ? 'white' : 'black'} />
|
||||
<b class="display">{e.short}</b>
|
||||
<span class="mv mono">{move.moveNo}{move.color === 'w' ? '.' : '…'}{move.san}</span>
|
||||
{#if clsMeta[move.cls].glyph}<span class="cls" style:color={clsMeta[move.cls].color}>{clsMeta[move.cls].glyph} {clsMeta[move.cls].label}</span>{/if}
|
||||
<span class="meta mono">
|
||||
<span title="время">⏱ {fmt.time(move.timeSec)}</span>
|
||||
<span title="токены">{fmt.tok(move.tokens)} tok</span>
|
||||
<span title="стоимость">{fmt.usd(move.costUsd)}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="tabs">
|
||||
<button class:on={tab === 'reason'} onclick={() => (tab = 'reason')}>Рассуждение</button>
|
||||
<button class:on={tab === 'tools'} onclick={() => (tab = 'tools')}>Тулы <i>{move.thought.tools.length}</i></button>
|
||||
<button class:on={tab === 'ctx'} onclick={() => (tab = 'ctx')}>Контекст</button>
|
||||
</div>
|
||||
<div class="body">
|
||||
{#if tab === 'reason'}
|
||||
{#if move.thought.noteFromPast && game.flags.notes}
|
||||
<div class="note past"><span class="kicker">Заметка из прошлого хода</span>{move.thought.noteFromPast}</div>
|
||||
{/if}
|
||||
<p class="summary">{move.thought.summary}</p>
|
||||
{#if move.bestSan}
|
||||
<p class="engine"><span class="kicker">Stockfish</span> лучше было <b class="mono">{move.bestSan}</b></p>
|
||||
{/if}
|
||||
{#if move.talk}
|
||||
<p class="talk"><span class="kicker">{persona}</span>«{move.talk}»</p>
|
||||
{/if}
|
||||
{#if move.thought.note && game.flags.notes}
|
||||
<div class="note"><span class="kicker">Заметка себе</span>{move.thought.note}</div>
|
||||
{/if}
|
||||
{:else if tab === 'tools'}
|
||||
<ol class="tools">
|
||||
{#each move.thought.tools as t, i}
|
||||
<li>
|
||||
<div class="call mono">
|
||||
<span class="idx">{i + 1}</span>
|
||||
<span class="fn">{t.name}</span>(<span class="args">{t.args}</span>)
|
||||
<span class="ms">{t.ms} ms</span>
|
||||
</div>
|
||||
<pre class="out mono">{t.result}</pre>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
{:else}
|
||||
<p class="ctx-note">Ровно то, что модель получила перед ходом. Контекст свежий: памяти о прошлых ходах нет.</p>
|
||||
<pre class="ctx mono">{move.thought.context}</pre>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.th {
|
||||
margin: 4px 0 10px;
|
||||
background: #08090e;
|
||||
border: 1px solid var(--line-2);
|
||||
border-left: 4px solid var(--c);
|
||||
animation: stinger-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.th::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(100deg, transparent 30%, rgba(255, 201, 60, 0.18) 50%, transparent 70%);
|
||||
background-size: 200% 100%;
|
||||
animation: flash 0.9s ease-out 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.replay {
|
||||
background: var(--gold);
|
||||
color: #140f00;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.16em;
|
||||
padding: 3px 8px 2px;
|
||||
clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
|
||||
}
|
||||
.head b {
|
||||
font-size: 13px;
|
||||
}
|
||||
.mv {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
.cls {
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
font-size: 11px;
|
||||
}
|
||||
.meta {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.tabs button {
|
||||
font-family: var(--display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
font-size: 11px;
|
||||
padding: 8px 12px 7px;
|
||||
color: var(--muted);
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1px;
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
.tabs button i {
|
||||
font-style: normal;
|
||||
background: var(--panel-3);
|
||||
padding: 0 5px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.tabs button.on {
|
||||
color: var(--text);
|
||||
border-bottom-color: var(--gold);
|
||||
}
|
||||
.body {
|
||||
padding: 10px 12px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.summary {
|
||||
margin: 0 0 8px;
|
||||
line-height: 1.55;
|
||||
color: var(--text);
|
||||
}
|
||||
.engine,
|
||||
.talk {
|
||||
margin: 6px 0 0;
|
||||
color: var(--text-2);
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
}
|
||||
.talk {
|
||||
font-style: italic;
|
||||
}
|
||||
.note {
|
||||
margin-top: 10px;
|
||||
padding: 8px 10px;
|
||||
background: color-mix(in srgb, var(--gold) 10%, transparent);
|
||||
border-left: 2px solid var(--gold);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
color: var(--text);
|
||||
}
|
||||
.note .kicker {
|
||||
color: var(--gold);
|
||||
}
|
||||
.note.past {
|
||||
margin: 0 0 10px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-left-color: var(--dim);
|
||||
color: var(--text-2);
|
||||
}
|
||||
.note.past .kicker {
|
||||
color: var(--muted);
|
||||
}
|
||||
.tools {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.call {
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.idx {
|
||||
color: var(--dim);
|
||||
min-width: 14px;
|
||||
}
|
||||
.fn {
|
||||
color: var(--ice);
|
||||
font-weight: 500;
|
||||
}
|
||||
.args {
|
||||
color: var(--text-2);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.ms {
|
||||
margin-left: auto;
|
||||
color: var(--dim);
|
||||
font-size: 11px;
|
||||
}
|
||||
.out,
|
||||
.ctx {
|
||||
margin: 4px 0 0 20px;
|
||||
padding: 6px 8px;
|
||||
background: #000;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--good);
|
||||
font-size: 11.5px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
max-height: 160px;
|
||||
overflow: auto;
|
||||
}
|
||||
.ctx {
|
||||
margin-left: 0;
|
||||
color: var(--text-2);
|
||||
max-height: 300px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.ctx-note {
|
||||
margin: 0 0 8px;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||