public void CastlingKingMoved() { var c = new CastlingTemplate(CastlingTemplate.CastlingType.Kingside); var from = new Position(5, 1); var to = new Position(7, 1); var rook = new Position(8, 1); var s = new ChessState(); s[rook] = new ChessPiece { Type = PieceTypes.Rook }; s[rook].Move(rook); s[from] = new ChessPiece { Type = PieceTypes.King }; s[from].Move(from); s[from].Move(from); Assert.IsFalse(c.CanApply(from, to, s)); }
public void CastlingBarrierQ() { var c = new CastlingTemplate(CastlingTemplate.CastlingType.Queenside); var from = new Position(5, 1); var to = new Position(3, 1); var rook = new Position(1, 1); var enmy = new Position(2, 1); var white = new Player(1); var s = new ChessState(); s[rook] = new ChessPiece { Type = PieceTypes.Rook, Player = white }; s[rook].Move(rook); s[from] = new ChessPiece { Type = PieceTypes.King, Player = white }; s[from].Move(from); s[enmy] = new ChessPiece { Type = PieceTypes.Rook, Player = white }; s[enmy].Move(enmy); Assert.IsFalse(c.CanApply(from, to, s)); }
public void RookPathUnderAttack() { var c = new CastlingTemplate(CastlingTemplate.CastlingType.Kingside); var from = new Position(5, 1); var to = new Position(7, 1); var rook = new Position(8, 1); var enmy = new Position(8, 3); var white = new Player(1); var s = new ChessState(); s[rook] = new ChessPiece { Type = PieceTypes.Rook, Player = white }; s[rook].Move(rook); s[from] = new ChessPiece { Type = PieceTypes.King, Player = white }; s[from].Move(from); s[enmy] = new ChessPiece { Type = PieceTypes.Rook, Player = new Player(2) }; s[enmy].Move(enmy); ChessPieceFactory.AddMoves((ChessPiece)s[enmy]); Assert.IsTrue(c.CanApply(from, to, s)); }