rem: result = movePiece(from, to ,prom) 
add: result = movePiece(this, from, to ,prom) 
context: 	this.convertMove = function(board) {		var to = this.pgn.nextMove()		var oldTo = to		if (to == null)			return;		var color = to[1]		to = to[0]				/*			Check which piece has to move.			Find the location of the piece.		*/		var pawnre = /^[a-z]+[1-8]/		var knightre = /^N[0-9]?[a-z]+[1-8]/		var bishre = /^B[a-z]+[1-8]/		var queenre = /^Q[0-9]?[a-z]+[1-8]/		var rookre = /^R[0-9]?[a-z]+[1-8]/		var lCastlere = /^(0|O)-(0|O)-(0|O)/i		var sCastlere = /^(0|O)-(0|O)/i		var kingre = /^K[a-z]+[1-8]/		var prom = ""				var toCoords = getSquare(to)		var fromCoords, from, to, result, tmp, myMove = null, pawnM = false		if (pawnre.test(to)) {			// let see if it is a promotional move			if (/^[a-z]+[1-8]=[A-Z]/.test(to))				prom = to.charAt(to.indexOf('=')+1)			fromCoords = findFromPawn(this.vBoard, to, toCoords, color)			pawnM = true		}		else if (knightre.test(to)) {			fromCoords = findFromKnight(this, to, toCoords, color)		}		else if (bishre.test(to)) {			fromCoords = findFromBish(this.vBoard, to, toCoords, color)		}		else if (queenre.test(to)) {			fromCoords = findFromQueen(this.vBoard, to, toCoords, color) 		}		else if (rookre.test(to)) {			fromCoords = findFromRook(this, to, toCoords, color)		}		else if (kingre.test(to)) {			fromCoords = findFromKing(this.vBoard, to, toCoords, color)   		}		else if (sCastlere.test(to)) {			var bCoords = new Array('e8','g8','h8','f8')			var wCoords = new Array('e1','g1','h1','f1')						if (lCastlere.test(to)) {					bCoords = new Array('e8', 'c8', 'a8', 'd8')					wCoords = new Array('e1', 'c1', 'a1', 'd1')			}			var coords = color=='white'?wCoords:bCoords						fromCoords = getSquare(coords[0])			toCoords = getSquare(coords[1])						from = this.vBoard[fromCoords[0]][fromCoords[1]]			to = this.vBoard[toCoords[0]][toCoords[1]]			// update king location			if ('king' == from.piece && 'white' == from.color)				 this.wKingX = toCoords[0], this.wKingY = toCoords[1]			else if ('king' == from.piece && 'black' == from.color)				 this.bKingX = toCoords[0], this.bKingY = toCoords[1]						result = movePiece(from, to, prom)							myMove = new MyMove()			myMove.moveStr = oldTo[0]			myMove.oPiece = result[2].piece			myMove.oColor = result[2].color			myMove.pPiece = result[3]			myMove.add(new MySquare(fromCoords[0], fromCoords[1]												,result[0].piece, result[0].color))						myMove.add(new MySquare(toCoords[0], toCoords[1]												,result[1].piece, result[1].color))			fromCoords = getSquare(coords[2])			toCoords = getSquare(coords[3])		}		else {			throw("Can't figure out which piece to move '"+oldTo+"'")   		}		from = this.vBoard[fromCoords[0]][fromCoords[1]]		to = this.vBoard[toCoords[0]][toCoords[1]]					// update king location		if ('king' == from.piece && 'white' == from.color)			this.wKingX = toCoords[0], this.wKingY = toCoords[1]		else if ('king' == from.piece && 'black' == from.color)			this.bKingX = toCoords[0], this.bKingY = toCoords[1]					// in case of castling we don't have a null value		if (!myMove)			 myMove = new MyMove()	 		 	var enPassante = null		if (pawnM)			enPassante = getEnPassante(this, fromCoords[0], fromCoords[1],														 toCoords[0], toCoords[1])				if (enPassante) {			var sq = this.vBoard[enPassante[0]][enPassante[1]]			var enP = new MySquare(enPassante[0], enPassante[1]													,sq.piece, sq.color)			myMove.enP = enP			this.vBoard[enPassante[0]][enPassante[1]].color = null			this.vBoard[enPassante[0]][enPassante[1]].piece = null		}					result = movePiece(from, to ,prom)				myMove.oPiece = result[2].piece		myMove.oColor = result[2].color		myMove.pPiece = result[3]		myMove.moveStr = oldTo[0]		myMove.add(new MySquare(fromCoords[0], fromCoords[1]												,result[0].piece, result[0].color))				myMove.add(new MySquare(toCoords[0], toCoords[1]												,result[1].piece, result[1].color))		return myMove	}
meta: 5532	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5532/8dc82f970441289f8c19dae01ddbeadc156f15d6/converter.js/buggy/src/converter.js