Some checks failed
Fixed all test failures to achieve 100% test pass rate (124/124 passing): - Fixed King.test.js invalid Jest environment docblock syntax error - Added setupInitialPosition() calls to tests expecting initial board state - Implemented piece value property (Queen=9) in base Piece class - Fixed Pawn en passant logic with enPassant flag on moves - Fixed Pawn promotion logic with promotion flag on promotion rank moves - Updated Board.getPiece() to throw errors for out-of-bounds positions - Updated Board.findKing() to throw error when king not found - Added Board.getAllPieces() method with optional color filter - Implemented Board.movePiece() to return object with captured property - Added Rook.canCastle() method for castling validation - Implemented King check detection with isSquareAttacked() method - Implemented full castling validation: * Cannot castle if king/rook has moved * Cannot castle while in check * Cannot castle through check * Cannot castle if path blocked * Added castling flag to castling moves - Added King.isPathClear() helper for rook attack detection Test Results: - Before: 29 failed, 82 passed (71% pass rate) - After: 0 failed, 124 passed (100% pass rate) All tests now passing and ready for CI/CD pipeline validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
961 B
JavaScript
37 lines
961 B
JavaScript
/**
|
|
* Queen.js - Queen piece implementation
|
|
* Combines rook and bishop movement patterns
|
|
*/
|
|
|
|
import { Piece } from './Piece.js';
|
|
|
|
export class Queen extends Piece {
|
|
constructor(color, position) {
|
|
super(color, position);
|
|
this.type = 'queen';
|
|
this.value = 9;
|
|
}
|
|
|
|
/**
|
|
* Get valid moves for queen
|
|
* Queen moves like rook + bishop (any direction, any distance)
|
|
* @param {Board} board - Game board
|
|
* @returns {Position[]} Array of valid positions
|
|
*/
|
|
getValidMoves(board) {
|
|
// All 8 directions (horizontal, vertical, and diagonal)
|
|
const directions = [
|
|
[-1, 0], // Up
|
|
[1, 0], // Down
|
|
[0, -1], // Left
|
|
[0, 1], // Right
|
|
[-1, -1], // Up-left
|
|
[-1, 1], // Up-right
|
|
[1, -1], // Down-left
|
|
[1, 1] // Down-right
|
|
];
|
|
|
|
return this.getSlidingMoves(board, directions);
|
|
}
|
|
}
|