Created
May 29, 2017 23:08
-
-
Save JeffML/1a89798a0585a6a2d46d78b1b8c7362d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.add({ | |
role: "movement", | |
cmd: "legalSquares", | |
}, (msg, reply) => { | |
const isPawn = msg.piece.piece === 'P'; | |
const isKnight = msg.piece.piece === 'N'; | |
this.act({ | |
role: "movement", | |
cmd: "rawMoves", | |
piece: msg.piece, | |
isPawn: isPawn, | |
isKnight: isKnight | |
}, (err, msg) => { | |
const squared = []; | |
msg.forEach((move) => { | |
if (move.file >= 'a' && move.file <= 'h') { | |
if (move.rank >= 1 && move.rank <= 8) { | |
squared.push(move) | |
} | |
} | |
}) | |
reply(null, squared); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment