X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/current/gitweb.css?a=blobdiff_plain;f=base_rules.js;h=699b1d814305237d9c6bffb70bee07d0ada503f9;hb=8f87962339f2bcaeb4c2716d0588a63449a68bde;hp=ae2ca80dfa1405239f46806b8124dcea0e9f7d13;hpb=3ca478329f818efdfe2e03ce72c0effa6a8b0c0b;p=xogo.git diff --git a/base_rules.js b/base_rules.js index ae2ca80..699b1d8 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1792,7 +1792,10 @@ export default class ChessRules { continue outerLoop; const oldIJ = [i, j]; [i, j] = this.increment([i, j], step); - if (Math.abs(j - oldIJ[1]) > 1 || Math.abs(i - oldIJ[0]) > 1) { + if ( + Math.abs(i - oldIJ[0]) != Math.abs(step[0]) || + Math.abs(j - oldIJ[1]) != Math.abs(step[1]) + ) { // Boundary between segments (cylinder or circular mode) segments.push([[segStart[0], segStart[1]], oldIJ]); segStart = [i, j]; @@ -2247,7 +2250,7 @@ export default class ChessRules { } // Update castling flags if start or arrive from/at rook/king locations move.appear.concat(move.vanish).forEach(psq => { - if ((!!king && psq.p == king) || this.isKing(0, 0, psq.p)) + if ((king && psq.p == king) || (!king && this.isKing(0, 0, psq.p))) castleFlags[psq.c] = [this.size.y, this.size.y]; // NOTE: not "else if" because king can capture enemy rook... let c = "";