New capturing animation added

This commit is contained in:
2026-10-19 14:26:34 +03:30
parent be54bdd5a7
commit 48c0ad1265
13 changed files with 981 additions and 136 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "chess-client", "name": "chess-client",
"version": "1.4.0", "version": "1.6.0",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+86 -7
View File
@@ -62,15 +62,31 @@ const host = connectHost({
prevS = S; prevS = S;
S = env.body as GameSnapshot; S = env.body as GameSnapshot;
detectMoveEvents(prevS, S);
if (S.turn !== S.me) { if (S.turn !== S.me) {
selectedSquare = ""; selectedSquare = "";
legalTargets = []; legalTargets = [];
pendingPromo = null; pendingPromo = null;
} }
// Pre-compute lastMove so cell highlight renders immediately in updateUI
if (prevS && S) {
const oldBoard = new Map(prevS.board.map((c) => [c.square, c]));
const newBoard = new Map(S.board.map((c) => [c.square, c]));
let f = "";
let t = "";
for (const [sq, newCell] of newBoard.entries()) {
const oldCell = oldBoard.get(sq);
if (!oldCell) continue;
if (oldCell.color && !newCell.color) f = sq;
else if (newCell.color && (!oldCell.color || oldCell.color !== newCell.color || oldCell.type !== newCell.type)) t = sq;
}
if (f && t) {
lastMove = { from: f, to: t };
}
}
updateUI(); updateUI();
detectMoveEvents(prevS, S);
} }
}, },
onAck(a) { onAck(a) {
@@ -93,6 +109,7 @@ function detectMoveEvents(oldState: GameSnapshot | null, newState: GameSnapshot)
let movedFrom = ""; let movedFrom = "";
let movedTo = ""; let movedTo = "";
let capturedPiece: CellInfo | null = null; let capturedPiece: CellInfo | null = null;
let capturedSquare = "";
for (const [sq, newCell] of newBoard.entries()) { for (const [sq, newCell] of newBoard.entries()) {
const oldCell = oldBoard.get(sq); const oldCell = oldBoard.get(sq);
@@ -106,13 +123,30 @@ function detectMoveEvents(oldState: GameSnapshot | null, newState: GameSnapshot)
movedTo = sq; movedTo = sq;
if (oldCell.color && oldCell.color !== newCell.color) { if (oldCell.color && oldCell.color !== newCell.color) {
capturedPiece = oldCell; capturedPiece = oldCell;
capturedSquare = sq;
}
}
}
// Handle en-passant where captured pawn square is different from movedTo
if (!capturedPiece && movedFrom && movedTo) {
for (const [sq, newCell] of newBoard.entries()) {
const oldCell = oldBoard.get(sq);
if (!oldCell) continue;
if (oldCell.color && !newCell.color && sq !== movedFrom) {
capturedPiece = oldCell;
capturedSquare = sq;
break;
} }
} }
} }
if (movedFrom && movedTo) { if (movedFrom && movedTo) {
lastMove = { from: movedFrom, to: movedTo }; lastMove = { from: movedFrom, to: movedTo };
const targetCellEl = document.querySelector(`[data-square="${movedTo}"]`) as HTMLElement; const targetCellEl = document.querySelector(`[data-square="${movedTo}"]`) as HTMLElement | null;
const fromCellEl = document.querySelector(`[data-square="${movedFrom}"]`) as HTMLElement | null;
const boardGridEl = document.getElementById("board-grid");
const ghostLayerEl = document.getElementById("ghost-layer");
if (targetCellEl) { if (targetCellEl) {
const rect = targetCellEl.getBoundingClientRect(); const rect = targetCellEl.getBoundingClientRect();
@@ -124,21 +158,65 @@ function detectMoveEvents(oldState: GameSnapshot | null, newState: GameSnapshot)
if (capturedPiece) { if (capturedPiece) {
vfx.captureImpact(x, y, capturedPiece.color as "w" | "b"); vfx.captureImpact(x, y, capturedPiece.color as "w" | "b");
setTimeout(() => {
vfx?.dissolvePuff(x, y, capturedPiece!.color as "w" | "b");
}, 440);
} else { } else {
vfx.landingPuff(x, y); vfx.landingPuff(x, y);
} }
} }
// Add landing squash animation to arrived piece // Add strike / land animation to arrived piece
const pieceEl = targetCellEl.querySelector(".piece-wrapper"); const pieceEl = targetCellEl.querySelector(".piece-wrapper") as HTMLElement | null;
if (pieceEl) { if (pieceEl) {
pieceEl.classList.remove("anim-land"); pieceEl.classList.remove("anim-land", "anim-strike");
void (pieceEl as HTMLElement).offsetWidth; void pieceEl.offsetWidth;
if (capturedPiece) {
pieceEl.classList.add("anim-strike");
targetCellEl.classList.remove("anim-shudder");
void targetCellEl.offsetWidth;
targetCellEl.classList.add("anim-shudder");
} else {
pieceEl.classList.add("anim-land"); pieceEl.classList.add("anim-land");
} }
} }
} }
// Dramatic Topple & Dissolve animation for captured piece
if (capturedPiece && boardGridEl && ghostLayerEl) {
const toppleOnSq = capturedSquare || movedTo;
const capturedCellEl = document.querySelector(`[data-square="${toppleOnSq}"]`) as HTMLElement | null;
if (capturedCellEl) {
const boardRect = boardGridEl.getBoundingClientRect();
const cellRect = capturedCellEl.getBoundingClientRect();
// Determine knock-over direction (attacker kinetic force direction)
let toppleDir: "right" | "left" = "right";
if (fromCellEl) {
const fromRect = fromCellEl.getBoundingClientRect();
if (cellRect.left < fromRect.left - 4) {
toppleDir = "left";
}
}
const ghost = document.createElement("div");
ghost.className = `captured-ghost topple-${toppleDir}`;
ghost.style.left = `${cellRect.left - boardRect.left}px`;
ghost.style.top = `${cellRect.top - boardRect.top}px`;
ghost.style.width = `${cellRect.width}px`;
ghost.style.height = `${cellRect.height}px`;
const pieceSvg = getPieceSvg(capturedPiece.type as PieceType, capturedPiece.color as PieceColor);
ghost.innerHTML = `<div class="piece-wrapper">${pieceSvg}</div>`;
ghostLayerEl.appendChild(ghost);
setTimeout(() => {
ghost.remove();
}, 800);
}
}
}
// Victory celebration // Victory celebration
if (newState.phase === "over" && newState.winner !== null && !confettiTriggered) { if (newState.phase === "over" && newState.winner !== null && !confettiTriggered) {
confettiTriggered = true; confettiTriggered = true;
@@ -156,6 +234,7 @@ function setupDOM() {
<div class="board-container"> <div class="board-container">
<canvas id="vfx-canvas"></canvas> <canvas id="vfx-canvas"></canvas>
<div id="board-grid" class="board-grid"></div> <div id="board-grid" class="board-grid"></div>
<div id="ghost-layer" class="ghost-layer"></div>
</div> </div>
<div id="bottom-bar" class="player-bar"></div> <div id="bottom-bar" class="player-bar"></div>
<div id="modal-container"></div> <div id="modal-container"></div>
+247 -102
View File
@@ -1,119 +1,264 @@
/** /**
* High-quality vector SVGs for standard Chess pieces (Staunton design). * Dazzling 2D Chess Pieces — Master Artisan Imperial Edition
* Provides clean, crisp rendering at all DPRs and sizes. * Rich volumetric gradients, gold filigree, faceted gemstones, and crisp specular highlights.
*/ */
export type PieceType = "k" | "q" | "r" | "b" | "n" | "p"; export type PieceType = "k" | "q" | "r" | "b" | "n" | "p";
export type PieceColor = "w" | "b"; export type PieceColor = "w" | "b";
const PIECE_SVGS: Record<PieceType, { w: string; b: string }> = { const WHITE_DEFS = `
k: { <defs>
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg"> <linearGradient id="cp-w-body" x1="0%" y1="0%" x2="100%" y2="100%">
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"> <stop offset="0%" stop-color="#ffffff"/>
<path d="M22.5 11.63V6M20 8h5" stroke-linejoin="miter"/> <stop offset="35%" stop-color="#f8fafc"/>
<path d="M22.5 25s4.5-7.5 3-10.5c0 0-1-2.5-3-2.5s-3 2.5-3 2.5c-1.5 3 3 10.5 3 10.5" fill="#fff" stroke-linecap="butt" stroke-linejoin="miter"/> <stop offset="70%" stop-color="#e2e8f0"/>
<path d="M11.5 37c5.5 3.5 15.5 3.5 21 0v-7s9-4.5 6-10.5c-4-6.5-13.5-3.5-16 4V23.5c-2.5-7.5-12-10.5-16-4-3 6 6 10.5 6 10.5v7z" fill="#fff"/> <stop offset="100%" stop-color="#94a3b8"/>
<path d="M11.5 30c5.5-3 15.5-3 21 0m-21 3.5c5.5-3 15.5-3 21 0m-21 3.5c5.5-3 15.5-3 21 0"/> </linearGradient>
<linearGradient id="cp-w-spec" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.95"/>
<stop offset="60%" stop-color="#ffffff" stop-opacity="0.3"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-w-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fef08a"/>
<stop offset="30%" stop-color="#f59e0b"/>
<stop offset="70%" stop-color="#d97706"/>
<stop offset="100%" stop-color="#78350f"/>
</linearGradient>
<radialGradient id="cp-ruby" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#fda4af"/>
<stop offset="35%" stop-color="#f43f5e"/>
<stop offset="75%" stop-color="#be123c"/>
<stop offset="100%" stop-color="#4c0519"/>
</radialGradient>
<radialGradient id="cp-pearl" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="45%" stop-color="#fef08a"/>
<stop offset="85%" stop-color="#f59e0b"/>
<stop offset="100%" stop-color="#b45309"/>
</radialGradient>
</defs>
`;
const BLACK_DEFS = `
<defs>
<linearGradient id="cp-b-body" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#334155"/>
<stop offset="25%" stop-color="#1e293b"/>
<stop offset="65%" stop-color="#0f172a"/>
<stop offset="100%" stop-color="#020617"/>
</linearGradient>
<linearGradient id="cp-b-spec" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#94a3b8" stop-opacity="0.9"/>
<stop offset="45%" stop-color="#64748b" stop-opacity="0.35"/>
<stop offset="100%" stop-color="#0f172a" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-b-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fde047"/>
<stop offset="30%" stop-color="#eab308"/>
<stop offset="70%" stop-color="#ca8a04"/>
<stop offset="100%" stop-color="#581c87"/>
</linearGradient>
<radialGradient id="cp-sapphire" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#93c5fd"/>
<stop offset="35%" stop-color="#38bdf8"/>
<stop offset="75%" stop-color="#1d4ed8"/>
<stop offset="100%" stop-color="#091e60"/>
</radialGradient>
<radialGradient id="cp-amethyst" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#e9d5ff"/>
<stop offset="45%" stop-color="#a855f7"/>
<stop offset="85%" stop-color="#6b21a8"/>
<stop offset="100%" stop-color="#2e1065"/>
</radialGradient>
</defs>
`;
function buildPawnSvg(isWhite: boolean): string {
const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
const stroke = isWhite ? "#0f172a" : "#020617";
const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
const rimStroke = isWhite ? "#e2e8f0" : "#64748b";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="28" ry="3.5" fill="${goldGrad}"/>
<path d="M 27 82 C 29 74, 34 68, 38 52 C 40 44, 42 42, 42 42 L 58 42 C 58 42, 60 44, 62 52 C 66 68, 71 74, 73 82 Z" fill="${bodyGrad}"/>
<path d="M 33 80 C 35 73, 40 60, 42 50 C 45 49, 48 50, 48 51 C 45 61, 41 72, 38 80 Z" fill="${specGrad}" stroke="none"/>
<ellipse cx="50" cy="42" rx="14" ry="4" fill="${goldGrad}"/>
<ellipse cx="50" cy="39" rx="11" ry="3" fill="${bodyGrad}"/>
<circle cx="50" cy="24" r="14" fill="${bodyGrad}"/>
<ellipse cx="44" cy="18" rx="6" ry="3.5" transform="rotate(-30 44 18)" fill="#ffffff" opacity="${isWhite ? "0.85" : "0.5"}" stroke="none"/>
<circle cx="50" cy="9.5" r="2.5" fill="${goldGrad}"/>
<path d="M 21 89 C 30 85, 70 85, 79 89" fill="none" stroke="${rimStroke}" stroke-width="1.2" opacity="0.6"/>
</g> </g>
</svg>`, </svg>`;
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg"> }
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M22.5 11.63V6M20 8h5" stroke="#fff" stroke-linejoin="miter"/> function buildKnightSvg(isWhite: boolean): string {
<path d="M22.5 25s4.5-7.5 3-10.5c0 0-1-2.5-3-2.5s-3 2.5-3 2.5c-1.5 3 3 10.5 3 10.5" fill="#2d3038" stroke-linecap="butt" stroke-linejoin="miter"/> const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
<path d="M11.5 37c5.5 3.5 15.5 3.5 21 0v-7s9-4.5 6-10.5c-4-6.5-13.5-3.5-16 4V23.5c-2.5-7.5-12-10.5-16-4-3 6 6 10.5 6 10.5v7z" fill="#2d3038"/> const stroke = isWhite ? "#0f172a" : "#020617";
<path d="M11.5 30c5.5-3 15.5-3 21 0m-21 3.5c5.5-3 15.5-3 21 0m-21 3.5c5.5-3 15.5-3 21 0" stroke="#fff"/> const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
const eyeColor = isWhite ? "url(#cp-ruby)" : "url(#cp-sapphire)";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${goldGrad}"/>
<path d="M 25 82 C 32 72, 38 60, 34 50 C 31 46, 24 47, 18 43 C 14 40, 15 35, 19 32 C 24 29, 32 30, 36 24 C 40 18, 44 14, 52 11 L 55 18 C 58 14, 62 12, 65 14 C 67 15, 66 18, 64 22 C 74 26, 78 40, 77 56 C 76 68, 73 76, 75 82 Z" fill="${bodyGrad}"/>
<path d="M 64 22 C 70 24, 76 29, 78 36 C 73 34, 68 33, 65 34 C 72 38, 77 44, 78 52 C 73 50, 68 49, 65 51 C 72 55, 75 62, 76 70 C 72 68, 68 67, 66 69" fill="none" stroke="${goldGrad}" stroke-width="2.6"/>
<path d="M 36 24 C 44 32, 48 44, 45 52 C 40 56, 34 52, 34 50" fill="none" stroke="${stroke}" stroke-width="1.8"/>
<path d="M 52 24 C 58 34, 60 52, 58 72 C 54 74, 48 74, 46 72 C 50 56, 48 38, 44 26 Z" fill="${specGrad}" stroke="none"/>
<ellipse cx="20" cy="38" rx="2.5" ry="1.5" transform="rotate(-20 20 38)" fill="${stroke}"/>
<path d="M 17 41 C 21 44, 25 43, 27 41" fill="none" stroke="${stroke}" stroke-width="1.5"/>
<ellipse cx="36" cy="27" rx="3.5" ry="2.2" transform="rotate(-15 36 27)" fill="${eyeColor}"/>
<circle cx="35" cy="26" r="1" fill="#ffffff" stroke="none"/>
<path d="M 33 66 C 42 70, 58 70, 67 66 L 68 71 C 58 75, 42 75, 32 71 Z" fill="${goldGrad}"/>
<circle cx="50" cy="71" r="4.5" fill="${goldGrad}"/>
<circle cx="50" cy="71" r="2.5" fill="${eyeColor}"/>
</g> </g>
</svg>`, </svg>`;
}, }
q: {
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg"> function buildBishopSvg(isWhite: boolean): string {
<g fill="#fff" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"> const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
<path d="M8 12a2 2 0 1 1-4 0 2 2 0 1 1 4 0zm16.5-4.5a2 2 0 1 1-4 0 2 2 0 1 1 4 0zM41 12a2 2 0 1 1-4 0 2 2 0 1 1 4 0zM16 8.5a2 2 0 1 1-4 0 2 2 0 1 1 4 0zm17 0a2 2 0 1 1-4 0 2 2 0 1 1 4 0z"/> const stroke = isWhite ? "#0f172a" : "#020617";
<path d="M9 26c8.5-1.5 21-1.5 27 0l2-12-7 11V11l-5.5 13.5-3-15-3 15-5.5-13.5V25L7 14l2 12z" stroke-linecap="butt"/> const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
<path d="M9 26c0 2 1.5 2 2.5 4 1 1.5 1 1 .5 3.5-1.5 1-1.5 2.5-1.5 2.5-1.5 1.5.5 2.5.5 2.5 6.5 1 16.5 1 23 0 0 0 2-1 .5-2.5 0 0 0-1.5-1.5-2.5-.5-2.5-.5-2 .5-3.5 1-2 2.5-2 2.5-4-8.5-1.5-18.5-1.5-27 0z" stroke-linecap="butt"/> const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
<path d="M11 38.5a35 35 1 0 0 23 0" fill="none" stroke-linecap="butt"/> const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
<path d="M11 29a35 35 1 0 1 23 0M12.5 31.5h20M11.5 34.5a35 35 1 0 0 22 0M10.5 37.5a35 35 1 0 0 24 0" fill="none"/> const gemColor = isWhite ? "url(#cp-ruby)" : "url(#cp-sapphire)";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 20 90 C 22 84, 30 82, 50 82 C 70 82, 78 84, 80 90 L 80 93 C 80 95, 76 96, 50 96 C 24 96, 20 95, 20 93 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="27" ry="3.5" fill="${goldGrad}"/>
<path d="M 29 82 C 31 72, 38 64, 40 52 L 60 52 C 62 64, 69 72, 71 82 Z" fill="${bodyGrad}"/>
<path d="M 35 80 C 37 72, 42 62, 44 54 C 47 54, 49 55, 49 56 C 45 66, 42 74, 39 80 Z" fill="${specGrad}" stroke="none"/>
<path d="M 38 52 C 44 55, 56 55, 62 52 L 63 56 C 56 59, 44 59, 37 56 Z" fill="${goldGrad}"/>
<path d="M 36 50 C 33 42, 32 30, 42 19 C 46 15, 49 13, 50 13 C 51 13, 54 15, 58 19 C 68 30, 67 42, 64 50 Z" fill="${bodyGrad}"/>
<path d="M 58 22 L 40 40 L 44 43 L 61 24 Z" fill="${goldGrad}"/>
<path d="M 50 28 L 50 42 M 45 33 L 55 33" stroke="${goldGrad}" stroke-width="2.6"/>
<circle cx="50" cy="11" r="3.5" fill="${goldGrad}"/>
<circle cx="50" cy="11" r="1.8" fill="${gemColor}" stroke="none"/>
<path d="M 40 24 C 36 30, 36 40, 39 46 C 40 46, 42 45, 42 44 C 40 38, 41 30, 43 25 Z" fill="${specGrad}" stroke="none"/>
</g> </g>
</svg>`, </svg>`;
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg"> }
<g fill="#2d3038" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M8 12a2 2 0 1 1-4 0 2 2 0 1 1 4 0zm16.5-4.5a2 2 0 1 1-4 0 2 2 0 1 1 4 0zM41 12a2 2 0 1 1-4 0 2 2 0 1 1 4 0zM16 8.5a2 2 0 1 1-4 0 2 2 0 1 1 4 0zm17 0a2 2 0 1 1-4 0 2 2 0 1 1 4 0z"/> function buildRookSvg(isWhite: boolean): string {
<path d="M9 26c8.5-1.5 21-1.5 27 0l2-12-7 11V11l-5.5 13.5-3-15-3 15-5.5-13.5V25L7 14l2 12z" stroke-linecap="butt"/> const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
<path d="M9 26c0 2 1.5 2 2.5 4 1 1.5 1 1 .5 3.5-1.5 1-1.5 2.5-1.5 2.5-1.5 1.5.5 2.5.5 2.5 6.5 1 16.5 1 23 0 0 0 2-1 .5-2.5 0 0 0-1.5-1.5-2.5-.5-2.5-.5-2 .5-3.5 1-2 2.5-2 2.5-4-8.5-1.5-18.5-1.5-27 0z" stroke-linecap="butt"/> const stroke = isWhite ? "#0f172a" : "#020617";
<path d="M11 38.5a35 35 1 0 0 23 0" fill="none" stroke="#fff" stroke-linecap="butt"/> const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
<path d="M11 29a35 35 1 0 1 23 0M12.5 31.5h20M11.5 34.5a35 35 1 0 0 22 0M10.5 37.5a35 35 1 0 0 24 0" fill="none" stroke="#fff"/> const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${goldGrad}"/>
<path d="M 26 82 L 31 34 L 69 34 L 74 82 Z" fill="${bodyGrad}"/>
<path d="M 31 80 L 35 36 L 43 36 L 39 80 Z" fill="${specGrad}" stroke="none"/>
<path d="M 23 34 L 77 34 L 75 27 L 25 27 Z" fill="${goldGrad}"/>
<rect x="28" y="29" width="6" height="4" fill="${bodyGrad}"/>
<rect x="40" y="29" width="6" height="4" fill="${bodyGrad}"/>
<rect x="54" y="29" width="6" height="4" fill="${bodyGrad}"/>
<rect x="66" y="29" width="6" height="4" fill="${bodyGrad}"/>
<path d="M 24 27 L 24 14 L 33 14 L 33 20 L 44 20 L 44 14 L 56 14 L 56 20 L 67 20 L 67 14 L 76 14 L 76 27 Z" fill="${bodyGrad}"/>
<path d="M 23 14 L 34 14 M 43 14 L 57 14 M 66 14 L 77 14" stroke="${goldGrad}" stroke-width="2"/>
<path d="M 48 46 C 48 43, 52 43, 52 46 L 52 64 L 48 64 Z" fill="${stroke}"/>
<circle cx="50" cy="46" r="1.5" fill="${goldGrad}"/>
<path d="M 33 55 L 67 55" stroke="${stroke}" stroke-width="1.2" opacity="0.4"/>
</g> </g>
</svg>`, </svg>`;
}, }
r: {
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg"> function buildQueenSvg(isWhite: boolean): string {
<g fill="#fff" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"> const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
<path d="M9 39h27v-3H9v3zm3-3v-4.5h21V36H12zm2-4.5v-11h17v11H14z" stroke-linecap="butt"/> const stroke = isWhite ? "#0f172a" : "#020617";
<path d="M14 20.5h17M11 14h23l-2.5 6.5h-18L11 14z"/> const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
<path d="M12 10.5h4v3.5h-4zm7 0h7v3.5h-7zm10 0h4v3.5h-4z" stroke-linecap="butt"/> const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
<path d="M14 29.5v-1h17v1H14zm-1 3.5v-1h19v1H13z" fill="none"/> const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
const gemColor = isWhite ? "url(#cp-ruby)" : "url(#cp-sapphire)";
const pearlColor = isWhite ? "url(#cp-pearl)" : "url(#cp-amethyst)";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${goldGrad}"/>
<path d="M 27 82 C 29 68, 38 60, 41 48 L 59 48 C 62 60, 71 68, 73 82 Z" fill="${bodyGrad}"/>
<path d="M 32 80 C 35 68, 41 58, 44 50 C 47 49, 49 50, 49 52 C 45 64, 40 74, 37 80 Z" fill="${specGrad}" stroke="none"/>
<path d="M 38 48 C 44 51, 56 51, 62 48 L 63 53 C 56 56, 44 56, 37 53 Z" fill="${goldGrad}"/>
<path d="M 40 48 C 37 40, 31 34, 28 32 L 72 32 C 69 34, 63 40, 60 48 Z" fill="${bodyGrad}"/>
<path d="M 28 32 L 20 18 L 34 26 L 50 12 L 66 26 L 80 18 L 72 32 Z" fill="${bodyGrad}"/>
<path d="M 27 32 C 40 35, 60 35, 73 32 L 73 35 C 60 38, 40 38, 27 35 Z" fill="${goldGrad}"/>
<circle cx="20" cy="17" r="3.2" fill="${pearlColor}"/>
<circle cx="34" cy="25" r="3.2" fill="${pearlColor}"/>
<circle cx="50" cy="11" r="4.2" fill="${pearlColor}"/>
<circle cx="66" cy="25" r="3.2" fill="${pearlColor}"/>
<circle cx="80" cy="17" r="3.2" fill="${pearlColor}"/>
<ellipse cx="50" cy="40" rx="3.5" ry="4.5" fill="${gemColor}"/>
<circle cx="49" cy="38" r="1.2" fill="#ffffff" stroke="none"/>
</g> </g>
</svg>`, </svg>`;
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg"> }
<g fill="#2d3038" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 39h27v-3H9v3zm3-3v-4.5h21V36H12zm2-4.5v-11h17v11H14z" stroke-linecap="butt"/> function buildKingSvg(isWhite: boolean): string {
<path d="M14 20.5h17M11 14h23l-2.5 6.5h-18L11 14z"/> const defs = isWhite ? WHITE_DEFS : BLACK_DEFS;
<path d="M12 10.5h4v3.5h-4zm7 0h7v3.5h-7zm10 0h4v3.5h-4z" stroke-linecap="butt"/> const stroke = isWhite ? "#0f172a" : "#020617";
<path d="M14 29.5v-1h17v1H14zm-1 3.5v-1h19v1H13z" fill="none" stroke="#fff"/> const bodyGrad = isWhite ? "url(#cp-w-body)" : "url(#cp-b-body)";
const specGrad = isWhite ? "url(#cp-w-spec)" : "url(#cp-b-spec)";
const goldGrad = isWhite ? "url(#cp-w-gold)" : "url(#cp-b-gold)";
const gemColor = isWhite ? "url(#cp-ruby)" : "url(#cp-sapphire)";
return `<svg viewBox="0 0 100 100" class="piece-svg piece-${isWhite ? "w" : "b"}" xmlns="http://www.w3.org/2000/svg">
${defs}
<g stroke="${stroke}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 16 90 C 18 84, 28 82, 50 82 C 72 82, 82 84, 84 90 L 84 94 C 84 96, 78 97, 50 97 C 22 97, 16 96, 16 94 Z" fill="${bodyGrad}"/>
<ellipse cx="50" cy="83" rx="31" ry="3.8" fill="${goldGrad}"/>
<path d="M 25 82 C 27 68, 36 58, 38 46 L 62 46 C 64 58, 73 68, 75 82 Z" fill="${bodyGrad}"/>
<path d="M 30 80 C 33 68, 40 56, 42 48 C 45 47, 48 48, 48 50 C 44 62, 38 74, 35 80 Z" fill="${specGrad}" stroke="none"/>
<path d="M 34 46 C 42 49, 58 49, 66 46 L 67 51 C 58 54, 42 54, 33 51 Z" fill="${goldGrad}"/>
<path d="M 33 46 C 28 38, 28 28, 50 24 C 72 28, 72 38, 67 46 Z" fill="${bodyGrad}"/>
<path d="M 50 24 L 50 46 M 34 36 C 42 34, 58 34, 66 36" stroke="${goldGrad}" stroke-width="2.6"/>
<ellipse cx="50" cy="46" rx="16" ry="3.5" fill="${goldGrad}"/>
<path d="M 46 24 L 54 24 L 52 19 L 48 19 Z" fill="${goldGrad}"/>
<path d="M 48 19 L 42 16 L 44 11 L 47 13 L 47 6 L 53 6 L 53 13 L 56 11 L 58 16 L 52 19 Z" fill="${goldGrad}"/>
<circle cx="50" cy="13" r="2.8" fill="${gemColor}"/>
<circle cx="49" cy="12" r="0.9" fill="#ffffff" stroke="none"/>
</g> </g>
</svg>`, </svg>`;
}, }
b: {
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg"> const PIECE_BUILDERS: Record<PieceType, (isWhite: boolean) => string> = {
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"> p: buildPawnSvg,
<g fill="#fff"> n: buildKnightSvg,
<path d="M9 36c3.39-.97 10.11.43 13.5-2 3.39 2.43 10.11 1.03 13.5 2 0 0 1.65.54 3 2-.68.97-1.65.99-3 .5-3.39-.97-10.11.46-13.5-1-3.39 1.46-10.11.03-13.5 1-1.35.49-2.32.47-3-.5 1.35-1.94 3-2 3-2z"/> b: buildBishopSvg,
<path d="M15 32c2.5 2.5 12.5 2.5 15 0 .5-1.5 0-2 0-2 0-2.5-2.5-4-2.5-4 5.5-1.5 6-11.5-5-15.5-11 4-10.5 14-5 15.5 0 0-2.5 1.5-2.5 4 0 0-.5.5 0 2z"/> r: buildRookSvg,
<path d="M25 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 1 1 5 0z"/> q: buildQueenSvg,
</g> k: buildKingSvg,
<path d="M17.5 26h10M15 30h15M22.5 15.5v5M20 18h5" stroke-linejoin="miter"/>
</g>
</svg>`,
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<g fill="#2d3038">
<path d="M9 36c3.39-.97 10.11.43 13.5-2 3.39 2.43 10.11 1.03 13.5 2 0 0 1.65.54 3 2-.68.97-1.65.99-3 .5-3.39-.97-10.11.46-13.5-1-3.39 1.46-10.11.03-13.5 1-1.35.49-2.32.47-3-.5 1.35-1.94 3-2 3-2z"/>
<path d="M15 32c2.5 2.5 12.5 2.5 15 0 .5-1.5 0-2 0-2 0-2.5-2.5-4-2.5-4 5.5-1.5 6-11.5-5-15.5-11 4-10.5 14-5 15.5 0 0-2.5 1.5-2.5 4 0 0-.5.5 0 2z"/>
<path d="M25 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 1 1 5 0z"/>
</g>
<path d="M17.5 26h10M15 30h15M22.5 15.5v5M20 18h5" stroke="#fff" stroke-linejoin="miter"/>
</g>
</svg>`,
},
n: {
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18" fill="#fff"/>
<path d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,7.4 17.03,5.16 20,6 C 22,6.5 21.84,7.85 22,10 z" fill="#fff"/>
<path d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z" fill="#222" stroke="#222"/>
<path d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z" transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)" fill="#222" stroke="#222"/>
</g>
</svg>`,
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18" fill="#2d3038"/>
<path d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,7.4 17.03,5.16 20,6 C 22,6.5 21.84,7.85 22,10 z" fill="#2d3038"/>
<path d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z" fill="#fff" stroke="#fff"/>
<path d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z" transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)" fill="#fff" stroke="#fff"/>
</g>
</svg>`,
},
p: {
w: `<svg viewBox="0 0 45 45" class="piece-svg piece-w" xmlns="http://www.w3.org/2000/svg">
<path d="M22.5 9c-2.21 0-4 1.79-4 4 0 .89.29 1.71.78 2.38C17.33 16.5 16 18.59 16 21c0 2.03.94 3.84 2.41 5.03-3 1.06-7.41 5.55-7.41 13.47h23c0-7.92-4.41-12.41-7.41-13.47 1.47-1.19 2.41-3 2.41-5.03 0-2.41-1.33-4.5-3.28-5.62.49-.67.78-1.49.78-2.38 0-2.21-1.79-4-4-4z" fill="#fff" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`,
b: `<svg viewBox="0 0 45 45" class="piece-svg piece-b" xmlns="http://www.w3.org/2000/svg">
<path d="M22.5 9c-2.21 0-4 1.79-4 4 0 .89.29 1.71.78 2.38C17.33 16.5 16 18.59 16 21c0 2.03.94 3.84 2.41 5.03-3 1.06-7.41 5.55-7.41 13.47h23c0-7.92-4.41-12.41-7.41-13.47 1.47-1.19 2.41-3 2.41-5.03 0-2.41-1.33-4.5-3.28-5.62.49-.67.78-1.49.78-2.38 0-2.21-1.79-4-4-4z" fill="#2d3038" stroke="#222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`,
},
}; };
// Cached SVG strings for instant performance
const PIECE_CACHE: Record<string, string> = {};
export function getPieceSvg(type: PieceType | null, color: PieceColor | null): string { export function getPieceSvg(type: PieceType | null, color: PieceColor | null): string {
if (!type || !color) return ""; if (!type || !color) return "";
return PIECE_SVGS[type]?.[color] ?? ""; const key = `${type}-${color}`;
if (!PIECE_CACHE[key]) {
const builder = PIECE_BUILDERS[type];
if (builder) {
PIECE_CACHE[key] = builder(color === "w");
}
}
return PIECE_CACHE[key] ?? "";
} }
+193 -12
View File
@@ -142,9 +142,13 @@ html, body {
} }
.captured-tray .mini-piece { .captured-tray .mini-piece {
width: 18px; width: 21px;
height: 18px; height: 21px;
opacity: 0.85; opacity: 0.95;
filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
display: flex;
align-items: center;
justify-content: center;
} }
.advantage-score { .advantage-score {
@@ -254,36 +258,59 @@ html, body {
========================================================================== */ ========================================================================== */
.piece-wrapper { .piece-wrapper {
width: 90%; width: 92%;
height: 90%; height: 92%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
pointer-events: none; pointer-events: none;
transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease; transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.22s ease;
} }
.piece-svg { .piece-svg {
width: 100%; width: 100%;
height: 100%; height: 100%;
filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
display: block; display: block;
filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38));
transition: filter 0.25s ease;
}
.piece-svg.piece-w {
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)) drop-shadow(0 1px 2px rgba(254, 240, 138, 0.2));
}
.piece-svg.piece-b {
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.52)) drop-shadow(0 1px 2px rgba(129, 140, 248, 0.25));
} }
.cell:not(:disabled):hover .piece-wrapper { .cell:not(:disabled):hover .piece-wrapper {
transform: translateY(-3px) scale(1.06); transform: translateY(-4px) scale(1.09);
filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35)); }
.cell:not(:disabled):hover .piece-svg.piece-w {
filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 10px rgba(245, 158, 11, 0.65));
}
.cell:not(:disabled):hover .piece-svg.piece-b {
filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 10px rgba(168, 85, 247, 0.7));
} }
.cell.selected .piece-wrapper { .cell.selected .piece-wrapper {
transform: translateY(-5px) scale(1.14); transform: translateY(-6px) scale(1.15);
filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
animation: piece-hover-breath 1.8s ease-in-out infinite alternate; animation: piece-hover-breath 1.8s ease-in-out infinite alternate;
} }
.cell.selected .piece-svg.piece-w {
filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 16px rgba(251, 191, 36, 0.9));
}
.cell.selected .piece-svg.piece-b {
filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 16px rgba(192, 132, 252, 0.9));
}
@keyframes piece-hover-breath { @keyframes piece-hover-breath {
0% { transform: translateY(-5px) scale(1.14); } 0% { transform: translateY(-5px) scale(1.14); }
100% { transform: translateY(-7px) scale(1.18); } 100% { transform: translateY(-8px) scale(1.18); }
} }
/* Physical animation classes */ /* Physical animation classes */
@@ -308,6 +335,160 @@ html, body {
100% { transform: translateY(0) scale(1); } 100% { transform: translateY(0) scale(1); }
} }
/* Attacking piece strike animation */
.piece-wrapper.anim-strike {
animation: piece-strike-lunge 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
z-index: 10;
}
@keyframes piece-strike-lunge {
0% {
transform: scale(0.88) translateY(-6px);
filter: brightness(1.25);
}
30% {
transform: scale(1.22) translateY(2px);
filter: brightness(1.35) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}
60% {
transform: scale(0.94, 1.06) translateY(-2px);
}
80% {
transform: scale(1.03, 0.97) translateY(0);
}
100% {
transform: scale(1, 1) translateY(0);
filter: none;
}
}
/* Board square impact shudder */
.cell.anim-shudder {
animation: cell-shudder 0.22s ease-out;
}
@keyframes cell-shudder {
0% { transform: translate(0, 0); }
25% { transform: translate(2px, 1px); }
50% { transform: translate(-2px, -1px); }
75% { transform: translate(1px, -1px); }
100% { transform: translate(0, 0); }
}
/* ==========================================================================
Capture Topple & Dissolve Layer
========================================================================== */
.ghost-layer {
position: absolute;
inset: 4px;
pointer-events: none;
z-index: 15;
overflow: visible;
}
.captured-ghost {
position: absolute;
pointer-events: none;
display: flex;
align-items: center;
justify-content: center;
z-index: 20;
}
.captured-ghost .piece-wrapper {
width: 92%;
height: 92%;
}
.captured-ghost.topple-right {
transform-origin: 45% 90%;
animation: piece-topple-right 0.78s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.captured-ghost.topple-left {
transform-origin: 55% 90%;
animation: piece-topple-left 0.78s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes piece-topple-right {
0% {
transform: translate(0, 0) rotate(0deg) scale(1);
opacity: 1;
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
14% {
/* Impact shock: jolt up and lean back */
transform: translate(6px, -12px) rotate(22deg) scale(1.05);
opacity: 1;
filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4)) brightness(1.2);
}
38% {
/* Falling over past balance point */
transform: translate(16px, -2px) rotate(60deg) scale(1);
opacity: 0.96;
}
58% {
/* Slam onto the board surface */
transform: translate(24px, 12px) rotate(92deg) scale(0.96, 0.9);
opacity: 0.92;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
70% {
/* Physical ground rebound / rattle */
transform: translate(26px, 8px) rotate(84deg) scale(0.97, 0.94);
opacity: 0.88;
}
80% {
/* Rest flat on board */
transform: translate(27px, 12px) rotate(90deg) scale(0.95);
opacity: 0.8;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
100% {
/* Dissolve and vanish into thin air */
transform: translate(30px, 16px) rotate(90deg) scale(0.68) scaleY(0.4);
opacity: 0;
filter: blur(5px) brightness(1.8) drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
}
}
@keyframes piece-topple-left {
0% {
transform: translate(0, 0) rotate(0deg) scale(1);
opacity: 1;
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
14% {
transform: translate(-6px, -12px) rotate(-22deg) scale(1.05);
opacity: 1;
filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4)) brightness(1.2);
}
38% {
transform: translate(-16px, -2px) rotate(-60deg) scale(1);
opacity: 0.96;
}
58% {
transform: translate(-24px, 12px) rotate(-92deg) scale(0.96, 0.9);
opacity: 0.92;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
70% {
transform: translate(-26px, 8px) rotate(-84deg) scale(0.97, 0.94);
opacity: 0.88;
}
80% {
transform: translate(-27px, 12px) rotate(-90deg) scale(0.95);
opacity: 0.8;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
100% {
transform: translate(-30px, 16px) rotate(-90deg) scale(0.68) scaleY(0.4);
opacity: 0;
filter: blur(5px) brightness(1.8) drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
}
}
/* ========================================================================== /* ==========================================================================
Move Indicators: Dots & Capture Reticles Move Indicators: Dots & Capture Reticles
========================================================================== */ ========================================================================== */
+27
View File
@@ -228,6 +228,33 @@ export class VfxEngine {
} }
} }
/**
* Dissolution / ether particles when defeated piece vanishes
*/
public dissolvePuff(x: number, y: number, capturedColor: "w" | "b" = "w") {
const colors = capturedColor === "w"
? ["#fef08a", "#fbbf24", "#ffffff", "rgba(254, 240, 138, 0.7)"]
: ["#c084fc", "#a855f7", "#60a5fa", "rgba(192, 132, 252, 0.7)"];
for (let i = 0; i < 16; i++) {
const angle = Math.random() * Math.PI * 2;
const speed = 12 + Math.random() * 38;
this.particles.push({
x: x + (Math.random() - 0.5) * 22,
y: y + 8 + (Math.random() - 0.5) * 12,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed - 22,
radius: 1.5 + Math.random() * 2.8,
color: colors[Math.floor(Math.random() * colors.length)],
alpha: 0.85,
decay: 1.5 + Math.random() * 0.8,
gravity: -18,
drag: 0.91,
shape: "circle",
});
}
}
/** /**
* Magical ascension / burst on Pawn Promotion * Magical ascension / burst on Pawn Promotion
*/ */
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -4,8 +4,8 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chess — 3miz</title> <title>Chess — 3miz</title>
<script type="module" crossorigin src="./assets/index-C5l45jZa.js"></script> <script type="module" crossorigin src="./assets/index-8tGLzrk3.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-BJNpcCwx.css"> <link rel="stylesheet" crossorigin href="./assets/index-CJ1BuKCF.css">
</head> </head>
<body><div id="app">…</div></body> <body><div id="app">…</div></body>
</html> </html>
+1 -1
View File
@@ -2,7 +2,7 @@
"bundle_format": 1, "bundle_format": 1,
"kind": "source", "kind": "source",
"game_id": "chess", "game_id": "chess",
"version": "1.4.0", "version": "1.6.0",
"server": { "entry": "server/main.ts" }, "server": { "entry": "server/main.ts" },
"client": { "entry": "index.html" }, "client": { "entry": "index.html" },
"catalog": { "catalog": {
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"manifest_version": 1, "manifest_version": 1,
"game_id": "chess", "game_id": "chess",
"version": "1.4.0", "version": "1.6.0",
"protocol": "socketio", "protocol": "socketio",
"protocol_version": 1, "protocol_version": 1,
"title": { "title": {
@@ -81,14 +81,14 @@
], ],
"achievements": [], "achievements": [],
"client": { "client": {
"entry": "https://g.3miz.ir/chess/1.4.0/index.html", "entry": "https://g.3miz.ir/chess/1.6.0/index.html",
"integrity": "sha384-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "integrity": "sha384-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"aspect": "1:1", "aspect": "1:1",
"min_width_px": 320, "min_width_px": 320,
"supports_portrait": true "supports_portrait": true
}, },
"server": { "server": {
"image": "registry.3miz.ir/games/chess:1.4.0", "image": "registry.3miz.ir/games/chess:1.6.0",
"max_tables_per_instance": 500, "max_tables_per_instance": 500,
"checkpoint_every_inputs": 20, "checkpoint_every_inputs": 20,
"snapshot_every_messages": 50, "snapshot_every_messages": 50,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@3miz/chess-server", "name": "@3miz/chess-server",
"version": "1.4.0", "version": "1.6.0",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "start": "tsx main.ts", "test": "node --test --import tsx ../tests/*.test.ts" }, "scripts": { "start": "tsx main.ts", "test": "node --test --import tsx ../tests/*.test.ts" },