public void PossibleMovesDoesNotReturnMovesResultingInCheckByPawn() { var king = new King(null, Player.Light) { HasMoved = true }; _board.SetPiece(6, 6, king); _board.SetPiece(5, 4, new Pawn(null, Player.Dark)); var moves = king.GetPossibleMoves(_board); Assert.IsFalse(moves.Any(x => x.To.X == 6 && x.To.Y == 5)); }
public void CannotMoveIntoCheck() { var king = new King(null, Player.Light); _board.SetPiece(1, 1, king); _board.SetPiece(0, 4, new Knight(null, Player.Dark)); var result = _board.CheckMoveForCheck(new Move(new Coordinate(1, 1), new Coordinate(1, 2))); Assert.AreEqual(true, result); }
private void FindKings() { if(_darkKing == null) { _darkKing = (King)GetPiecesForPlayer(Player.Dark).Where(x => x.PieceType == PieceType.King).Single(); } if (_lightKing == null) { _lightKing = (King)GetPiecesForPlayer(Player.Light).Where(x => x.PieceType == PieceType.King).Single(); } }
public void SetPiece(short x, short y, IPiece piece) { if (piece != null) { piece.Location = new Coordinate(x, y); } if (Squares[y, x] == null) { Squares[y, x] = new Square(x, y, piece); } else { Squares[y, x].Piece = piece; } if (piece != null) { if (piece.PieceType == PieceType.King) { if (piece.Player == Player.Light) _lightKing = (King)piece; else _darkKing = (King)piece; } } }