Skip to content

Commit

Permalink
Merge pull request #16 from brozeph/v0.2.6
Browse files Browse the repository at this point in the history
V0.2.6
  • Loading branch information
brozeph committed Mar 26, 2015
2 parents 6bbcf90 + df52b4f commit fb79b25
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 134 deletions.
18 changes: 13 additions & 5 deletions .jshintrc
@@ -1,11 +1,11 @@
{
"bitwise" : true,
"camelcase" : false,
"camelcase" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"immed" : true,
"indent" : false,
"indent" : true,
"latedef" : true,
"maxdepth" : 5,
"maxparams" : 5,
Expand All @@ -14,8 +14,16 @@
"noempty" : true,
"node" : true,
"nonew" : true,
"strict" : false,
"strict" : true,
"trailing" : true,
"undef" : true,
"unused" : false
}
"unused" : true,
"globals" : {
"after" : true,
"before" : true,
"assert" : true,
"describe" : true,
"it" : true,
"requireWithCoverage": true
}
}
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,3 +1,4 @@
language: node_js
node_js:
- 0.10
- 0.12
7 changes: 7 additions & 0 deletions HISTORY.md
@@ -1,3 +1,10 @@
0.2.6 / 2015-03-26
==================

* adding Node v0.12 build target for Travis-CI
* enhanced jshint coverage for entire project
* fixing issue where Pawn double-square move was incorrectly restricted in some scenarios where capture would have been evaded

0.2.5 / 2014-10-30
==================

Expand Down
42 changes: 24 additions & 18 deletions lib/algebraicGameClient.js
@@ -1,19 +1,22 @@
var piece = require('./piece.js'),
board = require('./board.js'),
var
piece = require('./piece.js'),
game = require('./game.js'),
gameValidation = require('./gameValidation.js');

// private methods
var getNotationPrefix = function (src, dest, movesForPiece) {
'use strict';

var containsDest = function (squares) {
var
containsDest = function (squares) {
var n = 0;

for (n = 0; n < squares.length; n++) {
if (squares[n] === dest) {
return true;
}
}

return false;
},
i = 0,
Expand Down Expand Up @@ -62,7 +65,8 @@ var getValidMovesByPieceType = function (pieceType, validMoves) {
var notate = function (validMoves, gameClient) {
'use strict';

var algebraicNotation = {},
var
algebraicNotation = {},
i = 0,
isPromotion = false,
movesForPiece = [],
Expand Down Expand Up @@ -225,7 +229,8 @@ AlgebraicGameClient.prototype.getStatus = function (forceUpdate) {
AlgebraicGameClient.prototype.move = function (notation, isFuzzy) {
'use strict';

var move = null,
var
move = null,
notationRegex = /[BKQNR]{0,1}[a-h]{0,1}[1-8]{0,1}[x]{0,1}[a-h]{1}[1-8]{1}/,
p = null,
promo = '',
Expand Down Expand Up @@ -268,18 +273,18 @@ AlgebraicGameClient.prototype.move = function (notation, isFuzzy) {
// apply pawn promotion
if (promo) {
switch (promo) {
case 'B':
p = piece.createBishop(side);
break;
case 'N':
p = piece.createKnight(side);
break;
case 'Q':
p = piece.createQueen(side);
break;
case 'R':
p = piece.createRook(side);
break;
case 'B':
p = piece.createBishop(side);
break;
case 'N':
p = piece.createKnight(side);
break;
case 'Q':
p = piece.createQueen(side);
break;
case 'R':
p = piece.createRook(side);
break;
}

if (p) {
Expand All @@ -304,7 +309,8 @@ module.exports = {
create : function (opts) {
'use strict';

var g = game.create(),
var
g = game.create(),
gc = new AlgebraicGameClient(g, opts);

updateGameClient(gc);
Expand Down
2 changes: 1 addition & 1 deletion lib/board.js
Expand Up @@ -156,7 +156,7 @@ Board.prototype.move = function (src, dest, n) {
},
p = src.piece,
sq = null,
undo = function (b, m, s) {
undo = function (b, m) {
return function () {
m.prevSquare.piece = m.postSquare.piece;
m.postSquare.piece = m.capturedPiece;
Expand Down
18 changes: 11 additions & 7 deletions lib/boardValidation.js
Expand Up @@ -24,7 +24,8 @@
of what is possible anyway).
*/

var piece = require('./piece.js'),
var
piece = require('./piece.js'),
board = require('./board.js'),
pieceValidation = require('./pieceValidation.js');

Expand All @@ -41,7 +42,8 @@ var BoardValidation = function (g) {
BoardValidation.prototype.evaluateCastle = function (validMoves) {
'use strict';

var getValidSquares = function (sq) {
var
getValidSquares = function (sq) {
var i = 0;

for (i = 0; i < validMoves.length; i++) {
Expand All @@ -50,7 +52,6 @@ BoardValidation.prototype.evaluateCastle = function (validMoves) {
}
}
},
isAttacked = false,
r = null,
rank = this.game.getCurrentSide() === piece.SideType.White ? 1 : 8,
squares = {
Expand Down Expand Up @@ -121,7 +122,8 @@ BoardValidation.prototype.evaluateCastle = function (validMoves) {
BoardValidation.prototype.filterKingAttack = function (kingSquare, moves) {
'use strict';

var i = 0,
var
i = 0,
isCheck = false,
n = 0,
r = null,
Expand Down Expand Up @@ -169,7 +171,8 @@ BoardValidation.prototype.isSquareAttacked = function (sq) {
return false;
}

var setAttacked = function (c) {
var
setAttacked = function (c) {
return function (err, squares) {
if (!err) {
var i = 0;
Expand Down Expand Up @@ -225,7 +228,8 @@ BoardValidation.prototype.isSquareAttacked = function (sq) {
return context.attacked;
};

return isAttacked(this.board, board.NeighborType.Above) ||
return (
isAttacked(this.board, board.NeighborType.Above) ||
isAttacked(this.board, board.NeighborType.AboveRight) ||
isAttacked(this.board, board.NeighborType.Right) ||
isAttacked(this.board, board.NeighborType.BelowRight) ||
Expand All @@ -242,7 +246,7 @@ BoardValidation.prototype.isSquareAttacked = function (sq) {
isAttackedByKnight(this.board, board.NeighborType.KnightBelowLeft) ||
isAttackedByKnight(this.board, board.NeighborType.KnightLeftBelow) ||
isAttackedByKnight(this.board, board.NeighborType.KnightAboveLeft) ||
isAttackedByKnight(this.board, board.NeighborType.KnightLeftAbove);
isAttackedByKnight(this.board, board.NeighborType.KnightLeftAbove));
};

// begin evaluation of the valid moves for an entire board
Expand Down
3 changes: 1 addition & 2 deletions lib/game.js
Expand Up @@ -8,7 +8,6 @@

var crypto = require('crypto'),
piece = require('./piece.js'),
Square = require('./square.js'),
board = require('./board.js');

// types
Expand Down Expand Up @@ -64,7 +63,7 @@ var addToHistory = function (g) {
var denotePromotionInHistory = function (g) {
'use strict';

return function (sq) {
return function () {
var latest = g.moveHistory[g.moveHistory.length - 1];

if (latest) {
Expand Down
3 changes: 1 addition & 2 deletions lib/gameValidation.js
Expand Up @@ -6,7 +6,6 @@
*/

var piece = require('./piece.js'),
board = require('./board.js'),
boardValidation = require('./boardValidation.js');

// base ctor
Expand Down Expand Up @@ -95,4 +94,4 @@ module.exports = {

return new GameValidation(g);
}
};
};

0 comments on commit fb79b25

Please sign in to comment.