From: Benjamin Auder Date: Sun, 15 Mar 2020 14:49:32 +0000 (+0100) Subject: Fix bug in Eightpieces rules (division by 0) X-Git-Url: https://git.auder.net/?p=vchess.git;a=commitdiff_plain;h=518a0dc97d18276d7c0cf946c69ec761b1ed50a5 Fix bug in Eightpieces rules (division by 0) --- diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js index beaddbe9..f7d93d84 100644 --- a/client/src/variants/Eightpieces.js +++ b/client/src/variants/Eightpieces.js @@ -924,7 +924,7 @@ export const VariantRules = class EightpiecesRules extends ChessRules { absDeltaX = Math.abs(deltaX); const deltaY = y2 - y1, absDeltaY = Math.abs(deltaY); - const step = [ deltaX / absDeltaX, deltaY / absDeltaY ]; + const step = [ deltaX / absDeltaX || 0, deltaY / absDeltaY || 0 ]; if ( // Check that the step is a priori valid: (absDeltaX != absDeltaY && deltaX != 0 && deltaY != 0) ||