Ejemplo n.º 1
0
        public void verifyMoveConstructorWithCapture()
        {
            // Make two occupied squares and construct a move from one to the other. Test
            // that the capture is correctly propagated to the move.
            square src = new pawnSquare(new squarePos(1, 1), pieceColour.black);
            square dst = new pawnSquare(new squarePos(2, 1), pieceColour.white);

            move captureMove = new move(src, dst);

            // First, check that the move has the correct squares associated with it..
            Assert.IsTrue(captureMove.srcPos.isSameSquareAs(src.position));
            Assert.IsTrue(captureMove.dstPos.isSameSquareAs(dst.position));

            Assert.IsTrue(captureMove.isCapture);
            Assert.IsTrue(captureMove.capturedSquare == dst);
        }
Ejemplo n.º 2
0
        public static square makeSquare(pieceType newType, pieceColour newColour, squarePos newPos)
        {
            square toRet ;
            switch (newType)
            {
                case pieceType.none:
                    toRet = new square(newPos);
                    break;
                case pieceType.pawn:
                    toRet = new pawnSquare(newPos, newColour);
                    break;
                case pieceType.rook:
                    toRet = new rookSquare(newPos, newColour);
                    break;
                case pieceType.bishop:
                    toRet = new bishopSquare(newPos, newColour);
                    break;
                case pieceType.knight:
                    toRet = new knightSquare(newPos, newColour);
                    break;
                case pieceType.queen:
                    toRet = new queenSquare(newPos, newColour);
                    break;
                case pieceType.king:
                    toRet = new kingSquare(newPos, newColour);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return toRet;
        }