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
| const myLittleTypes = [{ | |
| id: 1, | |
| description: 'This is good', | |
| }, { | |
| id: 2, | |
| description: 'This is better', | |
| }, { | |
| id: 3, | |
| description: 'This is the best!', | |
| }]; |
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
| import { | |
| makeExecutableSchema | |
| } from 'graphql-tools'; | |
| import { | |
| schema as authorpostsSchema, | |
| resolvers as authorpostsResolvers | |
| } from './authorposts'; |
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
| module.exports = function squareControl() { | |
| const getSquaresControlledBy = (board, pieceColor) => { | |
| var pieces = board.boardPieces[pieceColor]; | |
| const promises = pieces.map(p => | |
| new Promise(resolve => { | |
| this.act({ | |
| role: "movement", | |
| cmd: "legalMoves", | |
| piece: p, |
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
| module.exports = function (boardAndPiece, candidateMoves, reply) { | |
| const opposingColor = boardAndPiece.piece.color === 'W' ? 'black' : 'white'; | |
| //temporarily remove the K to avoid cycles | |
| boardAndPiece.board.removePiece(boardAndPiece.piece); | |
| function canCastle(king, rook, intervening, opposing) { | |
| // console.log("canCastle", arguments) | |
| const opposingControlled = [...opposing.controlled] |
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:legalMoves', function (msg, reply) { | |
| this.prior(msg, function (err, result) { | |
| if (msg.board) { | |
| const result2 = legalMovesWithBoard(msg, result); | |
| if (msg.piece.piece === 'K') { | |
| legalMovesWithKing.call(this, msg, result2, reply) | |
| } else { | |
| reply(err, result2); | |
| } | |
| } else { |
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
| const legalMovesWithBoard = require("./helpers/legalMovesWithBoard") | |
| //... | |
| this.add('role:movement,cmd:legalMoves', function (msg, reply) { | |
| this.prior(msg, function (err, result) { | |
| if (msg.board) { | |
| const result2 = legalMovesWithBoard(msg, result); | |
| //... |
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
| function knightChecks(boardAndPiece, candidateMoves) { | |
| const newMoves = []; | |
| for (const m of candidateMoves.moves) { | |
| const p = boardAndPiece.board.pieceAt(m) | |
| if (!p) { | |
| newMoves.push(m) | |
| } else if (p.color !== boardAndPiece.piece.color) { | |
| m.hasCaptured = p; | |
| newMoves.push(m) |
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
| module.exports = function (boardAndPiece, candidateMoves) { | |
| if (!boardAndPiece.board) return candidateMoves; | |
| const rangeChecks = { | |
| B: vectorChecks, | |
| R: vectorChecks, | |
| K: vectorChecks, | |
| Q: vectorChecks, | |
| P: pawnChecks, | |
| N: knightChecks |