X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDynamo.js;h=9d47fd8fbd72ebc5cfe89fc42e68c489f38d1be3;hb=5e1bc6519d4c81aeac40aec7390c64c913cbf566;hp=c600b8ae387f5bb80cdd8ad29d4486cb639e882c;hpb=616561273f216debfeab7f5fc532d0b0a8bc8e2d;p=vchess.git diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index c600b8ae..9d47fd8f 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -73,7 +73,7 @@ export class DynamoRules extends ChessRules { if ( this.subTurn == 2 && square.x == this.firstMove.end.x && - square.y == this.firstMove.end.y) + square.y == this.firstMove.end.y ) { return { appear: [], @@ -186,32 +186,29 @@ export class DynamoRules extends ChessRules { if (this.getColor(x, y) != color) // The only moves possible with enemy pieces are pulls and pushes: return this.getPactions([x, y], color); - else { - // Playing my pieces: either on their own, or pushed by another - // If subTurn == 2 then we should have a first move, - // TODO = use it to allow some type of action - if (this.subTurn == 2) { - return ( - this.moveOnSubturn1.isAnAction - ? super.getPotentialMovesFrom([x, y]) - : this.getPactions([x, y], color, TODO_arg) - ); - } else { - // Both options are possible at subTurn1: normal move, or push - moves = - super.getPotentialMovesFrom([x, y]) - .concat(this.getPactions([x, y], color, "push"); - // TODO: discard moves that let the king underCheck, and no second - // move can counter check. Example: pinned queen pushes pinned pawn. - .filter(m => { - this.play(m); - const res = this.filterMoves(this.getPotentialMoves(/* TODO: args? */)).length > 0; - this.undo(m); - return res; - }); - } + // Playing my pieces: either on their own, or pushed by another + // If subTurn == 2 then we should have a first move, + // TODO = use it to allow some type of action + if (this.subTurn == 2) { + return ( + this.moveOnSubturn1.isAnAction + ? super.getPotentialMovesFrom([x, y]) + : this.getPactions([x, y], color, TODO_arg) + ); } - return moves; + // Both options are possible at subTurn1: normal move, or push + return ( + super.getPotentialMovesFrom([x, y]) + .concat(this.getPactions([x, y], color, "push")) + // TODO: discard moves that let the king underCheck, and no second + // move can counter check. Example: pinned queen pushes pinned pawn. + .filter(m => { + this.play(m); + const res = this.filterMoves(this.getPotentialMoves(/* TODO: args? */)).length > 0; + this.undo(m); + return res; + }) + ); } // TODO: track rooks locations, should be a field in FEN, in castleflags? @@ -354,8 +351,7 @@ export class DynamoRules extends ChessRules { if (this.subTurn == 2) { this.subTurn = 1; this.movesCount--; - } - else { + } else { // subTurn == 1 (after a move played) this.turn = V.GetOppCol(this.turn); this.subTurn = 2;