X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FApocalypse.js;h=4587be3b49f399e4013956aaa54d3af24b826f0b;hb=af34341d92d47d14f396e7f4adb81f2a7e9d9a61;hp=ef10b3e1f821f5c2f505718be59823a9a5063dcb;hpb=9edfb7146fdc4dd08914b2a117d2852e705353aa;p=vchess.git diff --git a/client/src/variants/Apocalypse.js b/client/src/variants/Apocalypse.js index ef10b3e1..4587be3b 100644 --- a/client/src/variants/Apocalypse.js +++ b/client/src/variants/Apocalypse.js @@ -274,29 +274,44 @@ export class ApocalypseRules extends ChessRules { return ( ( m.vanish[0].p == V.KNIGHT && - (m.vanish.length == 1 || m.vanish[1].c != m.vanish[0].c) - ) - || - ( - // Promotion attempt - m.end.x == (m.vanish[0].c == "w" ? 0 : V.size.x - 1) && - other.vanish.length == 2 && - other.vanish[1].p == V.KNIGHT && - other.vanish[1].c == m.vanish[0].c - ) - || - ( - // Moving attempt - !movingLikeCapture(m) && - other.start.x == m.end.x && - other.start.y == m.end.y + ( + m.vanish.length == 1 || + m.vanish[1].c != m.vanish[0].c || + // Self-capture attempt + ( + !other.illegal && + other.end.x == m.end.x && + other.end.y == m.end.y + ) + ) ) || ( - // Capture attempt - movingLikeCapture(m) && - other.end.x == m.end.x && - other.end.y == m.end.y + m.vanish[0].p == V.PAWN && + !other.illegal && + ( + ( + // Promotion attempt + m.end.x == (m.vanish[0].c == "w" ? 0 : V.size.x - 1) && + other.vanish.length == 2 && + other.vanish[1].p == V.KNIGHT && + other.vanish[1].c == m.vanish[0].c + ) + || + ( + // Moving attempt + !movingLikeCapture(m) && + other.start.x == m.end.x && + other.start.y == m.end.y + ) + || + ( + // Capture attempt + movingLikeCapture(m) && + other.end.x == m.end.x && + other.end.y == m.end.y + ) + ) ) ); }; @@ -377,10 +392,6 @@ export class ApocalypseRules extends ChessRules { } play(move) { - if (!this.states) this.states = []; - const stateFen = this.getFen(); - this.states.push(stateFen); - // Do not play on board (would reveal the move...) move.flags = JSON.stringify(this.aggregateFlags()); this.turn = V.GetOppCol(this.turn); @@ -410,10 +421,6 @@ export class ApocalypseRules extends ChessRules { this.turn = V.GetOppCol(this.turn); this.movesCount--; this.postUndo(move); - - const stateFen = this.getFen(); - if (stateFen != this.states[this.states.length-1]) debugger; - this.states.pop(); } postUndo(move) { @@ -421,7 +428,7 @@ export class ApocalypseRules extends ChessRules { else this.whiteMove = move.whiteMove; } - getCheckSquares(color) { + getCheckSquares() { return []; }