X-Git-Url: https://git.auder.net/rpsls.js?a=blobdiff_plain;f=variants%2F_Antiking%2Fclass.js;h=5838ed6bbfecdb4c46833ebe66cd3f64d12f1bb1;hb=10c9010b3b04915e132b6b3820f2f19c9ea6dcf0;hp=941bd821c064cd6f797a2a3275d0a51d61e7f4d6;hpb=f31de5e46015a93dca20765da61670035ce8f491;p=xogo.git diff --git a/variants/_Antiking/class.js b/variants/_Antiking/class.js index 941bd82..5838ed6 100644 --- a/variants/_Antiking/class.js +++ b/variants/_Antiking/class.js @@ -37,8 +37,8 @@ export default class AbstractAntikingRules extends ChessRules { return ['k', 'a'].includes(p); } - // NOTE: canTake includes (wrong) captures of antiking, - // to not go to low-level using findDestSquares() + // NOTE: canTake includes (wrong) captures of (anti)king, + // to detect attacks on (anti)kings. canTake([x1, y1], [x2, y2]) { const piece1 = this.getPiece(x1, y1); const color1 = this.getColor(x1, y1); @@ -49,16 +49,14 @@ export default class AbstractAntikingRules extends ChessRules { ); } - // Remove captures of antiking (see above) + // Remove captures of (anti)king (see above) getPotentialMovesFrom([x, y]) { return super.getPotentialMovesFrom([x, y]).filter(m => - m.vanish.length == 1 || m.vanish[1].p != 'a'); + m.vanish.length == 1 || !['k', 'a'].includes(m.vanish[1].p)); } underCheck(square_s, color) { let res = false; - if (!Array.isArray(square_s[0])) - square_s = [square_s]; square_s.forEach(sq => { switch (this.getPiece(sq[0], sq[1])) { case 'k':