Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created May 29, 2017 23:08
Show Gist options
  • Save JeffML/1a89798a0585a6a2d46d78b1b8c7362d to your computer and use it in GitHub Desktop.
Save JeffML/1a89798a0585a6a2d46d78b1b8c7362d to your computer and use it in GitHub Desktop.
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