From 9405fd7372fcd6a315c82e3dacb8b829cc04e54f Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Wed, 16 Jan 2013 01:44:12 +0000
Subject: [PATCH] Move move logic into board object.

---
 xtrn/chess/board.js | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/xtrn/chess/board.js b/xtrn/chess/board.js
index 0dc463ba7d..7394a01424 100644
--- a/xtrn/chess/board.js
+++ b/xtrn/chess/board.js
@@ -54,19 +54,23 @@ function Board(moves)
 	this.moves=[];
 	if(moves) {
 		for(move in moves) {
-			// TODO: Promotions
-			m=moves[move].match(/^([a-h][1-8])([a-h][1-8])(.*)$/);
-			if(m==null)
-				throw("Corrupt game (invalid move)!");
-			if(m!=null) {
-				piece=this.getPiece(parsePos(m[1]));
-				if(!piece.moveTo(m[2]))
-					throw("Corrupt game (illegal move)!");
-			}
-			this.moves.push(moves[move]);
+			this.handleMove(moves[move]);
 		}
 	}
 }
+Board.prototype.handleMove
+{
+	// TODO: Promotions
+	m=moves[move].match(/^([a-h][1-8])([a-h][1-8])(.*)$/);
+	if(m==null)
+		throw("Corrupt game (invalid move)!");
+	if(m!=null) {
+		piece=this.getPiece(parsePos(m[1]));
+		if(!piece.moveTo(m[2]))
+			throw("Corrupt game (illegal move)!");
+	}
+	this.moves.push(moves[move]);
+}
 Board.prototype.movenum={value: 0};
 Board.prototype.pieces=null;
 Board.prototype._domove=function(from, to)
-- 
GitLab