Val Town Chess

A fully functional chess game implemented in JavaScript for Val Town. This game includes all standard chess rules and features.

Features

  • Complete chess rules implementation
  • Visual chessboard with proper piece movement
  • Highlights for selected pieces and valid moves
  • Support for special moves:
    • Castling (kingside and queenside)
    • En passant captures
    • Pawn promotion
  • Game state tracking:
    • Check detection
    • Checkmate detection
    • Stalemate detection
    • Draw conditions (insufficient material, 50-move rule)
  • Captured pieces display
  • Reset game functionality

How to Play

  1. White moves first, followed by black
  2. Click on a piece to select it
  3. Valid moves will be highlighted on the board
  4. Click on a highlighted square to move the selected piece
  5. When a pawn reaches the opposite end of the board, you'll be prompted to choose a piece for promotion
  6. The game automatically detects check, checkmate, and draw conditions
  7. Use the "Reset Game" button to start a new game

Implementation Details

The game is built using vanilla JavaScript with no external dependencies. The chess logic includes:

  • Piece movement validation based on chess rules
  • Check and checkmate detection
  • Special move handling (castling, en passant, promotion)
  • Game state management

The UI is styled with Tailwind CSS for a clean, responsive design.

File Structure

  • /index.ts - HTTP handler for serving the game
  • /index.html - Main HTML file with the game layout
  • /js/chess.js - Chess game logic implementation
  • /css/styles.css - Custom styles for the chessboard and pieces

Future Improvements

Potential enhancements for the future:

  • Move history and notation
  • Undo move functionality
  • Timer/clock for timed games
  • Save/load game state
  • AI opponent