MCPcopy Create free account
hub / github.com/react-dnd/react-dnd / canMoveKnight

Function canMoveKnight

examples/00 Chessboard/Tutorial App/Game.js:21–28  ·  view source on GitHub ↗
(toX, toY)

Source from the content-addressed store, hash-verified

19}
20
21export function canMoveKnight(toX, toY) {
22 const [x, y] = knightPosition;
23 const dx = toX - x;
24 const dy = toY - y;
25
26 return (Math.abs(dx) === 2 && Math.abs(dy) === 1) ||
27 (Math.abs(dx) === 1 && Math.abs(dy) === 2);
28}
29
30export function moveKnight(toX, toY) {
31 knightPosition = [toX, toY];

Callers 1

canDropFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected