예제 #1
0
        private MoveBreakdown CreateBreakdown()
        {
            int newRow        = _move.Piece.Row;
            int newCol        = _move.Piece.Col;
            var removedPieces = new List <CheckerPiece>();

            foreach (MoveDirection direction in _move.Direction)
            {
                newRow += MoveUtil.GetRowMoveAmountByColor(_move.Piece.Owner, direction);
                newCol += MoveUtil.GetColMoveAmount(direction);

                // adjust for jump
                CheckerPiece pieceAtPosition = _board.GetPiece(newRow, newCol);
                if (pieceAtPosition != null && pieceAtPosition.Owner != _move.Piece.Owner)
                {
                    removedPieces.Add(pieceAtPosition);
                    newRow += MoveUtil.GetRowMoveAmountByColor(_move.Piece.Owner, direction);
                    newCol += MoveUtil.GetColMoveAmount(direction);
                }
            }
            return(new MoveBreakdown
            {
                FinalRow = newRow,
                FinalCol = newCol,
                RemovedPieces = removedPieces
            });
        }
예제 #2
0
        private static void AssertBackwardRightMoveIsCorrect(CheckerBoard board, int originalRow, int originalColumn, PieceColor color)
        {
            Assert.IsNull(board.GetPiece(originalRow, originalColumn));

            int newRow = originalRow + MoveUtil.GetRowMoveAmountByColor(color, MoveDirection.BackwardRight);
            int newCol = originalColumn + MoveUtil.GetColMoveAmount(MoveDirection.BackwardRight);

            AssertPieceExists(board, newRow, newCol, color);
        }