Spaces:
Running
Running
онлайн шахматы челеове против человека, ии проитив человека и ии против ии
Browse files- README.md +7 -4
- components/footer.js +40 -0
- components/game-mode-card.js +40 -0
- components/navbar.js +38 -0
- human-vs-human.html +167 -0
- index.html +60 -19
- script.js +25 -0
- style.css +52 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🌖
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
|
|
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ChessFusion Royale ♟️🔥
|
|
|
|
| 3 |
colorFrom: blue
|
| 4 |
+
colorTo: purple
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
components/footer.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomFooter extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
.footer {
|
| 7 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 8 |
+
}
|
| 9 |
+
</style>
|
| 10 |
+
<footer class="footer text-white py-8">
|
| 11 |
+
<div class="container mx-auto px-4">
|
| 12 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
| 13 |
+
<div class="mb-4 md:mb-0">
|
| 14 |
+
<h2 class="text-xl font-bold flex items-center">
|
| 15 |
+
<i data-feather="chess" class="mr-2"></i>
|
| 16 |
+
ChessFusion Royale
|
| 17 |
+
</h2>
|
| 18 |
+
<p class="text-sm opacity-80 mt-1">The ultimate chess experience</p>
|
| 19 |
+
</div>
|
| 20 |
+
<div class="flex space-x-4">
|
| 21 |
+
<a href="#" class="hover:text-yellow-200">
|
| 22 |
+
<i data-feather="github"></i>
|
| 23 |
+
</a>
|
| 24 |
+
<a href="#" class="hover:text-yellow-200">
|
| 25 |
+
<i data-feather="twitter"></i>
|
| 26 |
+
</a>
|
| 27 |
+
<a href="#" class="hover:text-yellow-200">
|
| 28 |
+
<i data-feather="mail"></i>
|
| 29 |
+
</a>
|
| 30 |
+
</div>
|
| 31 |
+
</div>
|
| 32 |
+
<div class="border-t border-white border-opacity-20 mt-6 pt-6 text-sm text-center md:text-left">
|
| 33 |
+
<p>© ${new Date().getFullYear()} ChessFusion Royale. All rights reserved.</p>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
</footer>
|
| 37 |
+
`;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
customElements.define('custom-footer', CustomFooter);
|
components/game-mode-card.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class GameModeCard extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
const title = this.getAttribute('title') || '';
|
| 4 |
+
const description = this.getAttribute('description') || '';
|
| 5 |
+
const icon = this.getAttribute('icon') || 'help-circle';
|
| 6 |
+
const bgColor = this.getAttribute('bg-color') || 'bg-gray-500';
|
| 7 |
+
const href = this.getAttribute('href') || '#';
|
| 8 |
+
|
| 9 |
+
this.attachShadow({ mode: 'open' });
|
| 10 |
+
this.shadowRoot.innerHTML = `
|
| 11 |
+
<style>
|
| 12 |
+
.card {
|
| 13 |
+
transition: all 0.3s ease;
|
| 14 |
+
}
|
| 15 |
+
.card:hover {
|
| 16 |
+
transform: translateY(-5px);
|
| 17 |
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
| 18 |
+
}
|
| 19 |
+
</style>
|
| 20 |
+
<a href="${href}" class="block">
|
| 21 |
+
<div class="card bg-white rounded-xl shadow-md overflow-hidden h-full">
|
| 22 |
+
<div class="${bgColor} p-6 flex justify-center">
|
| 23 |
+
<i data-feather="${icon}" class="text-white w-12 h-12"></i>
|
| 24 |
+
</div>
|
| 25 |
+
<div class="p-6">
|
| 26 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">${title}</h3>
|
| 27 |
+
<p class="text-gray-600">${description}</p>
|
| 28 |
+
<div class="mt-4">
|
| 29 |
+
<span class="inline-flex items-center text-${bgColor.split('-')[1]}-600 font-medium">
|
| 30 |
+
Play now
|
| 31 |
+
<i data-feather="arrow-right" class="ml-2 w-4 h-4"></i>
|
| 32 |
+
</span>
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
</a>
|
| 37 |
+
`;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
customElements.define('custom-game-mode-card', GameModeCard);
|
components/navbar.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
.navbar {
|
| 7 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 8 |
+
}
|
| 9 |
+
.nav-link:hover {
|
| 10 |
+
transform: translateY(-2px);
|
| 11 |
+
}
|
| 12 |
+
.nav-link {
|
| 13 |
+
transition: all 0.2s ease;
|
| 14 |
+
}
|
| 15 |
+
</style>
|
| 16 |
+
<nav class="navbar shadow-lg">
|
| 17 |
+
<div class="container mx-auto px-4 py-3">
|
| 18 |
+
<div class="flex justify-between items-center">
|
| 19 |
+
<a href="/" class="flex items-center space-x-2">
|
| 20 |
+
<i data-feather="chess" class="text-white"></i>
|
| 21 |
+
<span class="text-white text-xl font-bold">ChessFusion</span>
|
| 22 |
+
</a>
|
| 23 |
+
<div class="hidden md:flex space-x-6">
|
| 24 |
+
<a href="/" class="nav-link text-white hover:text-yellow-200">Home</a>
|
| 25 |
+
<a href="/human-vs-human.html" class="nav-link text-white hover:text-yellow-200">PvP</a>
|
| 26 |
+
<a href="/ai-vs-human.html" class="nav-link text-white hover:text-yellow-200">vs AI</a>
|
| 27 |
+
<a href="/ai-vs-ai.html" class="nav-link text-white hover:text-yellow-200">AI Battle</a>
|
| 28 |
+
</div>
|
| 29 |
+
<button class="md:hidden text-white focus:outline-none">
|
| 30 |
+
<i data-feather="menu"></i>
|
| 31 |
+
</button>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
</nav>
|
| 35 |
+
`;
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
customElements.define('custom-navbar', CustomNavbar);
|
human-vs-human.html
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Human vs Human | ChessFusion Royale</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.2/chess.js"></script>
|
| 12 |
+
<script src="components/navbar.js"></script>
|
| 13 |
+
<script src="components/footer.js"></script>
|
| 14 |
+
</head>
|
| 15 |
+
<body class="bg-gray-100 min-h-screen flex flex-col">
|
| 16 |
+
<custom-navbar></custom-navbar>
|
| 17 |
+
|
| 18 |
+
<main class="flex-grow container mx-auto px-4 py-8">
|
| 19 |
+
<div class="max-w-4xl mx-auto">
|
| 20 |
+
<div class="flex justify-between items-center mb-8">
|
| 21 |
+
<h1 class="text-3xl font-bold text-gray-800">Human vs Human</h1>
|
| 22 |
+
<div class="flex space-x-4">
|
| 23 |
+
<button id="new-game-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md flex items-center">
|
| 24 |
+
<i data-feather="refresh-cw" class="mr-2"></i>
|
| 25 |
+
New Game
|
| 26 |
+
</button>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
|
| 30 |
+
<div class="bg-white rounded-xl shadow-lg p-6">
|
| 31 |
+
<div class="chess-board" id="chess-board"></div>
|
| 32 |
+
|
| 33 |
+
<div class="mt-6 flex justify-between items-center">
|
| 34 |
+
<div class="flex items-center">
|
| 35 |
+
<div class="w-8 h-8 rounded-full bg-gray-800 mr-2"></div>
|
| 36 |
+
<span class="font-medium">Black</span>
|
| 37 |
+
</div>
|
| 38 |
+
<div id="game-status" class="text-lg font-semibold">White's turn</div>
|
| 39 |
+
<div class="flex items-center">
|
| 40 |
+
<div class="w-8 h-8 rounded-full bg-white border border-gray-300 mr-2"></div>
|
| 41 |
+
<span class="font-medium">White</span>
|
| 42 |
+
</div>
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div class="mt-8 bg-white rounded-xl shadow-lg p-6">
|
| 47 |
+
<h2 class="text-xl font-semibold mb-4">Game History</h2>
|
| 48 |
+
<div id="move-history" class="bg-gray-50 p-4 rounded-md max-h-60 overflow-y-auto">
|
| 49 |
+
<!-- Moves will be added here -->
|
| 50 |
+
</div>
|
| 51 |
+
</div>
|
| 52 |
+
</div>
|
| 53 |
+
</main>
|
| 54 |
+
|
| 55 |
+
<custom-footer></custom-footer>
|
| 56 |
+
|
| 57 |
+
<script>
|
| 58 |
+
feather.replace();
|
| 59 |
+
|
| 60 |
+
// Initialize chess game
|
| 61 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 62 |
+
const game = new Chess();
|
| 63 |
+
const boardElement = document.getElementById('chess-board');
|
| 64 |
+
const moveHistoryElement = document.getElementById('move-history');
|
| 65 |
+
const gameStatusElement = document.getElementById('game-status');
|
| 66 |
+
|
| 67 |
+
// Render chess board
|
| 68 |
+
function renderBoard() {
|
| 69 |
+
boardElement.innerHTML = '';
|
| 70 |
+
|
| 71 |
+
for (let i = 0; i < 8; i++) {
|
| 72 |
+
for (let j = 0; j < 8; j++) {
|
| 73 |
+
const square = document.createElement('div');
|
| 74 |
+
square.className = `chess-square ${(i + j) % 2 === 0 ? 'light' : 'dark'}`;
|
| 75 |
+
square.dataset.row = i;
|
| 76 |
+
square.dataset.col = j;
|
| 77 |
+
|
| 78 |
+
const piece = game.get(`${String.fromCharCode(97 + j)}${8 - i}`);
|
| 79 |
+
if (piece) {
|
| 80 |
+
const pieceElement = document.createElement('div');
|
| 81 |
+
pieceElement.className = 'chess-piece';
|
| 82 |
+
pieceElement.innerHTML = getPieceSymbol(piece);
|
| 83 |
+
pieceElement.dataset.piece = piece.type;
|
| 84 |
+
pieceElement.dataset.color = piece.color;
|
| 85 |
+
square.appendChild(pieceElement);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
boardElement.appendChild(square);
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
updateGameStatus();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function getPieceSymbol(piece) {
|
| 96 |
+
const symbols = {
|
| 97 |
+
'p': '♟', 'n': '♞', 'b': '♝', 'r': '♜', 'q': '♛', 'k': '♚',
|
| 98 |
+
'P': '♙', 'N': '♘', 'B': '♗', 'R': '♖', 'Q': '♕', 'K': '♔'
|
| 99 |
+
};
|
| 100 |
+
return symbols[piece.type === 'k' || piece.type === 'K' ? piece.type : piece.type.toLowerCase()];
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
function updateGameStatus() {
|
| 104 |
+
if (game.isCheckmate()) {
|
| 105 |
+
gameStatusElement.textContent = `Checkmate! ${game.turn() === 'w' ? 'Black' : 'White'} wins!`;
|
| 106 |
+
} else if (game.isDraw()) {
|
| 107 |
+
gameStatusElement.textContent = "Game ended in a draw";
|
| 108 |
+
} else if (game.isCheck()) {
|
| 109 |
+
gameStatusElement.textContent = `${game.turn() === 'w' ? 'White' : 'Black'} is in check`;
|
| 110 |
+
} else {
|
| 111 |
+
gameStatusElement.textContent = `${game.turn() === 'w' ? 'White' : 'Black'}'s turn`;
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function updateMoveHistory() {
|
| 116 |
+
moveHistoryElement.innerHTML = '';
|
| 117 |
+
const moves = game.history({ verbose: true });
|
| 118 |
+
|
| 119 |
+
for (let i = 0; i < moves.length; i += 2) {
|
| 120 |
+
const moveDiv = document.createElement('div');
|
| 121 |
+
moveDiv.className = 'flex justify-between mb-1';
|
| 122 |
+
|
| 123 |
+
const whiteMove = moves[i];
|
| 124 |
+
moveDiv.innerHTML = `
|
| 125 |
+
<span class="text-gray-700">${Math.floor(i/2) + 1}. ${whiteMove.san}</span>
|
| 126 |
+
${i + 1 < moves.length ? `<span class="text-gray-700">${moves[i+1].san}</span>` : ''}
|
| 127 |
+
`;
|
| 128 |
+
|
| 129 |
+
moveHistoryElement.appendChild(moveDiv);
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// Handle piece selection and movement
|
| 134 |
+
let selectedSquare = null;
|
| 135 |
+
|
| 136 |
+
boardElement.addEventListener('click', (e) => {
|
| 137 |
+
const square = e.target.closest('.chess-square');
|
| 138 |
+
if (!square) return;
|
| 139 |
+
|
| 140 |
+
const row = parseInt(square.dataset.row);
|
| 141 |
+
const col = parseInt(square.dataset.col);
|
| 142 |
+
const position = `${String.fromCharCode(97 + col)}${8 - row}`;
|
| 143 |
+
|
| 144 |
+
const piece = game.get(position);
|
| 145 |
+
|
| 146 |
+
// If no piece is selected and clicked square has a piece of current turn's color
|
| 147 |
+
if (!selectedSquare && piece && piece.color === game.turn()) {
|
| 148 |
+
selectedSquare = position;
|
| 149 |
+
square.classList.add('selected');
|
| 150 |
+
return;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
// If a piece is already selected
|
| 154 |
+
if (selectedSquare) {
|
| 155 |
+
// If clicking on the same piece, deselect it
|
| 156 |
+
if (position === selectedSquare) {
|
| 157 |
+
document.querySelector(`.chess-square[data-row="${row}"][data-col="${col}"]`).classList.remove('selected');
|
| 158 |
+
selectedSquare = null;
|
| 159 |
+
return;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// Try to make the move
|
| 163 |
+
try {
|
| 164 |
+
const move = game.move({
|
| 165 |
+
from: selectedSquare
|
| 166 |
+
</body>
|
| 167 |
+
</html>
|
index.html
CHANGED
|
@@ -1,19 +1,60 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ChessFusion Royale | Online Chess Platform</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.2/chess.js"></script>
|
| 12 |
+
<script src="components/navbar.js"></script>
|
| 13 |
+
<script src="components/game-mode-card.js"></script>
|
| 14 |
+
<script src="components/footer.js"></script>
|
| 15 |
+
</head>
|
| 16 |
+
<body class="bg-gray-100 min-h-screen flex flex-col">
|
| 17 |
+
<custom-navbar></custom-navbar>
|
| 18 |
+
|
| 19 |
+
<main class="flex-grow container mx-auto px-4 py-8">
|
| 20 |
+
<section class="text-center mb-12">
|
| 21 |
+
<h1 class="text-4xl md:text-5xl font-bold text-gray-800 mb-4">ChessFusion Royale</h1>
|
| 22 |
+
<p class="text-xl text-gray-600 max-w-2xl mx-auto">Play chess in any mode you like - Human vs Human, AI vs Human, or watch AI battle itself!</p>
|
| 23 |
+
</section>
|
| 24 |
+
|
| 25 |
+
<section class="grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto">
|
| 26 |
+
<custom-game-mode-card
|
| 27 |
+
title="Human vs Human"
|
| 28 |
+
description="Challenge a friend to a classic chess match"
|
| 29 |
+
icon="users"
|
| 30 |
+
bg-color="bg-blue-500"
|
| 31 |
+
href="/human-vs-human.html">
|
| 32 |
+
</custom-game-mode-card>
|
| 33 |
+
|
| 34 |
+
<custom-game-mode-card
|
| 35 |
+
title="AI vs Human"
|
| 36 |
+
description="Test your skills against our chess AI"
|
| 37 |
+
icon="cpu"
|
| 38 |
+
bg-color="bg-purple-500"
|
| 39 |
+
href="/ai-vs-human.html">
|
| 40 |
+
</custom-game-mode-card>
|
| 41 |
+
|
| 42 |
+
<custom-game-mode-card
|
| 43 |
+
title="AI vs AI"
|
| 44 |
+
description="Watch two chess engines battle it out"
|
| 45 |
+
icon="activity"
|
| 46 |
+
bg-color="bg-green-500"
|
| 47 |
+
href="/ai-vs-ai.html">
|
| 48 |
+
</custom-game-mode-card>
|
| 49 |
+
</section>
|
| 50 |
+
</main>
|
| 51 |
+
|
| 52 |
+
<custom-footer></custom-footer>
|
| 53 |
+
|
| 54 |
+
<script>
|
| 55 |
+
feather.replace();
|
| 56 |
+
</script>
|
| 57 |
+
<script src="script.js"></script>
|
| 58 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 59 |
+
</body>
|
| 60 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Shared utility functions
|
| 2 |
+
function showToast(message, type = 'info') {
|
| 3 |
+
const toast = document.createElement('div');
|
| 4 |
+
toast.className = `fixed bottom-4 right-4 px-4 py-2 rounded-md shadow-lg text-white ${
|
| 5 |
+
type === 'error' ? 'bg-red-500' :
|
| 6 |
+
type === 'success' ? 'bg-green-500' : 'bg-blue-500'
|
| 7 |
+
}`;
|
| 8 |
+
toast.textContent = message;
|
| 9 |
+
document.body.appendChild(toast);
|
| 10 |
+
|
| 11 |
+
setTimeout(() => {
|
| 12 |
+
toast.remove();
|
| 13 |
+
}, 3000);
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
// Initialize chess game (will be extended in specific pages)
|
| 17 |
+
function initChessGame(mode) {
|
| 18 |
+
console.log(`Initializing chess game in ${mode} mode`);
|
| 19 |
+
// Common initialization logic here
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
// Navigation helper
|
| 23 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 24 |
+
// Any shared initialization logic
|
| 25 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,62 @@
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
margin-top: 0;
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 2 |
+
|
| 3 |
body {
|
| 4 |
+
font-family: 'Inter', sans-serif;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
.chess-board {
|
| 8 |
+
width: 100%;
|
| 9 |
+
max-width: 600px;
|
| 10 |
+
aspect-ratio: 1/1;
|
| 11 |
+
display: grid;
|
| 12 |
+
grid-template-columns: repeat(8, 1fr);
|
| 13 |
+
grid-template-rows: repeat(8, 1fr);
|
| 14 |
+
border: 2px solid #333;
|
| 15 |
+
margin: 0 auto;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.chess-square {
|
| 19 |
+
display: flex;
|
| 20 |
+
justify-content: center;
|
| 21 |
+
align-items: center;
|
| 22 |
+
position: relative;
|
| 23 |
}
|
| 24 |
|
| 25 |
+
.chess-square.light {
|
| 26 |
+
background-color: #f0d9b5;
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
+
.chess-square.dark {
|
| 30 |
+
background-color: #b58863;
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
+
.chess-piece {
|
| 34 |
+
width: 80%;
|
| 35 |
+
height: 80%;
|
| 36 |
+
cursor: pointer;
|
| 37 |
+
transition: transform 0.2s;
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
+
.chess-piece:hover {
|
| 41 |
+
transform: scale(1.1);
|
| 42 |
}
|
| 43 |
+
|
| 44 |
+
.highlight {
|
| 45 |
+
position: absolute;
|
| 46 |
+
width: 30%;
|
| 47 |
+
height: 30%;
|
| 48 |
+
border-radius: 50%;
|
| 49 |
+
background-color: rgba(0, 255, 0, 0.4);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.move-highlight {
|
| 53 |
+
position: absolute;
|
| 54 |
+
width: 30%;
|
| 55 |
+
height: 30%;
|
| 56 |
+
border-radius: 50%;
|
| 57 |
+
background-color: rgba(0, 0, 255, 0.4);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.selected {
|
| 61 |
+
box-shadow: inset 0 0 10px rgba(255, 255, 0, 0.8);
|
| 62 |
+
}
|