X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FFusion.js;h=2179aae282f1f7428fe6c66918def77af5e7560a;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=2ead9ad7ceccaa428449b7f6cb3fd6ab27c591ce;hpb=e023d74715d327ebd7623079cb778b0def0a1464;p=vchess.git diff --git a/client/src/variants/Fusion.js b/client/src/variants/Fusion.js index 2ead9ad7..2179aae2 100644 --- a/client/src/variants/Fusion.js +++ b/client/src/variants/Fusion.js @@ -185,7 +185,7 @@ export class FusionRules extends ChessRules { ] }) ); - if (!!oneStep) continue outerLoop; + if (oneStep) continue outerLoop; i += step[0]; j += step[1]; } @@ -326,32 +326,29 @@ export class FusionRules extends ChessRules { isAttackedByBN(sq, color) { return ( this.isAttackedBySlideNJump(sq, color, V.BN, V.steps[V.BISHOP]) || - this.isAttackedBySlideNJump( - sq, color, V.BN, V.steps[V.KNIGHT], "oneStep") + this.isAttackedBySlideNJump(sq, color, V.BN, V.steps[V.KNIGHT], 1) ); } isAttackedByRN(sq, color) { return ( this.isAttackedBySlideNJump(sq, color, V.RN, V.steps[V.ROOK]) || - this.isAttackedBySlideNJump( - sq, color, V.RN, V.steps[V.KNIGHT], "oneStep") + this.isAttackedBySlideNJump(sq, color, V.RN, V.steps[V.KNIGHT], 1) ); } isAttackedByKN(sq, color) { const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); return ( - this.isAttackedBySlideNJump(sq, color, V.KN, steps, "oneStep") || - this.isAttackedBySlideNJump( - sq, color, V.KN, V.steps[V.KNIGHT], "oneStep") + this.isAttackedBySlideNJump(sq, color, V.KN, steps, 1) || + this.isAttackedBySlideNJump(sq, color, V.KN, V.steps[V.KNIGHT], 1) ); } isAttackedByKB(sq, color) { const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); return ( - this.isAttackedBySlideNJump(sq, color, V.KB, steps, "oneStep") || + this.isAttackedBySlideNJump(sq, color, V.KB, steps, 1) || this.isAttackedBySlideNJump(sq, color, V.KB, V.steps[V.BISHOP]) ); } @@ -359,7 +356,7 @@ export class FusionRules extends ChessRules { isAttackedByKR(sq, color) { const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); return ( - this.isAttackedBySlideNJump(sq, color, V.KR, steps, "oneStep") || + this.isAttackedBySlideNJump(sq, color, V.KR, steps, 1) || this.isAttackedBySlideNJump(sq, color, V.KR, V.steps[V.ROOK]) ); } @@ -399,16 +396,17 @@ export class FusionRules extends ChessRules { postPlay(move) { const c = V.GetOppCol(this.turn); - const piece = move.appear[0].p; - if ([V.KING, V.KN, V.KB, V.KR].includes(piece)) - this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; - this.updateCastleFlags(move, piece); + move.kingMove = ( + [V.KING, V.KN, V.KB, V.KR].includes(move.appear[0].p) && + [V.KING, V.KN, V.KB, V.KR].includes(move.vanish[0].p) + ); + if (move.kingMove) this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; + this.updateCastleFlags(move, move.appear[0].p); } postUndo(move) { const c = this.getColor(move.start.x, move.start.y); - if ([V.KING, V.KN, V.KB, V.KR].includes(move.appear[0].p)) - this.kingPos[c] = [move.start.x, move.start.y]; + if (!!move.kingMove) this.kingPos[c] = [move.start.x, move.start.y]; } static get VALUES() { @@ -419,6 +417,10 @@ export class FusionRules extends ChessRules { ); } + static get SEARCH_DEPTH() { + return 2; + } + getNotation(move) { if (move.appear.length == 2 && move.vanish.length == 1) { // Fission (because no capture in this case)